Interfacing the HW with ROS (Robot Arm part 1)

Jonathan Lee
jon-tinkers-with-stuff
3 min readNov 24, 2020

--

The Arm (No creative or imaginative name yet.. suggestions are welcome)

Let’s start with the physical hardware, what you see here is actually about version 4 of my robot arm, it has evolved lots since I first bought it off AliExpress. Since then, I’ve changed out some of the servos to heavier duty sevos (from 11 kg/cm servos to 25kg/cm or 35kg/cm servos closer to the base of the arm, where the moments are larger), switched up my Arduino Uno to an Arduino Mega (since loading ROS on the Uno almost took up all of its measly 32KB of memory!), and also expanded range of motion of the arm for a 5 Degree of freedom (DOF) arm to a 7 DOF arm. Technically, that allows it to manoeuvre the gripper/manipulator into any position in the arm’s work space, which will help later when performing pick-and-place tasks (More on that in later posts)

Next, it was down to writing the Arduino code for the microcontroller for the robot arm. A good developmental framework is to:

1. Start with simple code for interacting with the Servo motors by entering in the desired angle of the servo in degrees into the Arduino Serial monitor.

2. Load the functionality for communicating with Robotics Operating System (ROS) into arduino, using the ros.h library, which is really important for more advanced functionality of the robot arm beyond simple hardcoded arm positions.

3. Start communicating with Arduino to give the desired angles for each servo by publishing over topics in ROS (For e.g. I publish the std_msgs/String “100,130,80,85,180,110,90,35” to the servo_commands topic, which commands servo0 to move to 100 deg, servo1 to move to 130 deg, etc. and read back the joint angles of the robot through the /read_joint_state topic)

These few steps are critical for interfacing the Arduino microcontroller (which is controlling the arm) to ROS on the PC (which will allow for much more advanced robot development), and forms the backbone of the future development.

My Arduino/C++ code for the robot arm can be found at: https://github.com/wootoodoo/6DofArm/blob/main/six_dof_arm_pkg/src/SixDofRobotROSv3/SixDofRobotROSv3.ino

To get Arduino interfaced with ROS, I publish a string of servo angles via rostopic to the servo_commands topic and read the position of the arm by echoing the /read_joint_state topic

There’s still definitely room for improvement, and some areas to work on if I have more time and money are:

1. Getting more expensive servos that can read torque, velocity and position, which will help later with the ROS trajectory controller when moving the robot arm, and also for sensing if the motion of the robot is obstructed or if the load is too heavy for the motors. Currently the physical sensing capabilities of the robot are non-existent, and there is no sense of “touch” or if the robot has failed in reaching its goal trajectory. This is dangerous if the robot is a 500kg beast in the factory, it’s definitely not a cobot at this point…

2. Getting a more stable power supply, since I am working with cheap USB cables and phone chargers that I can scrounge from around the house, and having a stronger and more reliable power supply will make the motion of the robot arm more stable.

My arm and I, enjoying the view

--

--