Hi there! I am working on a robot where I have to make an autonomous robot which runs in a lane (1.5-3 m wide), avoiding hitting the cones which mark the lanes, and also avoid collision with any other robots that might be in near vicinity of my robot. To do this I am thinking of using the HC-Sr 04 Ultrasonic sensor as range finder.
To be able to run in a lane and turn with it, I first take the distance from cones on both the sides of the lane, find their mean and then tell my robot to maintain the mean value from both side. This way, I hope that the robot will efficiently stay away from both the lane ends as well as turn with the lane. To turn, I'll make a steering mechanism based on the Ackerman's steering principle, which will be controlled by a servo motor, which in turn is controlled by the Arduino based upon the readings from the ultrasonic sensors.
To avoid collision from other robots, I am using the same method, the sensor on the front gives the distance of any robot in front of it and when it reaches a threshold value, it tells the servo motor to turn.
Now I was wondering whether this system would be efficient enough to be implemented in an autonomous robot running at approx 6-8 m/sec? Also will my Arduino UNO will be able to handle it? Because along with the 3 sensors and servo motor it also has to control 2 main motors.
Thanks!
Grumpy_Mike:
That is just a touch under 18 miles per hour!
That is not a beginners project in any way.
Yup I know, and if you recall, its the very same project whose concept I posted a while ago... Arduino being controlled by RPi which does image processing, remember? Well guess what I've become more skilled now, this is the Arduino part of the project.
how long it will take for 3 HC-SR04 sensors to make distance measurements,
how far the robot will travel in that time, at the design speed, and
how long it will take the robot to correct its position and/or respond appropriately to the presence of obstacles.
To do all (especially part 3) that requires much more information than you have provided, so you can't expect much help from the forum.
Actually the confusion I have about using the 3 sensors is that I am confused whether or not their data might get tangled. I was thinking of connecting all the 3 sensors to pins 7 & 8 on my Arduino (7 echo and 8 trig, the way its on most of the tutorials), by means of a breadboard, But I was confused whether or not it would be possible. If I use all 3 sensors on different pins, I'll be using 6 pins, and I'm concerned about the speed and efficiency of the sensors then. Moreover, during the development phase I want my Arduino to show the outputs on the Serial Monitor. Output from all the three sensors would definately be mingled on the screen, and the biggest problem, if I use all 3 on pins 7 & 8 I presume my code (which is written ad working for 1 sensor at the moment) will work for all 3 sensors, but if I connect them to different pins it'll add length to my code, not good from a programmers perspective. What do you think?
"I have become more skilled", by that I meant that when I posted the complete theory of this project on this forum for feedback, there were a lot of complications, I am good in programming and therefore I was able to quickly get the Image processing part of the RPi done, now that I have moved to the Arduino bit of my project, I'm still new to both Arduino and its coding, but not for long!
Thanks!
Yes, you need 6 pins to handle 3 sensors, unless you build external circuitry. The sensors will interfere with each other, so they have to be used sequentially.
As pointed out by AWOL above, it will take about 1/2 second to process three sensors. At your "design speed" of 6-8 m/s, the vehicle will have traveled 3 to 4 meters while those measurements were being made ! Impressive, eh?
jremington:
Yes, you need 6 pins to handle 3 sensors, unless you build external circuitry. The sensors will interfere with each other, so they have to be used sequentially.
As pointed out by AWOL above, it will take about 1/2 second to process three sensors. At your "design speed" of 6-8 m/s, the vehicle will have traveled 3 to 4 meters while those measurements were being made ! Impressive, eh?
Solve one problem at a time and move on.
This means that by the time my Arduino will be able to make a decision, my robot will be well out of the lane, not at all acceptable. What if I shift the motor control from the Arduino and use it solely for steering purpose(3 sensors + servo), is that gonna speed up processing?
I have decided to start off with 2 m/s as my speed during development, I'll keep on increasing the speed as I go on developing the robot more and more.
Processing speed is not the issue here; it's the speed of sound and the sensitivity of the receivers that's at issue.
Some simple back-of-a-beer-mat calculations:
Speed of sound is 340 ms-1.
We have sensors capable of 6 m range, so 12 m round-trip.
340 / 12 = 28
So 28 readings per second tops.
And, because you're using unmodified sensors, you can only ping one at a time and wait until it has finished its measurement before going to the next sensor.
At close range, the repetition rate could increase but only if you reduce the sensitivity of the receiver.
AWOL:
And, because you're using unmodified sensors, you can only ping one at a time and wait until it has finished its measurement before going to the next sensor.
Can they be modified to work all at once?? I mean if its possible I'm gonna give it a try.
Anyways I was thinking that the sensor has a max range of ~450 cm. Assuming my robot is in the center of the lane, I need no more than ~150 cm from each side, so what if I limit the side sensors to 150-200 CM and the front one to something like 50-60 CM, that's gonna make it work right?
AWOL:
You're going to have to explain how you intend limiting the range of your sensors.
Yes, of course, assuming you can replace the firmware.
I am thinking of using this - initialize a variable having the max range (lets say 200 cm), then after the distance has been calculated check whether its inside the max limit or not, then use or discard the reading depending upon the situation.
But wait, this method is crap, the sensor still runs through its max range, so how do I limit it?
Umm how do I do replace the firmware? I mean any general idea towards modding the sensor?
I dont know if this will help but it will depend on how your code is written.
I found a library for these ultrasonic sensors which was just called HCSR04 I dont have a link for it sorry but it used interrupts so that you didnt have to use pulseIn and wait for the reading to return, the rest of your code will just carry on running.
One more thing, when using multiple sensors, how do I power them up? I mean can I just pull out a 5v line from the power pin on the arduino and one ground line, and connect them all to to common power and ground? I tried it but it returned -1, the output which is supposed to come when the reading is outta range...
EDIT: Wiring and coding faults... Got the three sensors to work simultaneously, thing is, they are giving outputs instantaneously, I'll try adding some heavy task alongside to check if that slows them down.