Skip to content

Commit

Permalink
Add more debugging output
Browse files Browse the repository at this point in the history
- Add Stage::introspection() accessor
- Introspection: debug-log solution registration
- RemoteSolutionModel: show internal solution id as tooltip in 1st column
  • Loading branch information
rhaschke committed Oct 20, 2023
1 parent 08b102d commit 0850f37
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/include/moveit/task_constructor/stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class Stage
void setName(const std::string& name);

uint32_t introspectionId() const;
Introspection* introspection() const;

/** set computation timeout (in seconds)
*
Expand Down
5 changes: 5 additions & 0 deletions core/src/introspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ bool isValidCharInName(char c); // unfortunately this is not declared in ros/na
} // namespace names
} // namespace ros

static const char* LOGGER = "introspection";

namespace moveit {
namespace task_constructor {

Expand Down Expand Up @@ -206,6 +208,9 @@ uint32_t Introspection::stageId(const Stage* const s) const {

uint32_t Introspection::solutionId(const SolutionBase& s) {
auto result = impl->id_solution_bimap_.left.insert(std::make_pair(1 + impl->id_solution_bimap_.size(), &s));
if (result.second) // new entry
ROS_DEBUG_STREAM_NAMED(LOGGER, "new solution #" << result.first->first << " (" << s.creator()->name()
<< "): " << s.cost() << " " << s.comment());
return result.first->first;
}

Expand Down
3 changes: 3 additions & 0 deletions core/src/stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ uint32_t Stage::introspectionId() const {
throw std::runtime_error("Task is not initialized yet or Introspection was disabled.");
return const_cast<const moveit::task_constructor::Introspection*>(pimpl_->introspection_)->stageId(this);
}
Introspection* Stage::introspection() const {
return pimpl_->introspection_;
}

void Stage::forwardProperties(const InterfaceState& source, InterfaceState& dest) {
const PropertyMap& src = source.properties();
Expand Down
1 change: 1 addition & 0 deletions core/test/stage_mockups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void ConnectMockup::compute(const InterfaceState& from, const InterfaceState& to

auto solution{ std::make_shared<SubTrajectory>() };
solution->setCost(costs_.cost());
solution->setComment(std::to_string(from.priority().cost()) + " -> " + std::to_string(to.priority().cost()));
connect(from, to, solution);
}

Expand Down
7 changes: 7 additions & 0 deletions core/test/test_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ TEST_F(ConnectConnect, FailSucc) {
// TODO: Solutions are enumerated multiple times
// TODO: invalid solutions leak into enumeration
TEST_F(ConnectConnect, UniqueEnumeration) {
#if 1 // enable solution introspection
int argc = 0;
ros::init(argc, NULL, "debug");
t.enableIntrospection(true);
ros::console::set_logger_level(ROSCONSOLE_NAME_PREFIX, ros::console::levels::Debug);
#endif

add(t, new GeneratorMockup({ 1.0, 2.0, 3.0 }));
auto con1 = add(t, new ConnectMockup());
add(t, new GeneratorMockup({ 10.0, 20.0 }));
Expand Down
10 changes: 9 additions & 1 deletion visualization/motion_planning_tasks/src/remote_task_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,15 @@ QVariant RemoteSolutionModel::data(const QModelIndex& index, int role) const {
return item.id;

case Qt::ToolTipRole:
return item.comment;
switch (index.column()) {
#if 1 // show internal solution id in first column return item
case 0:
return item.id;
default:
return item.comment;
#endif
}
break;

case Qt::DisplayRole:
switch (index.column()) {
Expand Down

0 comments on commit 0850f37

Please sign in to comment.