My Maze Navigating and Predator Evading Robot

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
I recently finished working on a mobile robot that had to navigate through a maze and evade a predator. I thought the HT section might find the project to be interesting and also if anyone has any specific questions, I would be happy to answer them.

Some background:

The robot had to use a Motorola 68HC12 microcontroller, Tamiya gearbox, and a Pololu Serial dual channel motor controller. Other than that, it was up to each team how they wanted to meet the goals. My team (me and one other guy) decided to try both IR and ultrasonic sensors. We tested both sensors extensively and even put both types on a few prototype robots, but we ended up using only IR for the final project because the ultrasonic wasn't working quite like we were hoping.


The output of each sensor was connected to an analog to digital conversion port of the 68HC12, and from that a "count" was generated. Based on the count, motor directions and outputs were calculated through fuzzy logic. If anyone is interested, here are some files and pictures of the calculations and components.


Excel file for fuzzy membership functions and outputs

Circuit board I designed (previous classes used a big mess of wires). I included 8 transistor driven externally and individually controllable channels. The 68HC12 can't source or sink very much current, but all of the LEDs you will see in the video are high power and would have overloaded it. For this reason, the 8 channels can be turned on and off by the microcontroller by pulling an output pin low or high, which puts the transistor connected on the other end into cut-off or saturation mode. Drawing - Actual Board

Robot body (drawn in solid edge, printed in a rapid prototyper)
Actual Front - Drawing of Front -
Actual Rear - Drawing of Rear

Inside of the robot

Here is a zip file with all of the code we wrote to make the robot work. Main.c and Fuzzy.asm are the "main" files. The evasion section of this code revision uses the fuzzy logic just like the wall evasion program, but it has a 5 second spin-in-place loop as well.



Info on wall detection:

The short range sensors start to detect objects at around 40cm away from the front of the lens. Based on the distance from the front of the sensor, it outputs a certain voltage, which we converted into a "count" in the program. Based on the count, the reading was classified as either low, medium, or high, and was processed accordingly in the fuzzy logic. For example, if the front 3 short range sensors read in low, low, high (left, center, right), we would turn a moderate left since the right sensor was reading a high value. If the readings were high, high, low (left, center, right), we would turn a hard right since the left and center sensors are reading a high value (something is very close). Based on that decision and the magnitude of the turn needed, motor output values were chosen.

If it was determined that the robot had to turn a hard right, the left wheel might get a speed of 7C (on a scale from 00 to 7F, 7F being the fastest it can go) and the right wheel might get a speed of 04 (very slow). That setup should turn a very hard right because the left wheel is spinning way faster than the right.

If all 3 sensors read high, the robot went into backup mode (the function in Main.c is called Getoutofjam()...lol) and the back sensors turned on and used the fuzzy logic just like the front sensors.



Evasion info:

We tried TONS of different evasion modes. At the last minute, the sensors weren't acting like we wanted them to, so we programmed in a 5 second spin and then 5 seconds of driving using the fuzzy logic to avoid objects/predators. In the middle of the contest, we reprogrammed it with a loop to simply spin as fast as possible in place. The point of the evasion mode was to keep my professor from popping the balloon inside the top part of our robot. He popped it a few times, but this project was a huge success and the deans/teachers/students loved it, so he didn't bother taking points off for that.



Here is the webpage we threw together in about 5 seconds for the school website. There is a 5 minute video of the robot competition at the bottom. You have to click on the gif in the bottom right of the robot spinning in place. Link

BTW, you may notice hulk-bot on that page. That was the other team's robot, but their motor controller blew up about 10 minutes before the competition so they didn't get a chance to compete. The motor controllers we used were total garbage. We bought 6 (30 dollars each) and broke them about 15 times. I was able to fix them by switching components from board to board, but their microcontroller burned up (it was an 8 pin Pic) and since we didn't have the program that came flashed from the factory, I couldn't fix their controller.
 
Mar 10, 2005
14,647
2
0
When I read the title, I thought it meant one of these. Very nice work tho! As part of the evasion, could the bot sprint perpendicular to the threat's approach?
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: The Boston Dangler
When I read the title, I thought it meant one of these. Very nice work tho! As part of the evasion, could the bot sprint perpendicular to the threat's approach?

thanks. that was exactly the evasion technique we tried to do. it actually worked to be honest, but it wouldnt see the predator from far enough away for it to work every time. the field of vision of the IR sensors is pretty narrow at 30cm, and based on how fast the predator bot was moving, it would have popped the balloon with the lance before the robot turned all the way around. we were forced to do something else. the ultrasonic sensors would have been perfect for the perpendicular evasion, but we ran out of time and had to just make it work. good question...that was the thing we worked on the most!
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: Leros
What class was this for?

its called microprocessors. the point of the class is to learn how to write some pretty complex assembly programs in a microcontroller environment as well as get into some of the finer details of C. we also learned quite a bit about microprocessor/controller architecture and a lot of the math involved in the operations. i loved this class and the project was a really good way to tie it all into something useful.
 

