Package ftclib.sensor
Class FtcImu
- All Implemented Interfaces:
TrcOdometrySensor
This class implements the REV Control/Expansion Hub IMU which is either BNO055 or BHI260. It extends TrcGyro so
it implements the standard gyro interface.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class trclib.sensor.TrcGyro
TrcGyro.DataType
Nested classes/interfaces inherited from class trclib.sensor.TrcSensor
TrcSensor.DataSource<D>, TrcSensor.SensorData<T>
Nested classes/interfaces inherited from interface trclib.sensor.TrcOdometrySensor
TrcOdometrySensor.Odometry
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FtcImu.GyroData
private final TrcTaskMgr.TaskObject
final com.qualcomm.robotcore.hardware.IMU
private boolean
Fields inherited from class trclib.sensor.TrcGyro
GYRO_HAS_X_AXIS, GYRO_HAS_Y_AXIS, GYRO_HAS_Z_AXIS, GYRO_INTEGRATE
Fields inherited from class trclib.sensor.TrcSensor
instanceName, tracer
-
Constructor Summary
ConstructorsConstructorDescriptionFtcImu
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, double xRotation, double yRotation, double zRotation) Constructor: Creates an instance of the object.FtcImu
(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logoDirection, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usbDirection) Constructor: Creates an instance of the object.Constructor: Creates an instance of the object.FtcImu
(String instanceName, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logoDirection, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usbDirection) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetRawXData
(TrcGyro.DataType dataType) This method returns the raw data of the specified type for the x-axis.getRawYData
(TrcGyro.DataType dataType) This method returns the raw data of the specified type for the y-axis.getRawZData
(TrcGyro.DataType dataType) This method returns the raw data of the specified type for the z-axis.private void
gyroTask
(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method is called periodically to read the gyro data.boolean
This method returns the state of the gyro task.void
This method overrides the TrcGyro class and calls its own.void
setEnabled
(boolean enabled) This method enables/disables the gyro task that reads and caches the gyro data periodically.Methods inherited from class trclib.sensor.TrcGyro
getName, getOdometry, getRawData, getXHeading, getXRotationRate, getYHeading, getYRotationRate, getZHeading, getZRotationRate, printElapsedTime, resetOdometry, resetXIntegrator, resetXWrapValueConverter, resetYIntegrator, resetYWrapValueConverter, resetZWrapValueConverter, setElapsedTimerEnabled, setXInverted, setXScale, setXValueRange, setYInverted, setYScale, setYValueRange, setZInverted, setZScale, setZValueRange, toString
Methods inherited from class trclib.sensor.TrcSensor
calibrate, calibrate, getNumAxes, getProcessedData, isCalibrating, setInverted, setScale, setScaleAndOffset
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface trclib.sensor.TrcOdometrySensor
getOdometries, getOdometry
-
Field Details
-
gyroData
-
imu
public final com.qualcomm.robotcore.hardware.IMU imu -
gyroTaskObj
-
taskEnabled
private boolean taskEnabled
-
-
Constructor Details
-
FtcImu
public FtcImu(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logoDirection, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usbDirection) Constructor: Creates an instance of the object.- Parameters:
hardwareMap
- specifies the global hardware map.instanceName
- specifies the instance name.logoDirection
- specifies the orientation of the printed logo on the REV Control/Expansion Hub.usbDirection
- specifies the orientation of the USB port on the REV Control/Expansion Hub.
-
FtcImu
public FtcImu(String instanceName, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logoDirection, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usbDirection) Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.logoDirection
- specifies the orientation of the printed logo on the REV Control/Expansion Hub.usbDirection
- specifies the orientation of the USB port on the REV Control/Expansion Hub.
-
FtcImu
public FtcImu(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, double xRotation, double yRotation, double zRotation) Constructor: Creates an instance of the object.- Parameters:
hardwareMap
- specifies the global hardware map.instanceName
- specifies the instance name.xRotation
- specifies the X axis rotation of the REV hub.yRotation
- specifies the Y axis rotation of the REV hub.zRotation
- specifies the Z axis rotation of the REV hub.
-
FtcImu
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.xRotation
- specifies the X axis rotation of the REV hub.yRotation
- specifies the Y axis rotation of the REV hub.zRotation
- specifies the Z axis rotation of the REV hub.
-
-
Method Details
-
setEnabled
public void setEnabled(boolean enabled) This method enables/disables the gyro task that reads and caches the gyro data periodically.- Overrides:
setEnabled
in classTrcGyro
- Parameters:
enabled
- specifies true for enabling the gyro task, disabling it otherwise.
-
isEnabled
public boolean isEnabled()This method returns the state of the gyro task.- Returns:
- true if gyro task is enabled, false otherwise.
-
resetZIntegrator
public void resetZIntegrator()This method overrides the TrcGyro class and calls its own.- Overrides:
resetZIntegrator
in classTrcGyro
-
getRawXData
This method returns the raw data of the specified type for the x-axis.- Specified by:
getRawXData
in classTrcGyro
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the x-axis.
-
getRawYData
This method returns the raw data of the specified type for the y-axis.- Specified by:
getRawYData
in classTrcGyro
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the y-axis.
-
getRawZData
This method returns the raw data of the specified type for the z-axis.- Specified by:
getRawZData
in classTrcGyro
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the z-axis.
-
gyroTask
private void gyroTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method is called periodically to read the gyro data.- Parameters:
taskType
- specifies the type of task being run.runMode
- specifies the competition mode that is running.slowPeriodicLoop
- specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.
-