Obstacle avoidance robot (made from drift car)
Hello again everybody my name is chickenparmi, and I like robots.
Today I would like to show you my obstacle avoidance bot, with a difference. The difference with this bot is that it has been build onto an RC drift car, meaning it goes very fast and is very dangerous.
Not to long ago I purchased 5 HC-SR04's with the intention to build a robot made out of a butter tub using 360o servos for driving and the U.S sensors for avoidance. After I burnt out the servos due to a colour mismatch on the battery pack that idea was also burnt until I get some replacements. After the anger of wasting $32 settled down I remembered my RC drift car that had been sitting on top of my cupboard for a few months now and decided it was time to make it awesome again.
The first thing I had to do was check to see wether the electronics in the car were going to be easy to interface with the arduino, luckily they were. There was a servo for steering and a brushless motor for throttle, the brushless motor was connected to an electronic speed controller which had some leads going to the battery and three wires branching off to a JST connector.
Some googling taught me that the ESC can take the same signals sent to control servos and convert them into signals to control the speed of the brushless motor. The hardest part for me was trying to figure out exactly how to wire up the ESC because power was coming out of the VCC line and that confussed me. The ESC did this to power the reciever that came with the car and the steering servo, I figured this out eventually and after some playing around figured out how to wire it up. The battery goes into the ESC, the VCC and ground from the brushless motor go into the ESC, the three wires coming out of the ESC have the standard servo cable look, the ground goes to the arduino ground, the VCC goes to the VCC of the steering servo and the steering servos ground is connected to the arduino's ground.
After all the wiring I uploaded a basic sketch and found the ESC to be non-responsive, at first I thought it was a trouble in my wiring but everything looked alright and nothing was burning so I had a better look at the code. The code seemed fine but some crucial info itch was at the back of my head. I replugged the ESC into the remote control reciever and found that it worked, but I noticed that it beeped in a nice melodic pattern when the controller was on, else, it acted like it was trying to run for its life. I thought about how the radio control sent the signals and wondered if there was a special signal that was sent to turn the ESC on. Atleast now I had a rough idea what I was looking for and could begin to work out what to google for. Some googling found that a idle throttle signal must be sent to the ESC for two seconds to turn the ESC on, apparently its some kind of failsafe. After making some modifications to the code the car would now move forward, but only forward, for some reason it doesn't like going backwards, still have no idea why, please eleborate.
After I was happy with the wiring and mechanical state of the car it was time to put the 'eyes' onto the car to allow it to 'see'. I wanted to make some mounts for the ultrasonic sensors so that they would sit well on the car and be good enough to stay in place at high speeds, I happened to have some styrofoam around so it seemed like a good candidate. Next step came lots of measurements, I had to make sure that everything would fit nice and that there was sufficient holes in the styrofoam to allow the ultrasonic 'eyes' to see through.
I took most of the measurements using my new toy that I got from a Uni open day the week before, it's really handy.
After all the plans were drawn up I drew these marks on the styrofoam and began to cut them out, making quite the mess.
I used a big drill bit and manually drilled out the holes for the 'eyes', again making lots of mess.
After all the of this was done I made sure that if fit.
I repeated this process until it had three sets of 'eyes' so that it could see infront, left and right.
The next step was the programming. Now because this isn't a two sheel setup where only two wheels control both the speed and direction of the robot I knew this was going to be a little more difficult to setup, so I took to the paper and brainstormed. Instead of the wheels simply turning full left or full right depending on wether there is an object either side of the car I decided to use a dependant approach, depending on how far away that object is determines how sharp the wheels turn. If there is something far away to the right, it turns slightly to the left, it there is something very close to the left, it turns sharply right. I achieved this by using the map function in arduino, depending on if there is any objects near it, and if there is which side is closest, it will map that distance to an angle for the wheels to turn to. This was very effective and once implemented worked exactly how I wanted it to. The front ultrasonic sensor is just to cover the blind spot, if there is something infront of the car it will turn right always, then the side facing sensors can do the rest, this saves some extra programming.
On the first test I let it loose on the kitchen, I left scuff marks on the edge of the walls, it needed tweaking. After tweaking the values for the maximum distance it could ping and what distance it should take action I let it loose again, this time only crashing once every 15 seconds, good enough for me.
I took it out onto the road for a while and chased it up and down the street. It detected the gutters really well and only crashed a few times, I didn't get video of this because it was its first and final run. The last crash it had was very hard and broke the supports, I haven't fixed it because I feel like I accomplished what I wanted and I was happy with the outcome.
There is a bad demonstration of the cars turning code in the video but because it was indoors there was always something on each end so it got really claustrophobic.