Skip to content

RosControl

fontysrobotics edited this page Dec 23, 2020 · 1 revision

8.1 intro:

ROS control is a set of packages that include controller interfaces, controller managers, transmissions and hardware_interfaces. The mentioned packages are a rewrite of the pr2_mechanism packages to make controllers generic to all robots beyond just the PR2.

In other words ROS Control is the API that allows simple access to different actuators, and keeps the controller code separated from the actuator code. In our case we are working with a simulated manipulator which will be controlled later using a planner. In order to make it possible for the planner “moveit” to control the manipulator we have to provide a ROS interface. We will be using the ros_control packages which is a standard in ROS for controller interfaces. Please read the documentation for a better overview on ROS control. 8.2 ROS Control & Gazebo: The diagram below shows data flow of ros control and gazebo

More information can be found on Gazebo sim.

8.3 transmissions:

To use ros_control with the robot we need to add to the urdf which will link virtual actuators to joints:

Download the urdf file of this tutorial from the github.

Navigate to example_urdf package -> urdf folder and edit example.gazebo.xacro by adding a transmissions for each joint at the end of the file:

<transmission name="tran0"> <type>transmission_interface/SimpleTransmission</type> <joint name="jarmLink0"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> </joint> <actuator name="motor0"> <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission>

8.4 Gazebo Ros_control plugin:

Gazebo plugin is used to parse the transmission tags and load the hardware interfaces and the controller manager. Add the plugin to the example.gazebo.xacro:

<gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotNamespace>/example_urdf</robotNamespace> </plugin> </gazebo>

And that will conclude the urdf setup.

8.5 Ros_control package:

Last thing we have to do to finish setting up ros control with gazebo is to create a control package. The control package will include a configuration.yaml and a launch file. Navigate to catkin_ws/src and create a package by running the following command: $ catkin_create_pkg example_control controller_manager joint_state_controller robot_state_publisher

Navigate to the folder and create config and a launch directory: $ cd example_control $ mkdir launch config

Navigate to config folder and create a config.yaml file: example_urdf:

joint_state_controller: type: joint_state_controller/JointStateController publish_rate: 50 arm_controller: type: velocity_controllers/JointTrajectoryController joints: [jarmLink0, jarmLink1, jarmLink2, jarmLink3, jarmLink4, jarmLink5] gains: jarmLink0: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} jarmLink1: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} jarmLink2: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} jarmLink3: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} jarmLink4: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} jarmLink5: {p: 10, d: 0.1, i: 0.1, i_clamp: 1} allow_partial_joints_goal: true

Navigate to launch folder and create a control.launch file:

<launch> <rosparam file="$(find example_control)/config/config.yaml" command="load" ns="example_urdf" /> <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/example_urdf" args="arm_controller" /> <node name="robot_arm_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen"> <remap from="/joint_states" to="/example_urdf/joint_states" /> </node> </launch>

Now launch the description package: $ roslaunch example_urdf gazebo.launch Then launch the control package: $roslaunch example_control control.launch

In a new terminal run rostopic list. Notice that we have a list of new available topics starting with the namespace /example_urdf/arm_controller/. Those topics will form the interface between Gazebo and moveit which we will go in depth in the next tutorial. All files can be found on github under tutorial_files/roscontrol that concludes this tutorial