Asked — Edited

I Have A Tiny Question.

I'm going to make my rc car robot autonomous.

theres just one problem... It's an rc car! it has custom turn and drive scripts!

does anyone have an idea or example on how to make a script for radar? one that I can modify to accomidate my custom movements?


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

United Kingdom
#1  

Radar should work with the custom movement panel.

Otherwise, check the EZ-Cloud, I've added a few files with ping object avoidance scripts.

#2  

I don't have a custom movement panel. I used the Movement Panel to set up the sabertooth. Now I have scripts and key control. I need a basic radar script that checks left, Checks right, and reverses and goes the open way.

United Kingdom
#3  

SendSerial will probably work then, which means you could set up a custom Movement Panel rather than the sabertooth movement panel. You would need to find the serial commands for the sabertooth though, then add the scripts in for the directions on the custom movement panel.

Custom radar style script can be found here which is discussed here. I'm currently working on a more advanced avoidance/detection for this script which checks for being boxed in, increased number of positions and basing movements on the sensor readings, speed control based on surroundings and a bunch of other stuff. It does and will continue to use the Movement Panel Forward, Left, Right, Reverse and Stop though so a custom Movement Panel will be required.

Or the Introduction To Scripting covers some Ping/IR sensor reactions.

#4  

heres my setup. RcSabertoothcarcontrols.EZB

experiment using the "Radar (custom)" script.

we both can try to create a radar script that could work with this setup.

the key controls are: w forward s reverse a left forward d right forward z left reverse x right reverse

#5  

how would you say "if the ping sensor value=(3 quarters of the full value), move servo full left. if value is below (3 quarters of the full value), start "left" script for 1500 milliseconds if value is above (3 quarters of full value) move servo full right. if value is below (3 quarters of full value), start "right" script for 1500 milliseconds if value is still above(3 quarters of full value), start "reverse" script for 1500 milliseconds then check again. turn towards lower value then start over

United Kingdom
#6  

Quote:

if the ping sensor value=(3 quarters of the full value)
Full is 255, so 3/4 is 191.25 (I'll skip the maths). So make it 191 since it needs to be an integer really.


IF(GetPing($trig,$echo) = 191)
  # Start script (fill in the blank with proper  ControlCommand params)
ENDIF

If it needs to be greater than or equal to then change the = for >=

Quote:

if value is below (3 quarters of the full value)


IF(GetPing($trig,$echo) < 191)
  # Start script (fill in the blank with proper  ControlCommand params)
ENDIF

You cannot ControlCommand to run a script for a time period, that would need to be part of the script itself.

Use a label (i.e. :loop) and a goto to loop around. Add in a Sleep to avoid saturating the communications and bogging down ARC. Sleep(50) or Sleep(100) is usually all that's needed.

To turn towards the lower value you would need to use an if...


IF($value1 < $value2)
  # Turn towards value 1
Else
  # Turn towards value 2
ENDIF

#8  

oh and I was playing with your ping avoidance script and changed a couple things. i'll post the code so you can proof read.

# Ping Object Avoidance
# Using Ultra Sonic Ping Sensor on servo for avoidance

# Adjust values below for configuration
$pingport = D0 # Change for Ping Port
$echoport = D1 # Change for Echo Port
$maxdistance = 35 # Change for maximum distance from object before avoiding in units
$onlyforward = 0 # Only if moving forwards? 0 = no, 1 = yes
$reverseturn = 0 # Reverse before turn? 0 = no, 1 = yes
# centreturndirection removed
$turnamount = 500 # Change for how long to turn for in ms
$reverseamount = 500 # Change for how long to reverse for in ms (if applicable)
$movementspeed = 255 # Change for movement speed

# Sweep variables
$sweepmin = 25 # Change for min limit
$sweepmax = 77 # Change for max limit
$sweepcenter = 52 # Change for center position
$sweepservo = "D3" # Change for servo port
$sweepprevious = 1000 # Do not change

# -- The Script --

GOTO(sweep)

# Check if only to detect when moving forwards
:detect
IF ($onlyforward = 1)
  IF ($Direction = "Forward")
    GOTO (detectstart)
  ELSE 
    GOTO (detect)
  ENDIF 
ELSE 
  :detectstart
  $currentdistance = GetPing($pingport, $echoport)
  IF ($currentdistance <= $maxdistance)
    GOTO(avoid)
  ENDIF 
    
    # Sweep the servo to the next position
  GOTO(sweep)
  
  SLEEP (50)
  GOTO(detect)
ENDIF 
  
  # The avoidance script
:avoid
controlcommand("reverse",scriptstart)
IF ($sweepcurrent = $sweepmin)
  controlcommand("Right", scriptstart)
ELSEIF ($sweepcurrent = $sweepmax)
  controlcommand("left",scriptstart)
  Sleep(1500)
  
ELSE 
  Servo($sweepservo,$sweepmin)
  $pingmin = GetPing($pingport, $echoport)
  Servo($sweepservo,$sweepmax)
  $pingmax = GetPing($pingport, $echoport)
  Servo($sweepservo,$sweepcenter)
  IF ($pingmin > $pingmax)
    controlcommand("Right", scriptstart)
  ELSE 
    controlcommand("Left", scriptstart)
  ENDIF 
ENDIF 
RETURN()

# The sweep script
:sweep
# Check for previous position, if no position assume to be $sweepmax
IF ($sweepprevious = 1000)
  $sweepprevious = $sweepmax
ENDIF 
  
  # Get the current position
$sweepcurrent = GetServo($sweepservo)

# Move in the correct direction and store previous position
IF ($sweepcurrent = $sweepmin)
  $sweepprevious = $sweepcurrent
  Servo($sweepservo, $sweepcenter)
ELSEIF ($sweepcurrent = $sweepcenter and $sweepprevious = $sweepmin)
  $sweepprevious = $sweepcurrent
  Servo($sweepservo, $sweepmax)
ELSEIF ($sweepcurrent = $sweepcenter and $sweepprevious = $sweepmax)
  $sweepprevious = $sweepcurrent
  Servo($sweepservo, $sweepmin)
ELSE 
  $sweepprevious = $sweepcurrent
  Servo($sweepservo, $sweepcenter)
ENDIF 
  
  # Return back to the main script
Return()