Class HiTechnicCompass

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, SensorConstants, SensorMode, SensorModes, Calibrate, SampleProvider

    public class HiTechnicCompass
    extends I2CSensor
    implements Calibrate
    HiTechnic compass sensor Sensor name
    The HiTechnic compass measures the earth's magnetic field and calculates a heading angle.

    The code for this sensor has not been tested. Please report test results to the leJOS forum.

    Supported modes
    Mode name Description unit(s) Getter
    Compass Measures the orientation of the sensor Degrees, corresponding to the compass rose getCompassMode()
    Angle Measures the orientation of the sensor Degrees, corresponding to the right hand coordinate system getAngleMode()

    Sensor configuration
    The sensor can be calibrated for magnetic disturbances coming from the robot (soft iron calibration). Use the startCalibration method to put the sensor in calibration mode. While in calibration mode the sensor should be rotated slowly for making at least 1.5 full rotations. Then end calibration with the endCalibration method.

    See Sensor Product page See The leJOS sensor framework See leJOS conventions for SampleProviders

    Author:
    Your name
    • Constructor Detail

      • HiTechnicCompass

        public HiTechnicCompass​(I2CPort port,
                                int address)
        Create a compass sensor object
        Parameters:
        port - I2C port for the compass
        address - The I2C address used by the sensor
      • HiTechnicCompass

        public HiTechnicCompass​(I2CPort port)
        Create a compass sensor object
        Parameters:
        port - I2C port for the compass
      • HiTechnicCompass

        public HiTechnicCompass​(Port port,
                                int address)
        Create a compass sensor object
        Parameters:
        port - Sensor port for the compass
        address - The I2C address used by the sensor
      • HiTechnicCompass

        public HiTechnicCompass​(Port port)
        Create a compass sensor object
        Parameters:
        port - Sensor port for the compass
    • Method Detail

      • init

        protected void init()
      • getCompassMode

        public SensorMode getCompassMode()
        HiTechnic compass sensor, Compass mode
        Measures the bearing of the sensor.

        Size and content of the sample
        The sample contains one element containing the bearing of the sensor relative to north expressed in degrees. East being at 90 degrees.

      • getAngleMode

        public SensorMode getAngleMode()
        HiTechnic compass sensor, Angle mode
        Measures the color of a surface.

        Size and content of the sample
        The sample contains one element containing the bearing of the sensor relative to north expressed in degrees using a right hand coordinate system in the range of (-180 to 180). West being at 90 degrees, east being at -90 degrees.

      • startCalibration

        public void startCalibration()
        Starts calibration for the compass. Must rotate *very* slowly, taking at least 20 seconds per rotation. Should make 1.5 to 2 full rotations. Must call stopCalibration() when done.
        Specified by:
        startCalibration in interface Calibrate
      • stopCalibration

        public void stopCalibration()
        Ends calibration sequence.
        Specified by:
        stopCalibration in interface Calibrate