Writing ROS Controllers and Visualization Plugins

In the last chapter, we have discussed about pluginlib, nodelets, and Gazebo plugins. The base library for making plugins in ROS is pluginlib, and the same library can be used in nodelets and Gazebo plugins. In this chapter, we will continue with pluginlib-based concepts such as ROS controllers and RViz plugins. We have already worked with ROS controllers and have reused some standard controllers such as joint state, position, and trajectory controllers in Chapter 11, Simulating Robots Using ROS and Gazebo.

In this chapter, we will see how to write a basic ROS controller for a PR2 robot (https://www.willowgarage.com/pages/pr2/overview) and robots similar to PR2. After creating the controller, use the controller in PR2 simulation. The RViz plugins can add more functionality to RViz and in this chapter we can see how to create a basic RViz plugin. The detailed topics that we are going to discuss in this chapter are as follows:

  • Understanding packages required for ROS controller development
  • Setting the ROS controller development environment
  • Understanding ros_control packages
  • Writing and running a basic ROS controller
  • Writing and running a RViz plugin

Let us see how to develop a ROS controller; the first step is to understand the dependency packages required to start building custom controllers for PR2.

The main set of package that helps us to write real-time robot controllers are:

  • pr2_mechanism stacks. The following is the description of pr2_mechanism stacks:
  • pr2_mechanism: This is a ROS stack consisting of several classes and libraries that can be useful for writing real-time controllers. These packages are for the robot PR2 and we can reuse the packages for other robots. Following are the set of packages inside the pr2_mechanism stack.
  • pr2_controller_manager: The controller manager can load and manage multiple controllers and can work them in a real-time loop.
  • pr2_controller_interface: This is the controller base class package in which all custom real-time controllers should inherit the controller base class from this package. The controller manager will only load the controller if it inherits from this package.
  • pr2_hardware_interface: This package consists of PR2 robot hardware interface. There are interfaces for PR2 actuators, sensors, gripper, and so on. Controllers can directly access the hardware components inside a hard real-time loop.
  • pr2_mechanism_model: This package contains the robot model that can be used inside the controller loaded by the controller manager. The robot model mainly consists of joints, kinematics, and the dynamic model of the robot loaded from the URDF file. The controller mainly handles the main components inside the robot model which need to work in real time.
  • pr2_mechanism_msgs: This package consists of a message and service definition that is used to communicate with the real-time control loop. The message definition consists of the state of real-time controllers, joints, and actuators.

We should install the above packages for starting with ROS real-time controllers.
The following command will install the pr2_mechanism stack in Ubuntu 14.04:

  • In ROS Indigo:
$ sudo apt-get install ros-indigo-pr2-gazebo ros-indigo-pr2-mechanism ros-indigo-pr2-bringup

The description of other ROS packages installing along with the pr2_mechanism stack are as follows:

  • pr2-gazebo: The simulation package of PR2 using Gazebo. It contains the launch file for starting the simulation of the PR2 robot in Gazebo.
  • pr2-bringup: This has the launch files to start the PR2 hardware and simulation.

Before writing the ROS controller, it will be good if we understand the use of each package of the pr2_mechanism stack.

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

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