LeatherNeck

Member
Jan 16, 2001
174
0
76
Very cool. I had a class in Robotics for my MS EE about 12 years ago. I actually did some extra work on my own time to try and get the robot to navigate around tables. I remember how addicting program can be when you're actually trying to solve a problem in the real world. It was a ton of fun.

Your assignment was way more complex than I tried to solve then.
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: LeatherNeck
Very cool. I had a class in Robotics for my MS EE about 12 years ago. I actually did some extra work on my own time to try and get the robot to navigate around tables. I remember how addicting program can be when you're actually trying to solve a problem in the real world. It was a ton of fun.

Your assignment was way more complex than I tried to solve then.

So true. I had to pull myself out of the lab some nights because I was forgetting to study for other classes. It was so much fun to see the robot working that I just couldn't stop trying new things.
 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
Originally posted by: MrDudeMan
I recently finished working on a mobile robot that had to navigate through a maze and evade a predator. I thought the HT section might find the project to be interesting and also if anyone has any specific questions, I would be happy to answer them.

Some background:

The robot had to use a Motorola 68HC12 microcontroller, Tamiya gearbox, and a Pololu Serial dual channel motor controller. Other than that, it was up to each team how they wanted to meet the goals. My team (me and one other guy) decided to try both IR and ultrasonic sensors. We tested both sensors extensively and even put both types on a few prototype robots, but we ended up using only IR for the final project because the ultrasonic wasn't working quite like we were hoping.


The output of each sensor was connected to an analog to digital conversion port of the 68HC12, and from that a "count" was generated. Based on the count, motor directions and outputs were calculated through fuzzy logic. If anyone is interested, here are some files and pictures of the calculations and components.


Excel file for fuzzy membership functions and outputs

Circuit board I designed (previous classes used a big mess of wires). I included 8 transistor driven externally and individually controllable channels. The 68HC12 can't source or sink very much current, but all of the LEDs you will see in the video are high power and would have overloaded it. For this reason, the 8 channels can be turned on and off by the microcontroller by pulling an output pin low or high, which puts the transistor connected on the other end into cut-off or saturation mode. Drawing - Actual Board

Robot body (drawn in solid edge, printed in a rapid prototyper)
Actual Front - Drawing of Front -
Actual Rear - Drawing of Rear

Inside of the robot

Here is a zip file with all of the code we wrote to make the robot work. Main.c and Fuzzy.asm are the "main" files. The evasion section of this code revision uses the fuzzy logic just like the wall evasion program, but it has a 5 second spin-in-place loop as well.



Info on wall detection:

The short range sensors start to detect objects at around 40cm away from the front of the lens. Based on the distance from the front of the sensor, it outputs a certain voltage, which we converted into a "count" in the program. Based on the count, the reading was classified as either low, medium, or high, and was processed accordingly in the fuzzy logic. For example, if the front 3 short range sensors read in low, low, high (left, center, right), we would turn a moderate left since the right sensor was reading a high value. If the readings were high, high, low (left, center, right), we would turn a hard right since the left and center sensors are reading a high value (something is very close). Based on that decision and the magnitude of the turn needed, motor output values were chosen.

If it was determined that the robot had to turn a hard right, the left wheel might get a speed of 7C (on a scale from 00 to 7F, 7F being the fastest it can go) and the right wheel might get a speed of 04 (very slow). That setup should turn a very hard right because the left wheel is spinning way faster than the right.

If all 3 sensors read high, the robot went into backup mode (the function in Main.c is called Getoutofjam()...lol) and the back sensors turned on and used the fuzzy logic just like the front sensors.



Evasion info:

We tried TONS of different evasion modes. At the last minute, the sensors weren't acting like we wanted them to, so we programmed in a 5 second spin and then 5 seconds of driving using the fuzzy logic to avoid objects/predators. In the middle of the contest, we reprogrammed it with a loop to simply spin as fast as possible in place. The point of the evasion mode was to keep my professor from popping the balloon inside the top part of our robot. He popped it a few times, but this project was a huge success and the deans/teachers/students loved it, so he didn't bother taking points off for that.



Here is the webpage we threw together in about 5 seconds for the school website. There is a 5 minute video of the robot competition at the bottom. You have to click on the gif in the bottom right of the robot spinning in place. Link

BTW, you may notice hulk-bot on that page. That was the other team's robot, but their motor controller blew up about 10 minutes before the competition so they didn't get a chance to compete. The motor controllers we used were total garbage. We bought 6 (30 dollars each) and broke them about 15 times. I was able to fix them by switching components from board to board, but their microcontroller burned up (it was an 8 pin Pic) and since we didn't have the program that came flashed from the factory, I couldn't fix their controller.

Pretty cool project, although the layout of the PCB board has the most rounded corners I've seen. :)
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: blahblah99

