Skip to content

Commit 0725f81

Browse files
committed
fix rviz solution execution
Store the set of joints involved in a received trajectories and use this set to constrain serialization of solutions for execution to those joints only. If this is not done, all joints of the RobotModel are considered for the trajectory, but we might not have controllers defined for all joints, so execution will fail. Maybe, a better approach might be to just ask the MTC planner to execute a specific solution id. However, this requires that the planner node is still available.
1 parent f1acfa2 commit 0725f81

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

visualization/visualization_tools/include/moveit/visualization_tools/display_solution.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class DisplaySolution
7676
planning_scene::PlanningSceneConstPtr scene_;
7777
/// sub trajectories, might be empty
7878
robot_trajectory::RobotTrajectoryPtr trajectory_;
79+
/// joints involved in the trajectory
80+
std::vector<std::string> joints_;
7981
/// comment of the trajectory
8082
std::string comment_;
8183
/// id of creating stage

visualization/visualization_tools/src/display_solution.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ void DisplaySolution::setFromMessage(const planning_scene::PlanningScenePtr& sta
103103
steps_ = 0;
104104
size_t i = 0;
105105
for (const auto& sub : msg.sub_trajectory) {
106-
data_[i].trajectory_.reset(new robot_trajectory::RobotTrajectory(ref_scene->getRobotModel(), ""));
106+
data_[i].trajectory_.reset(new robot_trajectory::RobotTrajectory(ref_scene->getRobotModel(), nullptr));
107107
data_[i].trajectory_->setRobotTrajectoryMsg(ref_scene->getCurrentState(), sub.trajectory);
108+
data_[i].joints_ = sub.trajectory.joint_trajectory.joint_names;
109+
data_[i].joints_.insert(data_[i].joints_.end(), sub.trajectory.multi_dof_joint_trajectory.joint_names.begin(),
110+
sub.trajectory.multi_dof_joint_trajectory.joint_names.end());
108111
data_[i].comment_ = sub.info.comment;
109112
data_[i].creator_id_ = sub.info.stage_id;
110113
steps_ += data_[i].trajectory_->getWayPointCount();
@@ -129,7 +132,7 @@ void DisplaySolution::fillMessage(moveit_task_constructor_msgs::Solution& msg) c
129132
auto traj_it = msg.sub_trajectory.begin();
130133
for (const auto& sub : data_) {
131134
sub.scene_->getPlanningSceneDiffMsg(traj_it->scene_diff);
132-
sub.trajectory_->getRobotTrajectoryMsg(traj_it->trajectory);
135+
sub.trajectory_->getRobotTrajectoryMsg(traj_it->trajectory, sub.joints_);
133136
++traj_it;
134137
}
135138
}

0 commit comments

Comments
 (0)