#### Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

## Math Functions

hi,

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

-arcsin/arccos
-power/square root

What is the code for those?

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#2
Just curious what you plan on doing with math functions in a robot?

Alan
Netherlands
#3
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
#5
@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)
Netherlands
#6
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:

FileDelete("C:\...\newsweep.txt")

# Variables
# radarspeed is just like the servo increment speed in DJ's Radar Scan
\$servomax = 85
\$servomin = 15

# d14 is the horizontal servo with the ping sensor on it
servo(d14,50)

:sweep

# first wait for fresh ping data
sleep(100)
\$servopos = getservo(d14)
\$distance = getping(d12,d13)

# calculate
# 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
ELSE
servo(d14,\$servomax)
goto(sweep)
ENDIF
ELSE
ELSE
servo(d14,\$servomin)