Australia
Asked — Edited

Getping

hi all I am writing my own radar script

how do i use the value return by getping(d13,d12) e.g. :loop tr if getping(d13,d12) < 20 then Right(200) goto(tr) else stop script and exit


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

United Kingdom
#1  

#baloo

Don't know if you can 'mix n match' the if and getping functions like that??

you need to test the value Getping returns with an if statement afterwards. Lots easier to use ping_wait

Australia
#2  

this what i have so far see code below i what to test to see if the distance is under 15", if so turn robot to the right or left, depending on where it is looking


Servo(d14, 100)

# start for radar loop
:radar_loop
goto(full_right)
goto (haft_right)
goto(Full_Forward)
goto (haft_left)
goto(full_left)
goto (haft_left)
goto(Full_Forward)
goto (haft_right)
goto(radar_loop)

#set the servo to look left
:full_left
Servo(d14, 10)
# turn to the right start here
#code go here to turn robot right ??
#end of turn right here
return()


:haft_left
Servo(d14, 25)
return()

:Full_Forward
Servo(d14, 50)

return()

:haft_right
Servo(d14, 75)
return()

:full_right
Servo(d14, 100)
return()

PRO
Synthiam
#3  

sounds like you want to use the radar control?

Australia
#4  

hi DJ my own radar ? so how do i use getping(d13,d12) in an if statment .. if possible

Australia
#5  

hi dj i am doing it this way just to learn about some of the script command you have showen on the help page

PRO
Synthiam
#6  

The most powerful commands for something like this are the WAIT commands. For example...


:Start

# Wait for ping sensor to return a value less than 15
Ping_Wait(d0, d1, lower, 15)

# If the head servo is greater than position 40, turn right
if (Servo(d5) > 40)
  Right()

# If the head servo is greater than position 40, turn left
if (Servo(d5) < 40)
  Left()

# Pause for 2 seconds while we move
Sleep(2000)

# Stop moving
Stop()

# Goto the start of the script
goto(Start)

And then you'll want to move the head back and forth... So create another script that does it...


# Set the servo speed on the head servo to a slow speed
ServoSpeed(D5, 4)

:Start

# Move servo head all way to the right
Servo(D5, 10)

# Pause for 7 seconds while head moves
Sleep(7000)

# Move servo head all way to the left
Servo(D5, 80)

# Pause for 7 seconds while head moves
Sleep(7000)

# Loop
goto(Start)

Australia
#7  

Hi DJ thanks for the help I broke your move script into 2 scripts I just need to fine tune the time, to get it all to run smooth:D

turn right


# Wait for ping sensor to return a value less than 15
Ping_Wait(d0, d1, lower, 15)
# If the head servo is greater than position 50, turn left
if (Servo(d5) > 50)
  Right()
# Pause for 2 seconds while we move
Sleep(2500)
forward()

Turn left


:start
# Wait for ping sensor to return a value less than 15
Ping_Wait(d13, d12, lower, 15)

# If the head servo is less than position 50, turn left
if (Servo(d14) < 50)
Left()

# Pause for 2 seconds while we move
Sleep(2500)

forward()

# Goto the start of the script
goto(Start)

and your scan to


Servo(d14, 80)
ServoSpeed(D14, 1)

:start
# Move servo head all way to the right
Servo(D14, 20)

# Pause for 7 seconds while head moves
Sleep(800)

# Move servo head all way to the left
Servo(D14, 80)

# Pause for 7 seconds while head moves
Sleep(800)

# Loop
goto(Start)

PRO
Synthiam
#8  

Nice:) It'll use a lot more processing to hav two scripts for movement. How come you separated them?