Pretty cool project, although the layout of the PCB board has the most rounded corners I've seen. :)

lol yeah well i like rounded instead of hard corners. there are a few but i like it...
 

Lord Banshee

Golden Member
Sep 8, 2004
1,495
0
0
This is for an undergrad class? If so WOW, what school do you go to?

I am 4th out of 5 year EE undergrad and i've had most of the digital undergrad classes they offer here (taking the last one next semster Computer Architecure) and they don't offer anything on PCB design (undergrad) nor robot design. But we get coarses that cover a lot of different things. Our microprocessor class also used a 68HC12 (i loved there manuals, a lot better than atmel IMHO) we get to a lot of different thing to work with the 68HC12 and microcontrollers in general but nothing so specific as a robot, we have a grad class on that and we are not allowed to use a 68HC12 because you learn it in the microP class :).

But anyway nice job and what program do you use for PCB Design i would like to start learning it on my own.

 

Qacer

Platinum Member
Apr 5, 2001
2,721
1
91
Originally posted by: blahblah99
Pretty cool project, although the layout of the PCB board has the most rounded corners I've seen. :)

I agree. Most of my trace corners are either 90 degrees or 45 degrees. I haven't done any round corners, yet.

 

PsYcHoCoW

Member
Mar 29, 2005
133
0
0
nice job on the movement / wall detection, the robot turns in a very fluid way.

did you buy all those gp2d sensors? I seem to recall that the unit price is pretty high :eek:
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: Lord Banshee
This is for an undergrad class? If so WOW, what school do you go to?

I am 4th out of 5 year EE undergrad and i've had most of the digital undergrad classes they offer here (taking the last one next semster Computer Architecure) and they don't offer anything on PCB design (undergrad) nor robot design. But we get coarses that cover a lot of different things. Our microprocessor class also used a 68HC12 (i loved there manuals, a lot better than atmel IMHO) we get to a lot of different thing to work with the 68HC12 and microcontrollers in general but nothing so specific as a robot, we have a grad class on that and we are not allowed to use a 68HC12 because you learn it in the microP class :).

But anyway nice job and what program do you use for PCB Design i would like to start learning it on my own.

I used Eagle to design the board. Actually, we did not learn how to use Eagle at school. I taught myself in my spare time because I wanted to know how to do it, but the robot was for an undergrad class. Eagle is an awesome program and the cam processor makes it pretty easy to generate the right gerber files. If you started to use it, I have a cam processing job I can send you that will be exactly what Advanced Circuits needs to make your board (they are the best IMO).
Originally posted by: Qacer
Originally posted by: blahblah99
Pretty cool project, although the layout of the PCB board has the most rounded corners I've seen. :)

I agree. Most of my trace corners are either 90 degrees or 45 degrees. I haven't done any round corners, yet.

ok ok I get the point...you guys hate my rounded traces. I don't see why though. They look better than 45s and 90s IMO because it seems to flow better. Plus, you can fit more traces in tight areas by bending them, which has saved me a lot of trouble on previous boards. I also round the edges of my boards so they aren't sharp.

Originally posted by: PsYcHoCoW
nice job on the movement / wall detection, the robot turns in a very fluid way.

did you buy all those gp2d sensors? I seem to recall that the unit price is pretty high :eek:
Thanks. We did spend quite a bit of time adjusting the fuzzy to make the movement more fluid. They are 10 dollars each, but we had several left over from last year and they were donated by someone...so I bought 3.

 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Not to bring this back up again, but I thought I would mention that rounded traces emit less radiation.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
167
111
www.slatebrookfarm.com
Nice! Now, for a followup project, robots that navigate the sewers and use IR to locate and shoot rats. You could make a fortune!
 

PsYcHoCoW

Member
Mar 29, 2005
133
0
0
can you tell me what motor controller module you used? I'm guessing it doesn't have feedback from the motors, and it's just a PWM generator of some sort?
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: PsYcHoCoW
can you tell me what motor controller module you used? I'm guessing it doesn't have feedback from the motors, and it's just a PWM generator of some sort?

just so you know, it was a total piece of garbage. we broke tons of them. i was unsoldering parts and swapping them from board to board trying to salvage because they kept breaking. at first we thought we were just doing it wrong and it was our fault, but after a while i started to figure out just how sensitive it really was. for example, if you turned it on without a control signal sent to it, it would burn up. that makes no sense.

anyway, its this. the motor controller works really well when it works and has some cool features, but i would highly recommend getting a more expensive one. we found some 70-80 dollar serial motor controllers that work correctly and dont burn up at all. they have current, voltage, and temperature protection where the pololu has none of that.
 

SSSnail

Lifer
Nov 29, 2006
17,458
83
86
<dennis leary>I know some friends in the Middle East that would be verrrrry interested in a toy like this </dennis leary>

Sorry that I can't help, but I'd like to place my pre-order for a container. Can you affix lasers to their freaking heads too?