-
Notifications
You must be signed in to change notification settings - Fork 4
Interfacing Real Robot with MoveIt!
In the previous tutorial we saw how to control a robot in Gazebo using MoveIt!. In this tutorial we will see how to interface MoveIt! with real robotic arm.
We have seen how to control individual joint by sending command to the Joint Position Controller attached to it. ROS defines a more powerful method for controlling the movements of multiple joints simultaneously called the Joint Trajectory Action Controller (JTAC). The JTAC is designed to accept an entire joint trajectory as input. A joint trajectory is a list or sequence of joint positions, velocities, accelerations and efforts for each joint over a period of time.
Here is the documentation of trajectory_msgs/JointTrajectory Message : http://docs.ros.org/kinetic/api/trajectory_msgs/html/msg/JointTrajectory.html
- The desired end effector pose is sent to MoveIt using RViz GUI Plugin or C++/Python Script or through command-line interface provided by MoveIt!
- MoveIt! generates the motion plan in the from of trajectory_msgs/JointTrajectory message.
- MoveIt! sends the trajectory to the Joint Trajectory Action Controller by connecting to the follow_joint_trajectory topic.
Now we need to implement the Joint Trajectory Action Controller on our real robot which will process the trajectory_msgs/JointTrajectory Message sent by MoveIt!.
For this we use the ROS package dynamixel_motor. This package provides the implementation of Joint Trajectory Action Controller for dynamixel motors.
Refer http://wiki.ros.org/dynamixel_controllers/Tutorials for detailed tutorials on dynamixel_motor package.
- Create a launch file to start up the controller manager that will connect to the motors and publish raw feedback data (e.g. current position, goal position, error, etc.) at a specified rate. Here is the definition of controller_manager.launch located in /dxl_tutorial/launch/ folder:
Specify the correct port name, baud rate and min and max motor IDs. Wait till the initialization is complete and all the motors are found by the package.
-
To start the controller manager type the following command:
roslaunch dxl_tutorial controller_manager.launch
-
To examine the motor feedback type the following command in the terminal:
rostopic echo /motor_states/dxl_port
Meta controller is an action server that allows you to group up any number of motors and control it by an action client.
- Attach a Joint Position Controller to each Dynamixel motor. To do this we need create a configuration file specifying the parameters of the controller. Here is the code snippet from controllers.yaml located in /dxl_tutorial/config folder:
-
joint_name should be same as the joint name in URDF. Specify the ID of the Dynamixel motor to which the conroller is attached. Specify minimum,maximaum and initial position of the Dynamixel motor.
-
Now we need to create a configuration file for JointTrajectoryActionController. Here is the definition of joints_trajectory_controller.yaml file located in /dxl_tutorial/config folder:
- Now create a launch file to load controller parameters to the parameter server and start up the controller. Here is the definition of start_meta_controller.launch file located in /dxl_tutorial/launch folder:
Start the controller manager and then load the controllers using the command
roslaunch dxl_tutorial start_meta_controller.launch
To see the list of topics generated type the following command:
rostopic list
We will see that an Action Server is started under the robotic_arm_controller with action namespace of follow_joint_trajectory.
The next step is to convert the raw feedback from dynamixel motors into joint states and publish it. This is done by the script state_publisher.py located in /dxl_tutorial/scripts folder. Here is the definition of robot_state.launch located in /dxl_tutorial/launch folder:
This launch file loads the URDF, starts the state_publisher.py script, joint_state_publisher node and robot_state_publisher node.
To view the arm feedback in RViz type the following commands:
roslaunch dxl_tutorial controller_manager.launch
roslaunch dxl_tutorial robot_state.launch
roslaunch dxl_tutorial rviz.launch
- Before starting MoveIt! we need to edit the controllers.yaml file located in /final_config/config folder. Change the name of the controller from robotic_arm/robotic_arm_controller t0 robotic_arm_controller.
Note:
For Gazebo name should be robotic_arm/robotic_arm_controller.
For real robot name should be robotic_arm_controller.
Upload the Arduino code onto Arduino Mega and make the circuit ready before starting motion planning.
To start path planning on real robot type the following commands in the terminal:
roslaunch dxl_tutorial controller_manager.launch
roslaunch dxl_tutorial robot_state.launch
roslaunch dxl_tutorial start_meta_controller.launch
roslaunch final_config robotic_arm_bringup_rviz.launch