Skip to content

Commit 795bde7

Browse files
committed
Fix Solution::fillMessage() (#432)
The scene_diff field usually describes PlanningScene changes of the end scene relative to the start scene. For backwards planning, this direction is reversed: the start scene is derived from the end scene. Thus, we need to generate a full planning scene message for the end scene if planning progressed backwards. Fixes #405.
2 parents 5a42ca0 + 2450127 commit 795bde7

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

capabilities/src/execute_task_solution_capability.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,15 @@ bool ExecuteTaskSolutionCapability::constructMotionPlan(const moveit_task_constr
170170
exec_traj.controller_names_ = sub_traj.execution_info.controller_names;
171171

172172
/* TODO add action feedback and markers */
173-
exec_traj.effect_on_success_ = [this, sub_traj,
173+
exec_traj.effect_on_success_ = [this,
174+
&scene_diff = const_cast<::moveit_msgs::PlanningScene&>(sub_traj.scene_diff),
174175
description](const plan_execution::ExecutableMotionPlan* /*plan*/) {
175-
if (!moveit::core::isEmpty(sub_traj.scene_diff)) {
176+
scene_diff.robot_state.joint_state = sensor_msgs::JointState();
177+
scene_diff.robot_state.multi_dof_joint_state = sensor_msgs::MultiDOFJointState();
178+
179+
if (!moveit::core::isEmpty(scene_diff)) {
176180
ROS_DEBUG_STREAM_NAMED("ExecuteTaskSolution", "apply effect of " << description);
177-
return context_->planning_scene_monitor_->newPlanningSceneMessage(sub_traj.scene_diff);
181+
return context_->planning_scene_monitor_->newPlanningSceneMessage(scene_diff);
178182
}
179183
return true;
180184
};

core/python/test/rostest_mps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_fw_remove_object(self):
8181
s = self.task.solutions[0].toMsg()
8282
self.assertEqual(s.sub_trajectory[1].scene_diff.world.collision_objects[0].id, "box")
8383

84-
def DISABLED_test_bw_add_object(self):
84+
def test_bw_add_object(self):
8585
# add object to move_group's planning scene
8686
self.psi.add_box("block", make_pose(0.8, 0.55, 1.25), [0.2, 0.2, 0.2])
8787

@@ -104,7 +104,7 @@ def DISABLED_test_bw_add_object(self):
104104
objects = [o.id for o in s.sub_trajectory[1].scene_diff.world.collision_objects]
105105
self.assertTrue(objects == ["block", "box"])
106106

107-
def DISABLED_test_bw_remove_object(self):
107+
def test_bw_remove_object(self):
108108
mps = stages.ModifyPlanningScene("removeObject(box) backwards")
109109
mps.removeObject("box")
110110
self.task.insert(mps, 0)

core/src/storage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ void SubTrajectory::appendTo(moveit_task_constructor_msgs::Solution& msg, Intros
231231
if (trajectory())
232232
trajectory()->getRobotTrajectoryMsg(t.trajectory);
233233

234-
this->end()->scene()->getPlanningSceneDiffMsg(t.scene_diff);
235-
// reset JointStates (joints are already handled in trajectories)
236-
t.scene_diff.robot_state.joint_state = sensor_msgs::JointState();
237-
t.scene_diff.robot_state.multi_dof_joint_state = sensor_msgs::MultiDOFJointState();
234+
if (this->end()->scene()->getParent() == this->start()->scene())
235+
this->end()->scene()->getPlanningSceneDiffMsg(t.scene_diff);
236+
else
237+
this->end()->scene()->getPlanningSceneMsg(t.scene_diff);
238238
}
239239

240240
double SubTrajectory::computeCost(const CostTerm& f, std::string& comment) const {

0 commit comments

Comments
 (0)