The plan for building my second robot was simple:
- Build it from cheap components (not Lego)
- Must be able to drive indoors and outdoors.
- Autonomously navigate indoor
- Autonomously (and offline) be able to deliver a tin of beer to a neighbour on the road.
To actually build it is not that simple, working on a small budget is never easy. Every time the motors have to be more powerful, you also need more powerfull motor controllers, batteries, wheels etc. etc. and the price goes up very fast.
I settled on a 4-wheel driven rover design. I had seen several, rather expensive, kits with a similar design so I assumed it was a good idea… The 4 motors should give enough power to drive through grass and lose stones and also let the robot turn like a tank. To be able to turn around on its axis should make it easier to drive indoors and hopefully make the calculations for navigation easier.
For the robot to be able to drive in a straight line all 4 motors must turn with exactly the same speed, so I started looking for budget motors with built-in sensors. I managed to find 4x 9v motors with metal gears and these built-in sensors. Adding 11cm wheels from a RC offroader for extra grip it should give the robot a top speed of 3,1 Km/h and there ought to be enough power for both grass and a tin of beer as extra payload.
It was tempting to build bigger and more powerfull, but even small improvements would make the robot several times more expensive. Compared to my budget components, I wouldn’t have to upgrade that much for the price to increase tenfold, and it is after all only a little project for fun.
Each motor got a L298N motor driver so hopefully I wont have to cool them. The battery is a small 12v lead battery, it’s cheap but also very heavy. The Raspberry Pi is powered by a USB powerbank.
To read the input from the 4 motor sensors and generate PWM signals to control their speed was not as easy as I had hoped. A Raspberry Pi cannot handle the fast inputs from the sensors and is actually not very good at making the PWM signals either. So, I started hunting for an alternative.
Unfortunately I could not find anything suitable that I could program in python. I ended up with an Arduino Mega as it had enough interrupt pins to handle all the motors.
It was a pain getting the motorcontroller bashed together. I have never really done any C programming and I certainly have not become a fan of that during this project. I am proud of the end result though, it works;
- Reads the 4 motor speed sensors
- PID control making each motor run at desired speed
- Protection of the cheap motors;
- Prevent moving motors from changing direction
- “Ease in” so motors don’t start at full speed
- I2C interface to communicate with Raspberry Pi
- LCD display for debugging and settings
- Rotary encoder for menus
- Odometer feedback for Pi
- 3 coloured led for feedback
I never expected to make the perfect robot at the first attempt, so I decided to ignore all aesthetics and just mount everything on a plywood board. A wheel in each corner of a square.
It can drive straight as an arrow and it’s easy to send commands from the Pi via I2C. It has 3 ‘gears’; Indoor, outdoor and manual. How sharp it turns is controlled by the speed, or direction, of the left/right sides. It can drive continuously or use commands like ‘drive forward 75cm’ and does this very accurately. There is odometer feedback to the Pi so it knows how far the robot has driven to aid navigation.
My plan to turn like a tank did not work at all. If you want to turn like a tank ‘extra grip’ is absolutely not your friend, you need the opposite. When I tried to turn the robot around it’s axis it sounded like the motors were trying to rip it apart, to do this the wheels need to slide sideways. Smooth curves are not a problem and maybe if it used very thin and smooth tires, it would work indoors, but I also want to drive outdoors.
Robot #002 is being retired before I got to mount any sensors on it. I want to try to make it work with the motors and wheels I already have by making the robot wider and moving the front and back axis closer to each other and maybe moving the point of gravity closer to one of the axis. I hope Robot #003 will be the robot where I finally get to experiment with navigation etc.
The plan for Robot #003;
- Better at turning
- Battery upgrade
- Fuses (so the project dosn’t end in blue smoke if it gets stuck in a hedge)
- Sensors – loads of sensors
- Hopefully a new motorcontroller that can be programmed in python
- Find the PWN MHz sweet spot to minimise noise from the motors and make them more energy efficient.
- Camera, maybe also a Xbox 360 Kinect
- Telemetry over the air when outside wifi range
When all that works I can finally start looking at the software. The plan is to install Robot Operating System (ROS) on the Pi. Figuring out how to make ROS communicate with my DIY motorcontroller might be an issue but no need to worry about that yet. Finding time for the project will be the biggest problem.