Ultrasonic Navigation Create

Inside the Roomba and Scooba and more, Cool mods, Repair and Upgrades - including the all new iRobot Create Kit. Let's void that warranty baby!

Ultrasonic Navigation Create

Postby mfortuna » February 18th, 2012, 8:57 pm

Here is the start of my latest experiment. Not sure how practical it is but it should be fun.

The main components:

Irobot Create with Command Module
Parallax Ping Ultrasonic Sensor
Arduino software and libraries
Jameco J-Bot software (more on that later)

The Create used to be my Security Bot and then got freed up when I created the Security Dawg.I had the command module but really never did anything with it.

A while ago I got an email from Jameco about their J-Bot Robot which was basically a Arduino with two electric motors and a Parallax ping sensor. There was demo software so I got to thinking. Since the Command Module and Adruino ATmega168 boards were similar could I use the Arduino tools instead? The answer is yes. By setting up for a Diecimila board and using the AVR ISP programmer (The Arduino software uses the Atmel Software as a base) I was able to program the Command Module with Arduino programs.

I got a quick start by using the Jameco provided software. I had to modify the code as follows:

Use a different IO pin for the Ping Sensor.
Set pin B4 to allow debug messages back to the serial port.
Change the BAUD rate because of the difference in clock rates. The Arduino runs at 16Mhz, the Command Module runs at 18.432 Mhz. The normally 9600 BAUD rate becomes 8333.

I don't yet have motor control and the Ping Sensor is mounted backwards (It needs GND, 5V, and signal) in the top center port. Port PB1 is used for the interface. Mounting it backwards made it a direct plug-in.

The screen dump shows the pulse to and from the Ping module (narrow too, wide from). The wider the pulse the closer an object is.

I also have a serial port from the roomba showing debug information.

Next up I want to convert the J-Bot controls to Create controls.

I also want to find were the MCU frequency is declared in the code so I can adjust it for proper serial port operation and timer operation.

Once I do that should have a soft touch robot that drives around without hitting anything.
Attachments
create.JPG
Screen dump
create_ping.jpg
Hardware
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Create

Postby vic7767 » February 18th, 2012, 9:03 pm

Great project Mike. I remember using a sonar detector in a Heathkit robot for object avoidance about 30 years ago. You could hear the unit click and the clicks got faster as it approached an object.
Last edited by vic7767 on February 18th, 2012, 9:09 pm, edited 1 time in total.
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 11950
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Ultrasonic Create

Postby mfortuna » February 18th, 2012, 9:05 pm

I forgot to attach the pictures the first time around. They are there now.

Thanks for the kind words vic7767!
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Create

Postby mfortuna » February 18th, 2012, 9:20 pm

That is a great idea vic7767. I could use the Create speaker to beep. Maybe like sonar or those cool sensors they used in the movie Aliens!
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 20th, 2012, 6:43 pm

More progress but some mysteries.

At 28800 BAUD (The suggested Command module BAUD rate) teraterm displayed "junk" and the Create did not seem to respond to SCI commands. I modified the code to send three 200 msec low pulses on the DD pin which should change the create to 19200 BAUD. I then sent the baud command to change the BAUD rate to 9600. This seems to work.

At this point I can light all LEDS on the Create and play a song. But the mysteries are:

I did not change the mux to enable serial debug output yet I get serial debug output. My scope confirms this output is on the Create SCI RX pin. This is not a good thing since I am not trying to send commands over SCI.

I am testing the program with a USB cable attached. Normally this forces bootloader mode unless the command module Black button is held down during reset assert and de-assert. This makes the command module exit bootloader and run the code.

If I turn on the command module with no USB cable attached the CM should run the program. In this case the Create doesn't turn on, play a song, or set LEDs. Not sure what is going on but it has something to do with the serial port mux settings I think.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby Fraggboy » February 20th, 2012, 7:20 pm

Oooo. :D I have been lurking since you started it.. Great Job Mike!! :D Quick question tho.. In the last picture, you have the sonars pointed towards the back of the Create. Is it supposed to be pointing towards the rear, or the front?
Chris

