Navigating with Ultrasonic Distance Sensor
PPra
Posts: 10
So for my physics project, my partner and I wanted to use an ultrasonic distance sensor to navigate a maze. The problem is, we can only read the distance between the robot and an obstacle, and the sensor plays no part in navigating the robot. How would I program it so that the robot could manuever based on its readings from the sensor? I'm completely new to programming, sorry. Is there a way to program the robot so it doesn't have to be attached to the CPU to display the distance readings? Do we have to buy the mounting bracket, or should the sensor work by itself, without having to rotate around? Thanks in advance!!
Comments
or this http://www.parallax.com/downloads/roaming-ping-simple-basic-stamp-code
The first download Franklin linked to, incorporates both the IR and Ping Sensors. This program has been around for quite a while and is well tested.
http://www.parallax.com/downloads/roaming-ping-advanced-basic-stamp-code
If you are having problems with the program, you might want to include a picture of how you have it hooked up.
here is a video of my maze and the robot...the robot needs to move forward but it will only rotate around..i am using the basic stamp code roaming with ping, and just pressed play and disconnected the robot after and this is what happens
Try making the walls a little higher. You will have to rely on the IR sensor on the breadboard for walls that low. Is see you do not have IR sensors.
Here is the photo of the connection as well as the connection we got from the internet we used as an example to set it up. I think our board is unusual, because most of them had the 3 black thingies encircling the white portion (at least in the pictures we looked online), but ours only had black thingies on the top and to the left, not on the bottom (sorry I do not know the correct terminology).
Here is the video of the programming...it is basically exactly what I downloaded Roaming with Ping Basic, I believe.
Without the IR sensors how are you going to keep the bot from trying to climb the low walls of the maze? Two servos will always run at slightly different speeds, no matter how well calibrated. Also, any slight irregularity of the rolling surface could alter the direction the bot is headed. How will the bot know it is travelling down the center of the corridor and not dragging itself along one side? The IR sensors are there to correct the path the bot is taking so that it does not eventually run up against a side wall. They will also help in deciding which way to turn when reaching a corner since the rigidly mounted ultrasonic sensor will only report distance to whatever obstruction is straight ahead. If you don't have the IR sensors you could also try wire whiskers to help detect the side walls.
I did correct my post #6 after I saw your video with no IR sensors.
You need another set of sensors for that. There is really no way to get around that.
1. The Code you posted requires IR sensors (I'm not sure what a input value a disconnected pin has, but you probably don't want that.) The second link to code in post 2 does not require the IR sensors, but does use the bracket & ping servo.
2. The pin definitions in the code have the ping)) sensor on pin 15. Your wiring diagram has it on pin 0. And the ping servo (which you don't have) is on pin 14 in the code. Make sure that the pin definitions in your code agree with your actual wiring.
3. Without the ping bracket and servo, the ping will only point straight ahead. So if the BOT approaches a wall diagonally, it will hit the wall and not be able to adjust. With the bracket and servo, the ping would sweep from side to side and you could use those distances and adjust the BOTs direction. You can do the same without the bracket by:
traveling a short distance forward - stop - rotate the BOT - measure distance - use that value to adjust the bots motion - rotate the bot back to the desired direction - repeat.
That is significantly more complex code in addition to the maze solving code and much slower travel.
Hope this helps
Tom
Not with a single, fixed mounted Ping. In order for a bot to traverse a maze it has to know what is to its left and right as well as what is up ahead. When the bot approaches a corner, all it knows is that something is in front of it at xx inches. How is the bot going to determine which way to turn? All it "sees" is the wall in front of it. At least with a rotatable Ping you will have angular information along with distance to object. With IR sensors or whiskers the bot will also know where it is relative to the walls and correct its direction of travel to keep it near the center. Also, with the IR sensors or whiskers the bot will orient itself to the new direction of travel after making the turn.