This is probably the number one thing I hear people express disappointment about regarding Raspberry Pis used for robot controller. It doesn’t even matter which model – Pi 2, 3B, 3b+, and even the Pi4 are just lacking at the power it takes to real-time object recognition. Sadly, the hope that the Pi 4’s extra speed will do the trick leads hobbyists to abandon their Pi 3s for a 4, only to wind up twice disappointed – first with the image-processing speed and second with how much faster their battery dies in spite of very little benefit for the rest of the robot’s needs.
Fortunately, there is a solution that doesn’t require you committing a much larger, heavier, and more expensive computer to control your robot. The problem can be solved by off–loading the vision (or whatever heavy processing application) to another, more powerful computer on the network. If you’re using ROS (and I truly hope you are for so many reasons), this is incredibly easy to do and takes only a few seconds. With an extra minute or so of effort, it happens automatically and you don’t have to think about it again. Further, you aren’t limited to one robot tapping the power of powerful computer – you can have several robots or even stationary Raspberry Pis with camera to monitor different areas for motion. When motion is detected, they can send an image to the big machine for the recognition work.
How it Works
When you network two or more computers with ROS, only one will run roscore – I call this one the master and I call all others slaves. Once the networking is complete and roscore is running on the master, any nodes started on the slaves can see and publish ROS messages just as if you were on the master. Simply launch nodes on the other machines as usual – but without starting roscore on that machine.
How to do it
I recall being new at ROS and thinking “Networking sounds like another hassle I don’t need right now – I’m confused enough.” When I finally decided to try it, I kicked myself for waiting for so long – it would have simplified my robotics development, not slow it down. It was as easy as doing the following from the command line:
- Find the IP address of each computer by running “ip address” and noting the ip address under the field with “inet.”
- On ALL computers: “export ROS_MASTER_URI=http://ip_of_master:11311” – Note that you need to use the master’s ip on ALL machines.
- On all computers: “export ROS_IP=ip_of_that_machine” – Note that you’ll need to use the machine’s own IP address in this step.
- Start roscore on the master.
- Try rostopic list or rostopic echo some_topic on the slave to see the traffic.
That’s all there is to it. It’s not just useful for image processing, but for anything at all that you want to offload from the slower computer. RVIZ and other visualization tools are notoriously heavy. Want to try some machine learning stuff? Export the work to a faster machine. I did a better explanation, demo, and walked you through the process in the video below.