I plan on building a ROS powered robot car in the future when I study ROS. But before that I want to build a simple remote controlled car to test myself. I already bought a chassis for 4 wheeled robot car, and the necessary electronics. The robot will have a Rpi Zero W interfacing with a wireless gamepad and sending movement commands to a microcontroller. I also intend to use meccanum wheels. The plan is to complete this project in 3-4 days. So I plan to complete in the time limit.
4WD Robot Car Chassis kit
Kit common in amazon
Raspberry Pi Zero
Any gamepad that can interface with the Pi
So everything is done. I assembled up the bot with the battery(which adds quite a weight to the bot). I then started to run it around. But the bot isn't able to turn left or right without some forward or backward momentum. The main culprit I believe is the battery. I plan to solve this problem in my ROS robot by putting a screw support and a castor wheel below it to bear the weight of the battery. I hope it works out. This was a really nice simple project and I will use parts from this to make my ROS test bot(name in progress). I have gotten some of the components and will start work on it. Also I will open up a new project entry to log my progress there. Anyway, here are some pictures and videos. See you in the ROS bot project.
Finally added the code for encoder counter using interrupt pins on Pins 18,19,20,21 on the Mega. But the encoder values are getting very skewed which makes these values unusable. So I have updated the code on Github with the encoder counting and storing in variable along with the inaccuracies. For my ROS robot, I will modify this robot with new motors with more accurate encoders, Also will need to fix any possible problems that might pop up but for now the RC Car seems to run. Waiting for the battery to come. Will wire it up and share a video of it finally. Since this is such a simple project, I won't be putting a full build guide, but will list out the exact list of components for anyone to experiment with.
So I managed to resolve any issues with the motor power supply by applying a 12V wall power to the shield. After rewiring the motor connection to the shield according to the correct rotation direction, the movement commands were being sent successfully from the Pi, received on the Mega and the motors were running properly. I also managed to interface the opto-interruptor encoder for the BO Motors, which sucks like hell as I can only keep track of 10 degrees for every count for this encoder. So I will just add this to just keep track of the rotations and not use it any major way. So finally I will just add the encoder code for the 4 motors and close the project there. Next log should be the last. I have also updated the Github with the code and will be putting the final update to it too. Also 12V battery will be added and a final video will be posted.
Today, I wired up the motor connections to the L293D motor driver shield. I then when through a couple of online tutorials to see how to program it. After coding up a single command in the Arduino code, I attached a 6V power supply to the driver and tried to test it. Unfortunately, it didn't work as intended. In the code on M1 motor kept on rotating even if I gave it a stop command. This invites more research and investigation of what is the issue. I suspect that I will need to increase the power supply to probably 9V. But there could be other issues too. For now I am going to keep this project on hold as I have other more important projects ongoing. After the other project is done, I will resume this. I estimate there is only 1-2 days work left.
Also I haven't been able to find the wheel hubs to attach 48mm mecanum wheels to my TT Motors. So this robot is going to be a simple non-holonomic robot car.
I didn't do much work today. I got the main work of testing and debugging of Raspberry Pi Zero W code completed. The messages are being received perfectly on the Arduino's end and now Arduino code can be worked upon.
I also started some test code on the Arduino Mega for the L293D motor shield. Work for tomorrow is going to entail testing and completion of the motor controller code and writing up the command list with their respective motor commands.
I also received my mecanum wheels today. But I couldn't attach them to my TT Motors. So I spent a lot of time searching for a solution online. Finally I found that I didn't receive the mecanum wheel hubs to attach it to the TT Motors. I will be looking to solve this issue as soon as possible because I have also coded for the holonomic movements in the robot.
Today I managed to prepare the python code to run on the Raspberry Pi Zero W. The Pi Zero W is connected to the Redgear Elite Wireless gamepad via a wireless dongle attached to the only USB port on the Pi. The python code access the device files of the gamepad using Evdev library. Using the Evdev library I coded the movement commands. First the L1 button is pressed continously and then the direction command buttons are pressed. I have also added holonomic movement commands too. So the movement command generation is pretty much done. Next, using the serial library, I have coded the appropriate serial transmission messages that are supposed to be received by the Arduino Mega. The testing and debugging of any possible technical and logical bugs is only left now. I have still uploaded the code in a Github repo which will be updated if any corrections are needed.
I also did some work in 2nd phase. I have made serial connections between RPi Zero W and Arduino Mega. Using a bidirectional logic level convertor and 4148 diodes to protect RPi pins from reverse currents, now I have the serial communication connections established. This will also be tested tomorrow.
Tomorrow, after testing and debugging, motor control code will also be worked upon on the Arduino Mega.
Today, I planned out my gameplan and started with my 1st phase of the project. This is the (temporary) components list:
4 wheeled robot chassis kit
Raspberry Pi Zero W
Logic Level Convertor
Arduino Motor Shield(v1)
So for today's work, I revisited an old blog about interfacing gamepads with linux(raspbian) systems. This covers the workings really well and for today I only tried out the controller interfacing with my Raspberry Pi Zero. i am using a Redgear wireless controller with lots of inputs which give a lot of options for future additions.
Tomorrow I plan on building the python code for the movement commands and start with the phase 2 of my project.