MoveIt! comes with a plugin for the ROS Visualizer (RViz). The plugin allows you to setup scenes in which the robot will work, generate plans, visualize the output and interact directly with a visualized robot. We will explore the plugin in this tutorial.
You should have completed the MoveIt! Setup Assistant tutorial and you should now have a MoveIt! configuration for the PR2 that you can use. This tutorial assumes the generated MoveIt! configuration package is called “pr2_moveit_config”.
Alternately, you can just install the pre-made MoveIt! configuration for the PR2 in the pr2_moveit_config ROS package. To install it, run:
sudo apt-get install ros-hydro-moveit-pr2
This tutorial does not require you to actually have a PR2 robot, it just needs a set of working robot model files.
Launch the demo:
roslaunch pr2_moveit_config demo.launch
If you are doing this for the first time, you will have to add the Motion Planning Plugin.
There are four different visualizations active here currently:
The display states for each of these visualizations can be toggled on and off using checkboxes.
- Press Interact in the top menu of rviz. You should see a couple of interactive markers appear for the right arm of the PR2.
- One marker (corresponding to the orange colored right arm) will be used to set the “Goal State” for motion planning. Another marker corresponding to a green colored representation of the right arm will be used to set the “Start State” for motion planning.
- You will be able to use these markers (which are attached to the tip link of each arm) to drag the arm around and change its orientation.
Note what happens when you try to move one of the arms into collision with the other. The two links that are in collision will turn red.
The “Use Collision-Aware IK” checkbox allows you to toggle the behavior of the IK solver. When the checkbox is ticked, the solver will keep attempting to find a collision-free solution for the desired end-effector pose. When it is unticked, the solver will allow collisions to happen in the solution. The links in collision will always still be visualized in red, regardless of the state of the checkbox.
Note also what happens when you try to move an end-effector out of its reachable workspace (sometimes the access denied sign will not appear).