## Math Functions

hi,

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?

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

#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")

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

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

servo(d14,50)

:sweep

# first wait for fresh ping data

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

# (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)

# 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")

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

Netherlands
#7

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
#8

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.

#9

How i output in distance for navigation using a sonar