Class MindsensorsCompass
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.sensor.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
DescriptionThe 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
-
-
Field Summary
-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
-
-
Constructor Summary
Constructors Constructor Description MindsensorsCompass(I2CPort port)Create a compass sensor objectMindsensorsCompass(I2CPort port, int address)Create a compass sensor objectMindsensorsCompass(Port port)Create a compass sensor objectMindsensorsCompass(Port port, int address)Create a compass sensor object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SensorModegetAngleMode()MindSensors compass sensor, Angle mode
Measures the bearing of the sensor.SensorModegetCompassMode()Mindsensors compass sensor, Compass mode
Measures the bearing of the sensor.protected voidinit()voidstartCalibration()Starts calibration for the compass.voidstopCalibration()Ends calibration sequence.-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Constructor Detail
-
MindsensorsCompass
public MindsensorsCompass(I2CPort port, int address)
Create a compass sensor object- Parameters:
port- I2C port for the compassaddress- 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 compassaddress- 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:
startCalibrationin interfaceCalibrate
-
stopCalibration
public void stopCalibration()
Ends calibration sequence.- Specified by:
stopCalibrationin interfaceCalibrate
-
-