ROS2_Control Differential Drive Robot Project — Part 1 Mechanical Build
The main idea behind this robot is to build a robot that uses minimum amount of custom written code and utilizes ready to go frameworks available in ROS2 and off-the-shelf parts. The main framework we will leverage is ROS2_Control on Foxy Fitzroy and Nav2 plus Slam Toolbox packages. The mechanical parts are all purchased parts, no 3D-Printing necessary. The robot is able to do basic autonomous navigation using Nav2 stack at the end of the build.
The inspiration for writing this article series is to give back to the ROS/Robotics community who I have learned so much from as I took on this project. Some of the challenges I ran into while learning were:
- There is a lot of material out there for software side of it and hardware side of it separately but very few sites that put everything together.
- There are some good examples available that have good software code but then it only goes so far to run the robot in the simulator, so there is no real-world example to run the robot with software+hardware and make it all work.
- There are a couple of good projects like linorobot2 which has both software and hardware but the hardware is using a micro-controller and my goal was to build it solely using an SBC like Raspberry Pi and avoid using micro-controller all together. However, I must say that linorobot2 is an amazing project and I learned a lot just by reading their code and how elegantly the code and URDF are put together. I would highly recommend that you check out this project and bookmark it at top of your list if you are planning to build a robot.
- There is also a lot of material for building your robot and software for it in ROS1 but a lot less on ROS2 and even less for ROS2 Control. This is my attempt to help fill that gap and provide as much information I can that will help another tinkerer out there.
- ROS2 Control has some great demo examples in github repository but those are again built using fake sensors and not real hardware.
One heads up on software part of ROS2 Control is that you will need to know some C++ or at least be familiar with basics of C++to work with ROS2 Control hardware interface. It is not very difficult as you can literally get template of code from github samples and override code within the pockets of the methods that need to be implemented for the hardware interface, so don’t be discouraged by the fact that it requires C++. Even though I did code in C++ many years ago, I was still hesitant to go back to it and I would have preferred if ROS2 Control libraries had a way to provide hardware interface in Python. Python is just much more convenient and super fast way to prototype your code and has ton of samples on web for hardware interfacing. But as I started digging into the code, I realized that it was not that hard to write C++ code needed for hardware interface.
This is a three part series of articles describing this robot build.
- Part 1 — Mechanical Build
- Part 2 — Electronic Hardware setup and testing motors and IMU
- Part 3 — Software setup and code/configurations specific to this robot and running the robot in simulator
- Part 4 — Putting everything together and running the robot in real-world
This particular robot project consists of following hardware components [links are just example and references, these are NOT affiliate links]:
- Actobotics base frame [detail parts described below]
- Raspberry Pi 4 — running Ubuntu 20.04 — price with accessories $100
- Dynamixel Motors XL430-W250-T- price ~$50@Each x2=$100
- U2D2 — price ~$30
- U2D2 Power hub board — price ~$17
- IMU — BNO055 from Adafruit — price $20 [my simple advice, don’t cheap out on IMU, it will save you a ton of time and pain troubleshooting why things are not working]
- LIDAR- Slamtec RpLidar A1M8- price ~$100
- Battery for RPi4 — price ~$25
- Battery for Dynamixel Motors — price ~$26
- Robotis wheels that fit XL430 motors — price ~$9 for a pair
- Caster wheel in the back — price ~$14 for a set of 4
Overall, you are close to $500 budget. You can compare the parts list to another robot from NVidia — Kaya parts list. It is around $812 excluding 3D printed parts and it includes Intel Realsense Camera. I wanted to include the Realsense camera in my future builds until I heard that Intel recently decided to pull plug on it, which is pretty sad news for the robotics community. Those cameras were pretty reasonably priced for folks doing CV and visual odometry.
I’m using two separate batteries to avoid brown out for RPi4 when motors are under load but I loved the idea that Kaya build has incorporated that shows they are using a DeWalt rechargeable 20V tool battery to power the robot, I might explore that idea in future builds. The hardware build docs for Linobot2 also has advanced configuration that does similar setup.
Reasoning behind going with chosen parts list
The reason for choosing these parts was obviously not cost as it is not a cheaper set of parts by any consideration. I would agree that you will get a lot better value from buying the Turtlebot kit from Robotis as it includes so many more things at a reasonable price. FYI, in ROS world 2021, they also announced that they are updating the Turtlebot kit with RPi4.
At the time I was starting my build early 2021, they did not have an updated version for Raspberry Pi 4 as well as their code base was still based on ROS1 and old Nav stack. Although, later I realized that they do have a Foxy branch in their github repo. Also, they also have OpenCR card in their build which is a souped up Arduino or micro-controller which I did not want to use. I wanted to get everything working on latest ROS2 version which was Foxy [now its Galactic but LTS is still Foxy] and wanted to make it all work on Nav2 and ROS2 Control.
However, if I had purchased the Turtlebot3 kit, for me it would have just become another Lego blocks project that you follow someone else’s instructions and complete it but you don’t actually learn how to solve real world problems and you basically learn how to put that particular robot kit together with instructions and I did not want to do that. For me, after spending similar amount of money and a lot more pain to find, mix and match all the hardware parts described here and make it all work together was a different learning experience and I would probably be able to apply my learning and build next robot much faster because I made those mistakes and spent many months trying to figure out why something didn’t work.
In addition, I also wanted to learn to use Dynamixel servos and their SDK with ROS2. Initially, I started with their cheaper version of the newer Dynamixel motors but those turned out to be too small and I was not able to find off the shelf parts that would allow me to mount the wheel for robot. So I had to change my plan and shell out for slightly larger motors that fit the wheel set sold by Robotis.
As an alternative to Dynamixel, you can go with a combination of off the shelf DC Motors and a decent motor controller Roboclaw and Cytron motor controllers are very good ones. However, Roboclaw is the only one that I know of which will give you ability to read motor Encoders using the Roboclaw libraries. I have built another robot using that configuration and more on it some other time. However, the price point doesn’t change a lot. Roboclaw boards cost around $100 plus a couple of decent DC motors like GoBuilda yellow jackets would be $42x2 bucks so overall setup will still be around $180–190. If you don’t want to go with Roboclaw then you’ll have to go with a cheaper motor controller plus add something like an Arduino or another micro-controller to read Encoders and feed back that information to RPi4.
In the software build part of the robot we will discuss more about the ROS2_Control but since ROS2 Control works very closely with hardware like motor controllers and encoder readers, it is currently written in C++ to provide that very close real-time integration with hardware. So you do want to keep in mind whatever hardware you choose has decent starting point code/libraries to control it using C++ code. You could theoretically separate out the C++ code to hand off to python code by publishing out to topic that your python code listen on but that would not be optimal for performance.
When I first started learning about robotics, I came across article from Dronebot Workshop dude who had detail instructions on how to use Actobotics parts to build his base. I was really impressed with the Actobotics system in both the flexibility of how many different things you can do and also how elegant and industrially beautiful it looks with brushed aluminium look and feel. I liked it so much that I actually went ahead and bought the whole FTC kit of whatever version that was available at that time. They keep changing the kit configuration and discontinue parts so some of these parts are discontinued and you may not be able to find it on their site. But they have a large selection of parts so I’m sure you’ll find something to substitute. The Servocity team is awesome, I had great experience ordering parts from them and recently they seems to have merged or combined operations with GoBuilda, who also have a different style of FTC Kit. So check it out and you can choose whichever one you like, both of them are equally nice and come with lots of parts to build anything you can think of. The GoBuilda is metric based system vs Actobotics is based on imperial system. I invested in this kit because I knew that I would be doing a lot of prototyping along the way and I have since then built 3–4 different robots from single kit parts and I keep reusing them. That’s the beauty of this system that you don’t have to throw it away after you build your robot, you can decide to disassemble the whole thing after few months and recycle the parts to build a completely different robot with a different configuration. So I like that a lot and even though it is a bit expensive upfront, its worth the investment for long term and it pays off.
If you really want to reduce that cost you can consider going with something like Makerbeam that is a lot cheaper but you will have to improvise your design by adding some other adapters to hold your dynamixel to the Makerbeam. You can also completely get rid of all Actobotics parts and go with either ABS or plexiglass parts. However, as you can see from the parts list it is not the Actobotics parts that contribute most to the cost. The three most expensive components are RPi4, Lidar and the Dynamixel system including motors.
I have been thinking about experimenting with using the brand new Raspberry Pi Zero 2W which is supposedly around $15 bucks and has similar power like RPi3 so that would be a great cost reduction from approx. $100 to $25 including a cheap SD card. I did not have good luck with running micro-ROS on RPi Zero 2W but hopefully things will change in future and the compute power for RPi Zero is enough to keep up with the robot. Again, topic for another time and another robot build.
Chassis or Base Link
Base Link uses following parts from Servocity Actobotics system:
- 12" Aluminium U-Channel [x2]- This forms the two sides of the base link rectangle along the forward and backward direction of robot.
- 9" Aluminium U-Channel [x2] — This forms the front and back of the base link rectangle. These are at 90 degree angle to 12" channels. These are slightly offset and not symmetrically placed. The front channel is closer to the edge so we can mount the Lidar mount on top of it. The back channel is slightly inside so the Caster wheel is mounted between the back channel and the center plate.
- 4.5" x 12" Aluminium Pattern Plate [x1] — This plate provides the support for mounting Raspberry Pi 4 and also supports one side of caster wheel. You can replace this with a plexiglass sheet, there are plenty of pre-cut sizes available on Amazon. I recommend mounting at bottom of your channels as it will provide a base to mount the caster wheel.
- Series of Dual Side Mounts [x4]- A series of these needed to hold the channels together at right angle. This is standard Actobotics assembly pattern. They have a lot of youtube videos that show you different combinations of bases you can create using their parts so feel free to choose whatever works best.
- Assortment of screws and nuts — these are all same diameter, just different length depending on where you want to mount it. These are hex socket head screws that can be easily turned using Allen key and nuts are lock nuts with nylon inserts that hold really tight. Very high quality stuff to work with.
I won’t go into exact details of mechanical construction of Actobotic base. They have tons of good Youtube videos you can follow step by step, couple of alternatives listed here:
Frame build Option 1 — https://www.youtube.com/watch?v=YWQhIFRppIA
Frame build Option 2 — https://www.youtube.com/watch?v=I_PHa7mqVFs
After you have completed the base frame assembly using the screws and nuts [most of these are hex socket head screws that can be easily turned using Allen key], it should look like this. These are completed views as I don’t have intermediate stage photos.
Wheels and Motors
The next step is to mount the Dynamixel Motors and Caster wheel to the rectangle chassis. This was by far the trickiest part of the mechanical build as the Robotis Dynamixel motors and motor mounts have very different hole pattern with very different size holes. Most of the Dynamixel motor mount holes accept only M2 size screws, so I had to purchase a pack of assorted sizes of M2 screws, nuts and washers. The one I used I got from Amazon is here — Hitachi M2 M3 Screws Nuts Assortment Kit.
As I said earlier there were many challenges in combining Robotis parts with Actobotics parts:
- Robotis follows metric dimensions [while Actobotics in imperial system] and their dimensions are very small e.g. 12mm, 16 mm radial holes on the hub to mount the wheels on Dynamixel motors. So I had no choice but to purchase the parts from Robotis unless I went with doing 3D-printing of parts myself which would be more time consuming and expensive as I don’t own a 3D printer. My goal was to use off-the-shelf parts as much as I can for the project
- I had originally planned to use the Actobotics wheels that came with FTC Kit for my robot but I found out very quickly that those were too big for mounting hole patterns on the hub of the Dynamixel XL430 motors. And therefore I had no choice but to buy the Robotis wheels they sell on their website that fit with the XL430.
- It was also not my first choice to start with XL430 motors as those are more expensive, approximately $50 each. Originally, I wanted to try and build the robot with their more recent cheaper/smaller version of the XL330 motors so I ordered a couple of those first. But after those arrived I realized that they are not going to fit the Actobotics wheels so I ordered Wheels sold by Robotis. However, to my dismay even the Robotis wheels were too big for those new small XL330 motors and Robotis sells wheels in only one size. So I ended up purchasing XL430s. I realized that I was going on a slippery slope of spending more with Robotis as their parts are very specific dimensions and not a lot of off-the-shelf hardware you can find that will go with their motors. Their motors are wonderful and pleasure to work with but I wish they put in some more thought and made more adapters and parts available so makers and builders can do more with their motors. I had heard in one of their videos that the whole reason for coming out with XL330 series was to attract the maker audience from Arduino and other IoT communities but they have a long way to go if they don’t think about providing a lot of hardware adapters and mounts for those smaller motors.
- Mounting the motor plate [FR12-S102K]for holding the Dynamixel motor to Actobotics channel was very tricky. The motor mount plate has countersunk holes to insert the screws that you need to pre-insert before you attach the motor to the mount plate otherwise you cannot mount the entire motor+mount plate to Actobotics channel.
- Robotis parts are typically expensive. The motors are reasonably priced for what they do [they are servos, motor controller, encoder and programmatic interface all combined in one]. However, the miscellaneous parts like motor frames are fairly expensive.
Having pointed out all the pain and delays in the project to get the right parts and get them to match and work together, here is the final items needed to mount the XL430 to Actobotics Channel:
- FR12-S102K Set x 2 — These are the motor frames that will be mounted on top of the XL430 motors
- Robotis wheels that fit XL430 motors — These are sold in pairs so one is enough for differential drive robot with two wheels and two motors.
After that the assembly consists of follow steps:
- Insert the four of the M2 screws through the four holes around the central hole on FR12-S102K frame.
- Insert bushing supplied with the FR12-S102K frame into the mounting holes on the XL430 motors and then use the supplied screws to mount the FR12-S102K frame on top of the motor.
- Once you have secured that you will have four M2 screws that are sticking out on top of motor. You can align those four screws with the Actobotics channel holes so that the motor is hanging below the channel and then secure them using M2 nuts on other side of bottom plate of the channel. At this point you have your Dynamixel motor mounted on the bottom plate of the C-Channel with the opening of the C facing outwards.
- Next we need to mount the Robotis wheel on face of the XL430 motor. The XL430 comes with a hub pre-mounted that will match with the hole mounting pattern on the wheel. Using the mounting screws that came with Wheel, mount it to the face of the motor.
- Repeat the same steps for the other side wheel, motor assembly to the C-Channel on the other side e.g. if you mounted the motor in prev step to left side of the Chassis, this one will be on right side or vice-versa.
- Complete the chassis mechanical assembly by mounting the Caster wheel in-between back cross channel and the center plate.
- Nice thing was the caster wheel and the motor mounted under the Actobotics chassis were almost at the same level so I didn’t have to put any spacers to adjust the height to make them level.
Here are some pictures to compare your assembly against:
Mounting Raspberry Pi, Dynamixel Controller, Lidar and IMU on base frame
I used four brass standoffs to mount the Raspberry Pi in the middle of base frame. You can get a ton of these brass standoff packs on Amazon for 10–15 bucks and they come in handy in lot of difficult situations.
For IMU I built a small mounting rig using a series of standoffs, an one unit square Actobotic plate and a small square I cut out of plexiglass plate. You can get a big piece of plexiglass plate on Amazon for 10–15 bucks and you can cut it or drill it as needed.
Here are some pictures of IMU rig.
For the Lidar I built another small rig using combination of plexiglass piece and a small Actobotic channel. Same concept as IMU rig except this is bigger. Cool thing about building these rigs is, you can swap these sensors out if you are working on multiple robot projects at the same time. I don’t have multiple Lidar sensors as they are very expensive and its very convenient to be able to unscrew the rig with two screws and move it to another robot.
The U2D2 and its power hub stack up on each other and can be mounted closer to the RPi anywhere inside the base frame so the power cables and Dynamixel cables can reach the connection points. You can watch Robotis getting started videos on how to hook it up with Raspberry Pi with all the wiring.
Mounting the batteries
There are two batteries to power this robot, one to power the Dynamixel motors and the other one to power Raspberry Pi.
The Dynamixel battery comes in a plastic case with mounting holes and I was able to mount it using the 2–3mm nuts and bolts to the side of the Actobotic frame.
The other battery to power Raspberry Pi is just a standard phone charger power bank that I purchased from Amazon combined with usb-C cable to power the RPi. I mounted that using a couple of Velcro bands at the back of base frame.
That’s it, that includes all the hardware that needs to be mounted. In the next article we can look at the basic software setup needed to get ROS2 Foxy installed on RPi along with all the other necessary packages for Lidar, IMU, Dynamixel workbench and ROS2 Control.