Bots-hitechnic-compass

From Earlham Cluster Department

Jump to: navigation, search

Back to Robotics Main Page


Contents

HiTechnic compass

Copy the hicompass library into the directory of the rest of your NXT libraries


Functions

Expect more functions in the near future

Examples

Plug your compass into port four and place the following code somewhere in a program that already works with your robot

import nxt.hicompass
bot = (whatever variable you use to refer to your bot)
compass = hicompass.CompassSensor(bot,PORT_4)
print compass.get_manufacturer()
heading = compass.get_sample()
while heading > 10:
        heading = compass.get_sample()
        print 'Heading: ', heading

This will tell the sensor to collect headings until it is within ten degrees East of due North.

Calibrating the Compass

  1. Assemble a mobile robot that can drive in a circle
    • The size and precision of the circle is unimportant as long as the robot can make a full revolution
  2. Set your compass sensor to calibrate mode and instruct your robot to drive in a circle
    • Your program should tell the robot to make between one and a half and two revolutions in about twenty seconds and stop
  3. Be sure to set your compass sensor back to measure mode when you are done!

Notes

The compass sensor is a very sensitive device. Here are some tips to make sure you get accurate readings

Personal tools
Namespaces
Variants
Actions
websites
wiki
this semester
Toolbox