@@ -306,24 +306,26 @@ void ComputeIK::compute() {
306306 bool colliding =
307307 !ignore_collisions && isTargetPoseCollidingInEEF (scene, sandbox_state, target_pose, link, &collisions);
308308
309- // markers used for failures
310- std::deque<visualization_msgs::Marker> failure_markers;
311309 // frames at target pose and ik frame
312- rviz_marker_tools::appendFrame (failure_markers, target_pose_msg, 0.1 , " target frame" );
313- rviz_marker_tools::appendFrame (failure_markers, ik_pose_msg, 0.1 , " ik frame" );
310+ std::deque<visualization_msgs::Marker> frame_markers;
311+ rviz_marker_tools::appendFrame (frame_markers, target_pose_msg, 0.1 , " target frame" );
312+ rviz_marker_tools::appendFrame (frame_markers, ik_pose_msg, 0.1 , " ik frame" );
313+ // end-effector markers
314+ std::deque<visualization_msgs::Marker> eef_markers;
314315 // visualize placed end-effector
315- auto appender = [&failure_markers ](visualization_msgs::Marker& marker, const std::string& /* name*/ ) {
316+ auto appender = [&eef_markers ](visualization_msgs::Marker& marker, const std::string& /* name*/ ) {
316317 marker.ns = " ik target" ;
317318 marker.color .a *= 0.5 ;
318- failure_markers .push_back (marker);
319+ eef_markers .push_back (marker);
319320 };
320321 const auto & links_to_visualize = moveit::core::RobotModel::getRigidlyConnectedParentLinkModel (link)
321322 ->getParentJointModel ()
322323 ->getDescendantLinkModels ();
323324 if (colliding) {
324325 SubTrajectory solution;
326+ std::copy (frame_markers.begin (), frame_markers.end (), std::back_inserter (solution.markers ()));
325327 generateCollisionMarkers (sandbox_state, appender, links_to_visualize);
326- std::copy (failure_markers .begin (), failure_markers .end (), std::back_inserter (solution.markers ()));
328+ std::copy (eef_markers .begin (), eef_markers .end (), std::back_inserter (solution.markers ()));
327329 solution.markAsFailure ();
328330 // TODO: visualize collisions
329331 solution.setComment (s.comment () + " eef in collision: " + listCollisionPairs (collisions.contacts , " , " ));
@@ -384,10 +386,7 @@ void ComputeIK::compute() {
384386 planning_scene::PlanningScenePtr solution_scene = scene->diff ();
385387 SubTrajectory solution;
386388 solution.setComment (s.comment ());
387-
388- // frames at target pose and ik frame
389- rviz_marker_tools::appendFrame (solution.markers (), target_pose_msg, 0.1 , " ik frame" );
390- rviz_marker_tools::appendFrame (solution.markers (), ik_pose_msg, 0.1 , " ik frame" );
389+ std::copy (frame_markers.begin (), frame_markers.end (), std::back_inserter (solution.markers ()));
391390
392391 if (succeeded && i + 1 == ik_solutions.size ())
393392 // compute cost as distance to compare_pose
@@ -402,6 +401,10 @@ void ComputeIK::compute() {
402401
403402 InterfaceState state (solution_scene);
404403 forwardProperties (*s.start (), state);
404+
405+ // ik target link placement
406+ std::copy (eef_markers.begin (), eef_markers.end (), std::back_inserter (solution.markers ()));
407+
405408 spawn (std::move (state), std::move (solution));
406409 }
407410
@@ -418,9 +421,17 @@ void ComputeIK::compute() {
418421
419422 solution.markAsFailure ();
420423 solution.setComment (s.comment () + " no IK found" );
424+ std::copy (frame_markers.begin (), frame_markers.end (), std::back_inserter (solution.markers ()));
421425
422426 // ik target link placement
423- std::copy (failure_markers.begin (), failure_markers.end (), std::back_inserter (solution.markers ()));
427+ std_msgs::ColorRGBA tint_color;
428+ tint_color.r = 1.0 ;
429+ tint_color.g = 0.0 ;
430+ tint_color.b = 0.0 ;
431+ tint_color.a = 0.5 ;
432+ for (auto & marker : eef_markers)
433+ marker.color = tint_color;
434+ std::copy (eef_markers.begin (), eef_markers.end (), std::back_inserter (solution.markers ()));
424435
425436 spawn (InterfaceState (scene), std::move (solution));
426437 }
0 commit comments