This tutorial will show you how to use the Arbotix-M Robocontroller board to control DYNAMIXEL servos with ROS.
Before you can use the Arbotix board with ROS, you need to flash a proper firmware. Follow the Quick Start Guide from TrossenRobotics to learn how to program the board with Arduino IDE.
If you have successfully programmed the example sketches, open and upload the following sketch:
File -> Sketchbook -> ArbotiX Sketches -> ros
The rest of this tutorial can be done in any machine that runs ROS and have an Internet connection. It can be Leo Rover or your computer.
The driver for Arbotix board is distributed in arbotix package. It can be installed from official repository just by typing:
replace [DISTRO] with the ROS distribution you are using (If you are on LeoOS, type: melodic).
Make sure your setup looks like this:
Then, type in your terminal:
arbotix_terminal by default, assumes the board is connected on /dev/ttyUSB0 port. If it is attached to another device, you can specify it like this:
To check which port the device connects to, you can, for instance, run dmesg -w (Ctrl+C to exit), connect the device and check kernel logs.
If you are using Ubuntu on Windows Subsytem for Linux , you need to open Device Manager and look under Ports for COM port number of the device. COM[N] corresponds to /dev/ttyS[N] path. (e.g. COM4 -> /dev/ttyS4). You might need to run:
A terminal prompt should appear. Type help for the list of commands.
Connect the Dynamixel you want to set id to. Then type ls to see id of connected servo and mv [source] [target] to change it. For example, when the servo has ID 1 and we want to set it to 2, just type:
When you have connected multiple servos, this command will change ALL servos with ID [source] (1 in this example) to ID [target].
You can also read and change some parameters to test servo movement with get and set commands. For example, to read current position of servo with ID 1, type:
To move the servo to position 300 (the range is between 0 and 1023), type:
To set the goal speed of the servo to half of the maximum, type:
The servo should start moving continuously in one direction.
We will create a package that tests the arbotix driver. Let's start by creating a catkin workspace (if you don't have one yet):
and an empty package:
Inside the package, create config/test.yaml file with the following content:
You might need to change to port parameter
You can set more parameters for each joint, like maximum speed, minimum and maximum angle etc. A brief documentation (Unfortunately, a little outdated) can be found here.
And launch/test.launch with the following:
Build the package and source the result space:
Now, run the launch file, by typing:
You should see new topics spawned (check with rostopic list):
And new services (check with rosservice list):
To shortly summarize the features:
We can try to test the features using rostopic and rosservice tools.
Assuming you have connected the servo with ID 1, start by setting the speed to a safe value (0.2 rad/s in this case):
Move servo to a default neutral value:
The maximum angle range for a Dynamixel servo is [-150, 150] degrees which is equal to approximately [-2.62, 2.62] in radians