:confusion-shrug:
Website Question? Check out the FAQ section.
Roomba/Scooba Question? Check out the READ FIRST section.
:text-search:
Before posting, check out the improved Search engine. Your question might have been answered already.
User avatar
Fraggboy
Robot Master
 
Posts: 3643
Joined: March 2nd, 2007, 4:13 pm
Location: In the USA

Re: Ultrasonic Navigation Create

Postby mfortuna » February 20th, 2012, 7:22 pm

I should mention the Arduino code expects 8,16, or 20Mhz for a CPU speed. Not sure why Irobot chose 18.432Mhz. I seem to be able to work around this but it would be easier if the CM was Arduino compatible.

My next step will be enabling driving with distance detect. If I start up the Create with a USB cable attached and then pull the cable the Create seems to be running the program fine. Not a good solution long term but for debugging it should be fine.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 20th, 2012, 7:31 pm

Fraggboy wrote:Oooo. :D I have been lurking since you started it.. Great Job Mike!! :D Quick question tho.. In the last picture, you have the sonars pointed towards the back of the Create. Is it supposed to be pointing towards the rear, or the front?


Towards the front. I need to mount the sensor in the right direction. A servo extension cable and the proper mount will work. I plan on using double sided tape to mount a right angle bracket to the Create and will probably use small screws and nuts to mount the sensor to the bracket. I need to elevate the sensor a bit. Mounted backwards it seems to be detecting the rear of the cargo bay. Again, the reason I mounted it backwards is it plugs directly into the center Command Module DB9. I mainly wanted to prove it works.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby Fraggboy » February 20th, 2012, 7:50 pm

Ah, gotcha.. :) Keep up the great work!! I'm eager to read your updates on your project.
Chris

:confusion-shrug:
Website Question? Check out the FAQ section.
Roomba/Scooba Question? Check out the READ FIRST section.
:text-search:
Before posting, check out the improved Search engine. Your question might have been answered already.
User avatar
Fraggboy
Robot Master
 
Posts: 3643
Joined: March 2nd, 2007, 4:13 pm
Location: In the USA

Re: Ultrasonic Navigation Create

Postby mfortuna » February 22nd, 2012, 9:16 am

Making some progress. I mounted the sensor with a servo extension cable and a piece of plexiglass. Kinda looks like the Microsoft paper clip. I hated that dude! :)

Right now I am trying to read sensors so I can check the cliffs and bumpers state. Having trouble with getting data back from the robot. Once I do that it will be time to turn on the motors!
Attachments
ultra create.jpg
Create with sensor
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 22nd, 2012, 10:57 am

I forgot to add with the sensor mounted properly I get very accurate distance measurements. It still boggles my mind that I am having trouble reading data back from the create. I downloaded the example drive program and the scope showed a steady stream of sensor data from the Create.

I keep thinking the serial port is an issue. I could just write the code using the Atmel environment but I like working with the Adruino.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 23rd, 2012, 11:15 am

I made some progress on the code last night. What I had forgotten is the Atmel buffers up serial data. I need to wait until the buffer is empty before switching the mux. I was able to print out debug data, switch the mux, and then see roomba commands on the terminal screen. I need to try realterm so I can see what values are being sent to the robot.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 25th, 2012, 6:00 pm

It lives!! The biggest issue, and I could not solve it, was switching serial from SCI to USB. Doing that provides debug status back to a terminal program. But doing that switch makes SCI operations flakey.

After giving up on serial status for now I coded the Power, Play, and Advance LEDs on the create to indicate the status.
The Power LED can be red, amber, or green. The other LEDs are green only.
If Power is Red the robot is stopped.
If Power is green the robot is moving. Play on means turning left, Advance on means turning right. If all three are green the robot should be backing up.
If Power is orange the robot is scanning distances. The other two LEDs indicate left or right scan.
The Ping Sensor has an LED to detect activity. That is quite useful.

The basic algorithm is:
Ping forward and check sensors.
If the drop sensors are on stop. If the cliff sensors are on back up. If the left bumper is on turn right. If the right bumper is on turn left.
If both bumpers are on turn left (I may change this to a random turn).
If none of the sensors are on check the distance. If distance > 12" then drive forward. If distance < 12" first turn left and record the distance then turn right and record the distance. Turn towards the longest distance and drive. If both distances are < 12" backup.

