Asked — Edited

Math Functions


I want to do some simple scripting in ARC . But i cant find the syntax for some mathematical functions:

-arcsin/arccos -power/square root

What is the code for those?


Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.


Just curious what you plan on doing with math functions in a robot?



Thats awesome! Thank you so much!

At the moment i am working on my own version of the radar. Ill have full control over when and where to measure distance. The robot will determine what kind of bends and manouvres it can make to avoid collision. And will do radar sweeps at specific angle ranges during these manouvres.

To calculate the desired steering wheel position these functions will come in handy.

United Kingdom

@Boon that sounds great. I hope you share the code once you have it written as it will come in very handy for the IR sensors I use that aren't supported by the built in IR radar function in ARC (plus it looks like it'll add a lot of extra functions/uses)


I will try to comment it to try and make it understandable. But it will be very specific to the dimensions and configuration of my wheels, steering and ping sensor setup. Also i cannot promise any time of completion. I am new to ez-robot and college has priority.

here's a snippet of the radar code:



radarspeed is just like the servo increment speed in DJ's Radar Scan

$radardirection = 1 $radarspeed = 4 $servomax = 85 $servomin = 15

d14 is the horizontal servo with the ping sensor on it



first wait for fresh ping data

sleep(100) $servopos = getservo(d14) $distance = getping(d12,d13)


alpha is the angle of looking with center position being 0

negative x is to the left of sensor, positive to the right

(servo is below the sensor in this case)

$alpha = (50-$servopos)$pi/($servomax-$servomin) $y = cos($alpha)$distance $y = round($y,2) $x = sin($alpha)*$distance $x = round($x,2)

i have a right and left led that light up but you could ignore this whole part

it does give an idea how to use our data.

################ $dim = 100 - $distance IF ($dim > 80) $dim = 80 ELSEIF ($dim < 0) $dim = 0 ENDIF

(the width of my robot is about '40', with the sensor in the middle so '20' to either side)

IF ($x > -20 and $x <= 0 and $distance < 255)

collision left

pwm(d4,$dim) pwm(d5,0) ELSEIF ($x >= 0 and $x < 20 and $distance <255)

collision right

pwm(d4,0) pwm(d5,$dim) ELSE pwm(d4,0) pwm(d5,0) ENDIF ##############

save data

FileWriteLine("C:...\newsweep.txt", "servo pos:$servopos:distance:$distance:x:$x:y:$y")

Move the servo

This could be adjusted to any desired behaviour

i'm thinking of 1 or 2 full sweeps left to right, next decide how to drive

and then sweep while driving, maybe look at interesting points more

IF ($radardirection = 1) IF (($servopos+$radarspeed)<$servomax) servoup(d14,$radarspeed) ELSE servo(d14,$servomax) $radardirection = 0 goto(sweep) ENDIF ELSE IF (($servopos-$radarspeed)>$servomin) servodown(d14,$radarspeed) ELSE servo(d14,$servomin) $radardirection = 1 ENDIF ENDIF goto(sweep)


i'm using the .txt file in other scripts but those are not in presentable shape yet and much more robot-specific and therefore less comprehendable too.

United Kingdom

Great, thanks.. I'll take a look at that later if I get chance and see how I can make it work with my set up.


How i output in distance for navigation using a sonar