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-B v4
Related Control Indoor Positioning System

ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

#1  

Do you mean a cliff detector?  I use an Sharp IR sensor and a script to detect cliff edges.

Alan

PRO
USA
#2  

do you have the Arduino code for that

#3  

No, I did it in Synthiam ARC with an EZ-B V4/2.

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

PRO
USA
#4  

ok talk later, thanks

#5  

This has come up a few times lately.  When I have a few minutes either tonight or maybe Wednesday I'll make a project without all the extra stuff just to demonstrate how this works.  Maybe even create a tutorial, although I never have enough free time for that lately.

Alan

#6  

I just posted a cliff detection sample project: https://synthiam.com/Community/Apps/cliff-detection-sample-18442

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

PRO
USA
#7  

Thanks for the info and the link, I will try later,

PRO
USA
#8  

I used my Arduino, com3 on ARC

sharp sensor:

used port ADC3

sharp IR radar

ADC graph

ADC  meter

ADC read

All went well

PRO
USA
#9  

thetechguru,

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?

#10  

@EzAng 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

PRO
USA
#11   — Edited

any sensors better then the sharp IR for table top robots that don't fall off the table?

Does this need a left or right turn to avoid the edge while it is in reverse?

User-inserted image

#12  

I think the IR is pretty good for this use.  It is sensitive and fast.

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

PRO
USA
#13  

I tried this

User-inserted image

works ok then stops, have to keep starting the robot

be back later for more, thanks

EzAng

#14  

Instead of the stop before the :loop, you will need to tell the script to return to what it was doing previously, whether that is a separate script or a control command, or just a forward()

Alan

PRO
USA
#15  

Hi, I made it back,

I will try what you said, thanks

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


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..




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

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

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

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.

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.

#35  

I have used those Sharp sensors too, and they do a pretty good job.

#36  

I've used the same Sharp sensors for years and have have had good results with them for edge and line detection.

PRO
USA
#37  

Hi JustinRatliff, nice to see you again,

what script do you use ior edge detection?

I have one but it may not be as good as you ,  thanks

PRO
USA
#38   — Edited

On my big robot I use 5 of this:

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:

User-inserted image

#39  

@PTP   I like how small those are.  The GP2Y0A21YK0F work fine if the drop-off you are worried about is high enough.  The step I am avoiding is well over 10cm, so I just watch for an increase from unmeasurably small to measurable, but for future builds I think I'll get the Pololu ones.

PRO
USA
#40   — Edited

This is why I use the Sharp GP2Y0A21YK0F GP2Y0A21 10~80cm Infrared Proximity Distance Sensor

not the Sharp Infrared Distance Sensor

PtP what script do you use for the sensors?

PRO
USA
#41   — Edited

I purchased some of the IR Infrared Obstacle Avoidance Sensor Modules 7.99  for 10 units

will test soon, hope they work

User-inserted image

PRO
Synthiam
#42  

I'm curious how those will work - without any rear reflector housing on the emitter or detector... will be interesting to see.

PRO
USA
#43   — Edited

This is just to avoid obstacles