This code proves a Command Module can be used with the Arduino tools which are a bit easier to use than the winAVR toolchain.

I have attached the code and will be attaching a video of the Create in action.
Attachments
ultrasonic_create.txt
Arduino sketch
(8.98 KiB) Downloaded 133 times
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 25th, 2012, 6:25 pm

The video and lighting are not that great but here is the create driving around. The sun is about to set here, that doesn't help.
Attachments
PICT0002.AVI
Ultrasonic create video
(64.84 MiB) Downloaded 139 times
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby vic7767 » February 25th, 2012, 6:48 pm

That's some good programming and sensor response. I think the dog is just a bit upset though :wink:
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 11950
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Ultrasonic Navigation Create

Postby mfortuna » February 25th, 2012, 7:02 pm

Thanks vic7767. Our dog Caleb did not maintain safe minimum distance :) He knows when to get out of the way though! It is almost supper time so he will forget all about it.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » February 27th, 2012, 11:49 am

The code doesn't take up much room so I plan on trying add simple navigation to it. I will create a two dimensional array that stores each square foot of the room as occupied or not. This will rely on the wheel tach sensors being accurate since I will record the distance traveled before a sensor goes off or minimum distance is not met. The robot will keep traveling until it determines all squares have been visited or are occupied by something.

Showed it to my wife and she was impressed on how it avoided bumping into things in the living room. It did get fooled by really narrow table legs though.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby Fraggboy » February 27th, 2012, 1:11 pm

Congratulations Mike!! :)

Very cool project. I can't wait to see how your new navigation system works.
Chris

:confusion-shrug:
Website Question? Check out the FAQ section.
Roomba/Scooba Question? Check out the READ FIRST section.
:text-search:
Before posting, check out the improved Search engine. Your question might have been answered already.
User avatar
Fraggboy
Robot Master
 
Posts: 3643
Joined: March 2nd, 2007, 4:13 pm
Location: In the USA

Re: Ultrasonic Navigation Create

Postby mfortuna » February 27th, 2012, 5:55 pm

A minor update. One of the things I noticed is the serial mux only affects the roomba TX side meaning data is received by the Atmega168 from either the USB or roomba but serial data from the Atmega168 is always sent to both the USB and roomba. I think all my serial debug messages made the SCI port unhappy. Even though none of the characters were greater than decimal 127 the roomba still had to decode them. I think this may cause issues.

One way around this could be to program a software UART on a set of available command module ports and add use a max232 chip to interface to a PC serial port. Not sure if I will go that route. I was thinking I could scan for button presses and if I get one output stored debug information. After getting the debug info the roomba and CM may need to be power cycled.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Ultrasonic Navigation Create

Postby mfortuna » March 23rd, 2012, 1:52 pm

I haven't done much but plan on working on this Saturday night. Next step is to use actual distance measurements when doing the spin left and spin right commands. I just eyballed it by turning for some number of milliseconds until it looked like a 90deg turn.

Although it would make mapping tougher an idea I came up with is I could distance scan as the robot turns and find the longest path to drive straight.

But to keep things simple I plan on just using 90deg and 180deg turns.

Here is what I am thinking:

Maintain a 20x20 grid map with each grid representing 1sqft. This will be done by using 400 bytes of data to make it easy, it could be done in 100 bytes with each byte storing 4 values. Values are
0-not explored
1-explored and open
2-explored and occupied.
3-not used

If the robot travels over 20ft in any direction it will turn around.

I will start the robot as if it was in the middle of the room. Memory may have to be shifted around as a new middle is found.

When the robot is done mapping It will beep a certain way, stop, and flash LEDs. At his point I can hook a serial cable to it, press a button, and upload the map to a PC. Finally, I will use the data to draw the map on the PC. Not sure how to do that yet.

If I can get it to work I will trying hooking an Arduino (with the same program) and sonar sensor to one of my reds. I then should have a mapping, cleaning robot.

This project could take a while but I will report back when I make progress.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5221
Joined: February 5th, 2006, 10:35 am
Location: NH

Next

Return to Robotic Hacking

Who is online

Users browsing this forum: CleanMe, mfortuna and 145 guests