Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
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
AI Support Bot
Related Content
Synthiam
PRO
USA
#15  
Hi, I made it back,

I will try what you said, thanks
PRO
Portugal
#16   — Edited
The Roomba and most vacuum robots use IR sensors for cliff detection.
PRO
USA
#17   — Edited
Sharp IR sensor - ARC

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)

User-inserted image


User-inserted image


How would you write this code in java?
EzAng
PRO
Synthiam
#18  
Synthiam ARC doesn't work with Java - at least not without a ton of work. You'd need to create some bridge between the two compiled executables.

Also, I don't think those sleep(50) lines are doing anything.
PRO
USA
#19  
I ment Java script
PRO
Synthiam
#20   — Edited
This is probably a good way to back away from cliffs...

JavaScript Code

Code:


while (true) {

// Wait for ever until the sensor is lower than 160
// meaning a cliff was detected
ADC.waitForLower(adc0, 160);

// start moving back at speed 200
Movement.reverse(200);

// Continue moving back until the cliff sensor
// no longer detects the cliff
ADC.waitForHigher(adc0, 160);

// And continue back a little more just in case
sleep(1000);

// Stop moving cause we're safe
Movement.stop();
}
PRO
USA
#21  
thanks DJ for the code
PRO
Synthiam
#22  
Actually this makes more sense if using any NMS skills for navigating..

Code:




while (true) {

// Wait for ever until the sensor is lower than 160
// meaning a cliff was detected
ADC.waitForLower(adc0, 160);

// Instruct any NMS navigation that we're pausing
Navigation.SetNavigationStatusToPause();

// start moving back at speed 200
Movement.reverse(200);

// Continue moving back until the cliff sensor
// no longer detects the cliff
ADC.waitForHigher(adc0, 160);

// And continue back a little more just in case
sleep(1000);

// Stop moving cause we're safe
Movement.stop();

// Resume any NMS Navigation
Navigation.SetNavigationStatusToNavigating();
}
PRO
USA
#23   — Edited
My problem was - I have a Sharp IR distance sensor, I need a Sharp Infrared Proximity Distance Sensor, ordered it
PRO
Portugal
#24  
What is a the diference between "Sharp Infrared Proximity Distance Sensor" and "Sharp IR distance sensor"?
PRO
USA
#25  
From what I read,

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,
PRO
Synthiam
#26  
I think the distance sensors don’t work well with close objects, specifically edge detection. 

the proximity detector is designed for close contact and edge detection.
PRO
USA
#27  
proteusy,

received the Sharp proximity sensor, did the test,

much better results, responds very different
PRO
Portugal
#28  
What is the reference of those sensores? Can you post a pic?
Thanks
PRO
Synthiam
#29  
The ones I’ve used require a two resistors and they’re tiny and super cheap. Look like this 

User-inserted image



but you can get ones that have a pcb with the wiring all ready for you. Maybe like this from Amazon 

User-inserted image
PRO
Portugal
#30  
Oh yes, i know those sensors. Thanks.
PRO
USA
#31   — Edited
proteusy

This is the Sharp proximity sensor, not the distance sensor

works well for me

Here are 2 pics:

User-inserted image


User-inserted image
PRO
Synthiam
#32  
In my experience, the sensor that ezang just posted isn't great for edge detection. They have difficulty with close objects and prefer a distance of 10+ cm away.
PRO
Portugal
#33  
Yep, that seems to be the Sharp GP2Y0A21YK0F sensor. It works from 10 to 80cm.
PRO
USA
#34   — Edited
Sharp GP2Y0A21YK0F GP2Y0A21 10~80cm Infrared Proximity Distance Sensor

 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.