The sensors are working, remote control is working – all that remains is to combine them and provide the Raspberry Tank with its first autonomous capability.
To begin with, I implemented a very simple behaviour, as follows:
- Drive forwards until the range to an obstacle in front of the tank is less than one metre
- Shoot whatever is in front of the tank
- Reverse slightly and turn to the right
- Start driving forwards again, and repeat.
A fourth thread was implemented in the C code, which reads the sensor data and issues commands in the same format as the JavaScript on the web interface. The web interface was then updated to include a toggle for the state of autonomy on the vehicle. In truth, autonomy runs all the time – what this new flag does is instruct the tank’s control code to listen either to autonomy or to the web client. Of course, the web client retains overall control so that you can turn autonomy back off again!
As always, you can download the public domain source code from my GitHub.
In the video below, the tank is having its sensors and autonomous behaviour tested on the bench:
And below, it’s first venture into autonomously navigating the world.
Well, that didn’t go quite according to plan. But it is progress! Next time on the Raspberry Tank Build Diary, we’ll tweak the parameters that autonomy uses and see if we can get a better result!
Comments
Hi Ian, I found your site, while I worked on a similar project. I use a HengLong Panther, but only the chassis. Very interesting indeed. What are your latest advances? Please look at my page.
Hi Andreas, your project looks great! You may not have the gun turret on yours, but it looks like your autonomous navigation is working a bit better than mine.
Out of interest, how quickly do your ultrasound sensors respond? Mine seems to take around 200ms to return a reading, (and that reading is quite often wrong) which is why it tends to drive into things a lot!
I have modified the timings of various things in my code to produce a better autonomous behaviour than what you can see in the video above, and I will post a new video soon.
Hi Ian, thanks for the flowers. I have a separate thread for the measurement. It supplies at a frequency of about 10Hz (one arduino-sketch for compass and two ultrasonics). I push in a kind of register and I have an algorithm that smoothes(?) the measured values ??by average.
Next step will be a kind of sensor-radar.
I see - I also have an independent thread for monitoring data from my sensors, but it doesn't poll as fast as yours. I also don't smooth the data because my polling is so slow (I don't want to slow it even more with any averaging).
Hi Ian , are you or will you overlay the sensor data on the video image , only I think it would be awesome, also just a thought could you tie in the range with the gun elevation ? i.e if the object it 10 feet away the gun elevates for the range ? Juat a thought .. good work as ever mate .. cant wait to get my bits and start on this project !
Hi Ian, I don't see my first post , maybe the tinterweb Golins ate it .. so I'll repost .. if it's a duplicate feel free to delete.. btw since that post we are sitting around listens to some DPurple and discussing how your blog will affect our lives over the next few months .. all positive so far except one of the guys is married so he will have to hide the excitement from her.
I have to say first of all Ian thank you very much for sharing this build, I'm gob smacked at how well it's been constructed and the effort you have put into it. I have always wanted to have a pc / tablet controlled RC tank .. I have the Patton which is now in bits on my work bench ready to mod. My three other friends who have 7 tanks between them all went to CPC today and bought PI's lol. We are just waiting for the Voltage regulators and some bits from RS that I ordered tonight. I only stumbled across the article last night it's exactly what I've been looking for for over a year. I noticed on the tanks controller that there are two spare sockets, I had this idea of adding a servo so that the camera can pan independently. Do you think that that would be possible? Also a mad idea we had was to turn the firing system into either laser or some other ammunition and maybe even run an RC version of world of tanks. Anyway that's a long way in the future. So once again thank you very much for all the effort you put in on this blog and the tank build you are a god! :) I'm 47 and giddy about building a PITank ..
No problem, I'm glad there are people out there as enthusiastic about this stuff as we are :)
To answer your questions one by one:
Hi Ian , one of my friends has a Hornet On Screen Display or OSD but this is more for flight but it looks awesome .. a vid of it working http://www.youtube.com/watch?v=B14epS918VM not his video btw. It even shows battery life etc GPS data and some of the stuff you have diplsyed tilt etc. Its way to expensive but the idea is there. Anyway small steps. I have a box full of arduino sensor / motor shields so I will look into that . Plus a Sony micro camera , the battle tank IR is a great idea like you said maybe improved with some code and the Pi ..?
Hi, I'm interested in building an RPi tank. I'v got a WiFi dongle and have bought a tank, but I'm not good with Java or C. Could you e-mail me the code so I don't need to learn 2 new programming languages?
PiBoy, all the code is in my github repository here:
You should be able to get up and running by following roughly what I've done, you don't necessarily need to learn C, unless something's different in your setup and my code doesn't work for you. Let me know if you have any problems getting it working!
However, I have a HengLong German Leopard II. Is it any different?
I’m not sure, sorry. I just have the Tiger so I don’t know what the others are like. If you see a box that looks like the one below when you open it up, it should be similar enough that the electronics mods and code I’ve posted should work. https://www.rctankwarfare.co.uk/forums/download/file.php?id=24557&mode=view