Class MindsensorsCompass

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

    public class MindsensorsCompass
    extends I2CSensor
    implements Calibrate
    MindSensor Compass sensor
    Description

    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 2 full rotations taking at least 20 seconds per turn. Then end calibration with the endCalibration method.

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

    Author:
    Lawrie Griffiths
    • Constructor Detail

      • MindsensorsCompass

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

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

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

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

      • init

        protected void init()
      • getCompassMode

        public SensorMode getCompassMode()
        Mindsensors 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()
        MindSensors compass sensor, Angle 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 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