
PRO
EzAng
USA
Asked
— Edited
Sharp IR On Car Robot, Table Top Robot Avoids Falling Off
anyone know how to write this code in java?
:loop
adc_wait(adc0,lower,160)
stop()
reverse(200,500)
sleep(50)
left(255,500)
stop()
forward()
sleep(50)
goto(loop)
now it starts, avoids falling off table, turns left, keeps going - cheers!
All figured out below, I solved it below with help of thetechguru
thanks
Related Hardware EZ-Robot EZ-B v4
Related Control
Indoor Positioning System
Alan
It is in the MyRoli MKII project under my name. I believe the script and object are named Edge Detector (I am at work and can't open the project from here).
Alan
Alan
This uses an H-Bridge movement panel, and a Sharp IR sensor plugged into the ADC7 port. The read-ADC control reads the value, and has a multiplier to adjust the sensitivity range. The script waits for a change, and if the value is high enough that the robot would fall, it stops and backs up, then waits for further instructions. You need to start the cliff detection script (in a real robot, you would probably call it from your init script) before driving the robot.
I believe I used a 5cm-30cm Sharp IR sensor, but I don't recall for sure. You want one with a short enough range that it can detect drops when facing down from a mount point on the robot.
This could easily be adapted to use multiple sensors to detect cliffs on the sides and back and have different actions depending on which sensor triggered.
Alan
sharp sensor:
used port ADC3
sharp IR radar
ADC graph
ADC meter
ADC read
All went well
I know this is an old thread, but I have a question.
Why do you use the H-Bridge Movement Panel in your app?
I use the servo Movement Panel for the wheels.
I am interested in table top robots that don't fall off the table :-) anymore info?
I was using a Roli. It has an HBridge and motors, so I needed the HBridge Movement Panel to make it work, but the example will work with any movement panel. It just issues a stop, then a short back any time the IR detector discovers the distance increase. I only put one on the front, but you would probably want them at each corner with approptiate scripts for a tabletop robot so it doesn't back or turn its way off the table when responding to one of hte sensors. Maybe a script that just does a panic stop if 2 detectors trigger at once.
Alan
Does this need a left or right turn to avoid the edge while it is in reverse?
As far as the script, it depends on how the robot is being driven. This script is just a panic stop. If you want it to continue moving, then yes, you probably want it to make a turn, and then pass control back to whatever you are using to drive it. (When I wrote it, I was manually driving using the movement panel, so when it panic stopped, I took care turning and recovering...).
Alan
works ok then stops, have to keep starting the robot
be back later for more, thanks
EzAng
Alan
I will try what you said, thanks
figured it out - now it starts, avoids falling off table, turns left, keeps going - cheers!
:loop
adc_wait(adc0,lower,160)
stop()
reverse(200,500)
sleep(50)
left(255,500)
stop()
forward()
sleep(50)
goto(loop)
How would you write this code in java?
EzAng
Also, I don't think those sleep(50) lines are doing anything.
JavaScript Code
Code:
Code:
the Sharp IR Analog Distance Sensor (6.99_ detects (avoids) objects in front of the robot, I have this, works well,
I going to try The Sharp Proximity Distance Sensor (9.98) to detect more of a depth proximity
I will receive this Sunday and test and let you know,
the proximity detector is designed for close contact and edge detection.
received the Sharp proximity sensor, did the test,
much better results, responds very different
Thanks
but you can get ones that have a pcb with the wiring all ready for you. Maybe like this from Amazon
This is the Sharp proximity sensor, not the distance sensor
works well for me
Here are 2 pics:
is enough for a table top car :-)
You always can get the Infrared Proximity Sensor Long Range - Sharp GP2Y0A02YK0F 19.95
the Description: Infrared proximity sensor made by Sharp. Part # GP2Y0A02YK0F has an analog output that varies from 2.8V at 15cm to 0.4V at 150cm with a supply voltage between 4.5 and 5.5VDC. The sensor has a Japanese Solderless Terminal (JST) Connector. We recommend purchasing the related pigtail below or soldering wires directly to the back of the module.
what script do you use ior edge detection?
I have one but it may not be as good as you , thanks
Sharp GP2Y0A51SK0F Analog Distance Sensor 2-15cm
https://www.pololu.com/product/2450
Similar to the GP2Y0A21YK0F but a shorter range 2-15cm.
Cliff detection:
not the Sharp Infrared Distance Sensor
PtP what script do you use for the sensors?
will test soon, hope they work