Displaying the target motion

MoveIt! provides a set of messages that can be used to communicate visualization information, essentially providing it with the planned path in order to get a nice visualization of how the arm is going to move to achieve its goal. As usual, communication is performed through a topic, which needs to be advertised:

ros::Publisher display_pub = 
nh.advertise<moveit_msgs::DisplayTrajectory>("/move_group/display_
planned_path", 1, true);

The message we need to publish requires the start state of the trajectory and the trajectory itself. In order to obtain such information, we always need to perform planning using the planning group interface first, and using the created plan, we can proceed to fill in the message:

moveit_msgs::DisplayTrajectorydisplay_msg; 
display_msg.trajectory_start = goal_plan.start_state_; 
display_msg.trajectory.push_back(goal_plan.trajectory_); 
display_pub.publish(display_msg); 

Once the message has been filled in, publishing it to the correct topic will cause the RViz visualization to show the trajectory that the arm is about to perform. It is important to take into account that, when performing a call to plan, it will also show the same type of visualization, so you shouldn't be confused if the trajectory is displayed twice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.152.162