Compass Rover

This robot uses the new compass sensor. You should build a slow motion robot like the Mars-Rover, which gears the motors down using the worm screw. The Roverbot equipped with chains will do the job. It is important that the robot you build is able to stear very slowly. The main reason is that the PEWATRON-sensor needs 2,5 seconds to recover the exact values if the sensors is turned 90 degrees. The second reason is the important calculations the RCX has to compute in order to determine the angle by executing the program described at CompassSensor2.htm. As you probably found out, the angle is returned in variable 28 which is called alpha.

As shown in the pictures, there appears a field distortion if the sensor is mounted on the RCX. The proximity to the electric, magnetic and metallic objects inside of the RCX, even if ordinary insignificant, changes the respons of the sensor.

So there has to be operated some deviation-correction by software means. Using the least-squares polynomial method, we get a deviation-function for x from 0 to 180:

f(x) = -3.321 + 0.60336 x - 0.00323 x2

The RCX beeing unable to operate with floating-point numbers, we use a simplified function:

g(x) = (6 x - (x2 / 3 + 5) / 10 + 5) / 10

The source-code to placed just before the setvar(alpha,var,phi) command looks like:

 

if(var,phi,GT,con,180)

setvar(p,con,360)

subvar(p,var,phi)

else()

setvar(p,var,phi)

endif()

setvar(q,var,p)

mulvar(q,con,6)

mulvar(p,var,p)

divvar(p,con,3)

sumvar(p,con,5)

divvar(p,con,-10)

sumvar(p,con,5)

sumvar(p,var,q)

divvar(p,con,10)

if(var,phi,gt,con,180)

subvar(phi,var,p)

else()

sumvar(phi,var,p)

endif()

if(var,phi,GT,con,360)

setvar(phi,con,360)

endif()

if(var,phi,LT,con,0)

setvar(phi,con,0)

endif()

{alpha returns the actual direction}

setvar(alpha,var,phi)


Here the complete source code: CompassRover.zip

Notes:


Main Page