It's a lot harder than it looks
This is just a comment but I suspect I'm not the only one to experience this problem. I've spent several weeks trying to come up with instructions for my
'cobbled together' robot to avoid walls and objects. The behavior is still unpredictable and 'goofy'. All I want it to do is move in the direction that is most open. A few examples are; "If you get within 26 cm, 'back up' :". If you get within 45 cm and right side is longer than 80 cm, turn right 45° ". "If you get within 45 cm and right side is less than 81 cm, turn left". In this situation it could move forward then backward indefinitely. And then again, it might turn right and maybe left.
I'm not out of ideas but I do have to put it down after tinkering with it for awhile.
'cobbled together' robot to avoid walls and objects. The behavior is still unpredictable and 'goofy'. All I want it to do is move in the direction that is most open. A few examples are; "If you get within 26 cm, 'back up' :". If you get within 45 cm and right side is longer than 80 cm, turn right 45° ". "If you get within 45 cm and right side is less than 81 cm, turn left". In this situation it could move forward then backward indefinitely. And then again, it might turn right and maybe left.
I'm not out of ideas but I do have to put it down after tinkering with it for awhile.
Comments
I'm working on a similar roaming program.
My platform is set up with Servo mounted Ping sensor and two Sharp IR sensors.
I use a BS2 Homework board for control.
Here's where I run into trouble.
My Ping sensor sometimes does not see some objects, like my sweater.
Panning with the servo is pretty fast, but what I've noticed is that sometimes, I'm looking in the wrong direction
to see objects in time to stop or correct the steering direciton.
The Sharp IR sensors help in that when the platform gets within about 8" or so of an object, the platform will stop, pan again
and decide where to go.
I'm patiently awaiting the snow melting, so I can take it outside and do a thorough test.
I'm hoping these comments help you out.
In the latest SERVO Magazine Dennis Clark re-introduces the idea of behavior-based robotics, which is made to handle this sort of thing. The Propeller especially makes this form of robot control quite doable. I think Dennis demonstrates the concept using a simple Arduino procedural code structure, but with eight cores going independently in a Prop you can feed their outputs to a central routine that can make a determination of what to do given the variety and priority of the triggered events.
-- Gordon
@ratronic, This code sits between the motors and a Ping sensor. It calls the Ping, tests the returns and copies the result to a variable. The left and right motor objects use that variable for motor control. @GordonMcComb, I went to the bookstore but I was only able to get a copy of ROBOT mag. I'll get a copy of SERVO
You aren't the only one having the problem. Everyone else is too shy to ask:)
In your original post, you say that what you are trying to do is get your bot to go in the direction that is most open. But your code isn't looking for the direction that is most open.
Why don't you find the largest value returned by the ping sensors, turn a little in that direction. Check again, etc. Remembering the greatest value found. When your bot is done looking, go back to that direction and proceed forward.
Rich
Rich
You have received many excellent suggestions already. Hope you find your solution quickly.
The humble start of one of my many unfinished navigation experiments is shown at http://www.youtube.com/watch?v=Z_YUsDeuT-c , a BoeBot doing S-turns. The L/R turn durations are balanced 50/50 to move overall in a straight line. There is a front-mounted, stationary PING or Sharp IR ranging module measuring distance constantly. My intent is to use the sensor info to achieve graceful continuous motion instead of the more typical herky-jerky stop & start motion. As the robot does S-turns, it will sense and avoid the closest obstacle by modifying the S-turn to turn more left or right.
I'll have to jump back on this now that I've disclosed my top secret plans before Duane or Martin_H beat me to it!
BTW I know you can't reveal how you managed an S turn. It certainly looks like differential steering to me. Good work.
I know not everyone agrees with me on this but I think there is great merit in 'sub-contracting'. Offload the care and feeding of sensors to sub-processors and just query them for sensor values when needed. That way the main code is all about the priority and response to events, not bogged down in critical timing on measuring some pulse duration. In my bot, I am currently working to make the brain a RaspberryPi as it has gobs of RAM and processor speed and math capacity to run the decision logic and handle gyros, accelerometers, ect. I'll move the Propeller to the role of managing the sensors, aggregating data and pre-processing what it can. I'm also not above throwing a PICAXE at some sensor that I don't want to waste a 32bit Propeller cog to manage.
You are correct though. Nothing about it is 'easy'. Things that you get the bot to do that will impress you to no end will be met by shoulder shrugs from the family and others. "Yeah, so... it doesn't run into the walls, big deal?". "Well, it's not SUPPOSED to fall down the stairs though right?". "I can drive my R/C car in a circle too!"
And then you have the situation where the value in front of you becomes smaller than the value behind you, and all the side values are smaller to deal with. IOW, how do you prevent the robot going back and forth in a loop.
The logic is straightforward; I had the robot rotate 360° calling Ping every 30°.
If "LongestDirection" was "7", for example, I would use that as a multiplier which, in theory, should have worked. It would always exit the loop after twelve iterations but the robot often went past the correct direction. If I can make it work this time I will post it. I would like to come up with something that a few others find useful.
He explains pretty well the benefit of having simple rules that build on each other to perform complex tasks.
I learned a lot in the video.
John Abshier
Excellent and exactly what I'm attempting to do.
This confirms my latest platform strategy, which is differential drive.
However, I'm now more concerned about how it will behave outside in the lawn but,
I'll cross that bridge when I get to it.
Thanks Lardom for starting this thread!