Class MindsensorsAbsoluteIMU
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.sensor.MindsensorsAbsoluteIMU
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,Calibrate,SampleProvider
public class MindsensorsAbsoluteIMU extends I2CSensor implements SensorModes, Calibrate
Mindsensors AbsoluteIMU
Sensor interface for the Mindsensors AbsoluteIMU family of sensors. The AbsoluteIMU sensors combine gyro, accelerometer and compass sensors in various combinations in a single housing. This interface works with all AbsoluteIMU models, but not all modes will work with any particular model.Supported modes Mode name Description unit(s) Getter Magnetic Measures the strength of the magnetic field over three axes getMagneticMode()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()Acceleration The Acceleration mode measures the linear acceleration of the sensor over three axes Metres/second^2 getAccelerationMode()Rate The Rate mode measures the angular speed of the sensor over three axes Degrees/second getRateMode()Sensor configuration
The gyro sensor of the AbsoluteIMU uses a filter to remove noise from the samples. The filter can be configured using thesetGyroFilter(int)method.
The compass sensor of the AbsoluteIMU can be calibrated to compensate for magnetical disturbances on the robot (soft iron calibration) using thestartCalibration()andstopCalibration()methods.To calibrate Compass, mount it on your robot where it will be used and issue startCalibration method and then rotate AbsoluteIMU slowly along all three axes. (The Compass in AbsoluteIMU is a 3 axis compass, and hence needs to be turned along all three axes, and if it's mounted on your robot, the whole robot needs to rotate). Rotate one axis at a time, turn once in clock-wise direction completing at-least 360 degrees, and then turn it in anti-clock-wise direction, then go to next axis. Upon finishing turning along all axes, issue stopCalibration method.
See Mindsensors IMU user guide"> Sensor Product page See The leJOS sensor framework See
leJOS conventions for SampleProviders- Author:
- Andy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMindsensorsAbsoluteIMU.ShortSensorMode
-
Field Summary
Fields Modifier and Type Field Description protected static intACCEL_DATAprotected MindsensorsAbsoluteIMU.ShortSensorModeaccelModeprotected MindsensorsAbsoluteIMU.ShortSensorModeangleModeprotected static intCOMMANDprotected static intCOMPASS_DATAprotected MindsensorsAbsoluteIMU.ShortSensorModecompassModestatic intDEFAULT_I2C_ADDRESSThe default I2C address of the sensorprotected static byteEND_CALIBRATIONprotected static intGYRO_DATAprotected static intGYRO_FILTERprotected MindsensorsAbsoluteIMU.ShortSensorModegyroModestatic intHIGHstatic intLOWprotected static intMAG_DATAprotected MindsensorsAbsoluteIMU.ShortSensorModemagModestatic intMEDIUMprotected static byteSENSITIVITY_BASEprotected static byteSTART_CALIBRATIONstatic intVERY_HIGH-
Fields inherited from class lejos.hardware.sensor.I2CSensor
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 MindsensorsAbsoluteIMU(I2CPort port)MindsensorsAbsoluteIMU(I2CPort port, int address)MindsensorsAbsoluteIMU(Port port)MindsensorsAbsoluteIMU(Port port, int address)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SensorModegetAccelerationMode()Return a SensorMode object that will acceleration data for the X, Y and Z axis.SensorModegetAngleMode()Return a SensorMode object that will provide angle data.SensorModegetCompassMode()Return a SensorMode object that will provide tilt compensated compass data .SensorModegetMagneticMode()Return a SensorMode object that will return Magnetic data for the X, Y and Z axis The data is returned in GuassSensorModegetRateMode()Return a SensorMode object that will angular velocity data for the X, Y and Z axis.protected voidinit()voidsetGyroFilter(int value)Set the smoothing filter for the gyro.voidsetRange(int range)Set the sensitivity used by the sensor.voidstartCalibration()To calibrate Compass, mount it on your robot where it will be used and issue startCalibration method and then rotate AbsoluteIMU slowly along all three axes.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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface lejos.robotics.SampleProvider
fetchSample, sampleSize
-
Methods inherited from interface lejos.hardware.sensor.SensorMode
getName
-
Methods inherited from interface lejos.hardware.sensor.SensorModes
getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, setCurrentMode, setCurrentMode
-
-
-
-
Field Detail
-
DEFAULT_I2C_ADDRESS
public static final int DEFAULT_I2C_ADDRESS
The default I2C address of the sensor- See Also:
- Constant Field Values
-
ACCEL_DATA
protected static final int ACCEL_DATA
- See Also:
- Constant Field Values
-
COMPASS_DATA
protected static final int COMPASS_DATA
- See Also:
- Constant Field Values
-
MAG_DATA
protected static final int MAG_DATA
- See Also:
- Constant Field Values
-
GYRO_DATA
protected static final int GYRO_DATA
- See Also:
- Constant Field Values
-
COMMAND
protected static final int COMMAND
- See Also:
- Constant Field Values
-
GYRO_FILTER
protected static final int GYRO_FILTER
- See Also:
- Constant Field Values
-
SENSITIVITY_BASE
protected static final byte SENSITIVITY_BASE
- See Also:
- Constant Field Values
-
START_CALIBRATION
protected static final byte START_CALIBRATION
- See Also:
- Constant Field Values
-
END_CALIBRATION
protected static final byte END_CALIBRATION
- See Also:
- Constant Field Values
-
LOW
public static final int LOW
- See Also:
- Constant Field Values
-
MEDIUM
public static final int MEDIUM
- See Also:
- Constant Field Values
-
HIGH
public static final int HIGH
- See Also:
- Constant Field Values
-
VERY_HIGH
public static final int VERY_HIGH
- See Also:
- Constant Field Values
-
accelMode
protected MindsensorsAbsoluteIMU.ShortSensorMode accelMode
-
magMode
protected MindsensorsAbsoluteIMU.ShortSensorMode magMode
-
gyroMode
protected MindsensorsAbsoluteIMU.ShortSensorMode gyroMode
-
compassMode
protected MindsensorsAbsoluteIMU.ShortSensorMode compassMode
-
angleMode
protected MindsensorsAbsoluteIMU.ShortSensorMode angleMode
-
-
Constructor Detail
-
MindsensorsAbsoluteIMU
public MindsensorsAbsoluteIMU(I2CPort port, int address)
-
MindsensorsAbsoluteIMU
public MindsensorsAbsoluteIMU(I2CPort port)
-
MindsensorsAbsoluteIMU
public MindsensorsAbsoluteIMU(Port port, int address)
-
MindsensorsAbsoluteIMU
public MindsensorsAbsoluteIMU(Port port)
-
-
Method Detail
-
init
protected void init()
-
getCompassMode
public SensorMode getCompassMode()
Return a SensorMode object that will provide tilt compensated compass data . The sample contains one element containing the bearing of the sensor relative to north expressed in degrees. East being at 90 degrees.- Returns:
- a SensorMode object
-
getAngleMode
public SensorMode getAngleMode()
Return a SensorMode object that will provide angle data. 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.- Returns:
- a SensorMode object
-
getAccelerationMode
public SensorMode getAccelerationMode()
Return a SensorMode object that will acceleration data for the X, Y and Z axis. The data is returned in units of m/s/s.- Returns:
- a SensorMode object
-
getMagneticMode
public SensorMode getMagneticMode()
Return a SensorMode object that will return Magnetic data for the X, Y and Z axis The data is returned in Guass- Returns:
- a SensorMode object
-
getRateMode
public SensorMode getRateMode()
Return a SensorMode object that will angular velocity data for the X, Y and Z axis. The data is returned in units of degrees/s.- Returns:
- a SensorMode object
-
setRange
public void setRange(int range)
Set the sensitivity used by the sensor. This setting impacts the maximum range of the returned value and the resolution of the reading.
LOW Acceleration 2G Gyro 250 degrees/second
MEDIUM Acceleration 4G Gyro 500 degrees/second
HIGH Acceleration 8G Gyro 2000 degrees/second
VERY_HIGH Acceleration 16G Gyro 2000 degrees/second
The default setting is LOW.- Parameters:
range- the selected range (LOW/MEDIUM/HIGH/VERY_HIGH)
-
setGyroFilter
public void setGyroFilter(int value)
Set the smoothing filter for the gyro.
The Gyro readings are filtered with n???th order finite impulse response filter, (where n ranges from 0 to 7) value 0 will apply no filter, resulting in faster reading, but noisier values.value 7 will apply stronger filter resulting in slower read (about 10 milli-seconds slower) but less noise.
The default value for the filter is 4.- Parameters:
value- (range 0-7)
-
startCalibration
public void startCalibration()
To calibrate Compass, mount it on your robot where it will be used and issue startCalibration method and then rotate AbsoluteIMU slowly along all three axes. (The Compass in AbsoluteIMU is a 3 axis compass, and hence needs to be turned along all three axes, and if it's mounted on your robot, the whole robot needs to rotate). Rotate one axis at a time, turn once in clock-wise direction completing at-least 360 degrees, and then turn it in anti-clock-wise direction, then go to next axis. Upon finishing turning along all axes, issue stopCalibration method.- Specified by:
startCalibrationin interfaceCalibrate
-
stopCalibration
public void stopCalibration()
Ends calibration sequence.- Specified by:
stopCalibrationin interfaceCalibrate
-
-