Class Pigeon2
- Direct Known Subclasses:
WPI_Pigeon2
// Example usage of a Pigeon 2
Pigeon2 pigeon = new Pigeon2(0); // creates a new Pigeon2 with ID 0
Pigeon2Configuration config = new Pigeon2Configuration();
// set mount pose as rolled 90 degrees counter-clockwise
config.MountPoseYaw = 0;
config.MountPosePitch = 0;
config.MountPoseRoll = 90;
pigeon.configAllSettings(config);
System.out.println(pigeon.getYaw()); // prints the yaw of the Pigeon
System.out.println(pigeon.getPitch()); // prints the pitch of the Pigeon
System.out.println(pigeon.getRoll()); // prints the roll of the Pigeon
double gravityVec[] = new double[3];
pigeon.getGravityVector(gravityVec); // gets the gravity vector of the Pigeon 2
ErrorCode error = pigeon.getLastError(); // gets the last error generated by the Pigeon
Pigeon2_Faults faults = new Pigeon2_Faults();
ErrorCode faultsError = pigeon.getFaults(faults); // fills faults with the current Pigeon 2 faults; returns the last error generated
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconfigAllSettings
(Pigeon2Configuration settings) Configures all persistent settings.configAllSettings
(Pigeon2Configuration settings, int timeoutMs) Configures all persistent settings.configDisableNoMotionCalibration
(boolean disable) Disables the no-motion calibration from Pigeon2configDisableNoMotionCalibration
(boolean disable, int timeoutMs) Disables the no-motion calibration from Pigeon2configDisableTemperatureCompensation
(boolean disable) Disables temperature compensation from Pigeon2.configDisableTemperatureCompensation
(boolean disable, int timeoutMs) Disables temperature compensation from Pigeon2.configEnableCompass
(boolean enable) Enables the magnetometer fusion for Pigeon2.configEnableCompass
(boolean enable, int timeoutMs) Enables the magnetometer fusion for Pigeon2.configMountPose
(double yaw, double pitch, double roll) Configure the mounting pose of the Pigeon2.configMountPose
(double yaw, double pitch, double roll, int timeoutMs) Configure the mounting pose of the Pigeon2.configMountPosePitch
(double pitch) Configure the mounting pose Pitch of the Pigeon2.configMountPosePitch
(double pitch, int timeoutMs) Configure the mounting pose Pitch of the Pigeon2.configMountPoseRoll
(double roll) Configure the mounting pose Roll of the Pigeon2.configMountPoseRoll
(double roll, int timeoutMs) Configure the mounting pose Roll of the Pigeon2.configMountPoseYaw
(double yaw) Configure the mounting pose Yaw of the Pigeon2.configMountPoseYaw
(double yaw, int timeoutMs) Configure the mounting pose Yaw of the Pigeon2.void
getAllConfigs
(Pigeon2Configuration allConfigs) Gets all persistant settings.void
getAllConfigs
(Pigeon2Configuration allConfigs, int timeoutMs) Gets all persistant settings.getFaults
(Pigeon2_Faults toFill) Gets the fault statusgetGravityVector
(double[] gravVector) Get the Gravity Vector.getStickyFaults
(Pigeon2_Faults toFill) Gets the sticky fault statusPerforms an offset calibration on gyro biaszeroGyroBiasNow
(int timeoutMs) Performs an offset calibration on gyro biasMethods inherited from class com.ctre.phoenix.sensors.BasePigeon
addYaw, addYaw, clearStickyFaults, clearStickyFaults, configAllSettings, configAllSettings, configFactoryDefault, configFactoryDefault, configGetCustomParam, configGetCustomParam, configGetParameter, configGetParameter, configGetParameter, configGetParameter, configSetCustomParam, configSetCustomParam, configSetParameter, configSetParameter, configSetParameter, configSetParameter, DestroyObject, get6dQuaternion, getAbsoluteCompassHeading, getAccumGyro, getAllConfigs, getAllConfigs, getBiasedAccelerometer, getBiasedMagnetometer, getCompassFieldStrength, getCompassHeading, getDeviceID, getFirmwareVersion, getHandle, getLastError, getPitch, getRawGyro, getRawMagnetometer, getResetCount, getResetFlags, getRoll, getSimCollection, getStatusFramePeriod, getStatusFramePeriod, getTemp, getUpTime, getYaw, getYawPitchRoll, hasResetOccurred, setAccumZAngle, setAccumZAngle, setControlFramePeriod, setControlFramePeriod, setStatusFramePeriod, setStatusFramePeriod, setStatusFramePeriod, setStatusFramePeriod, setYaw, setYaw, setYawToCompass, setYawToCompass
-
Constructor Details
-
Pigeon2
Create a Pigeon object that communicates with Pigeon on CAN Bus.- Parameters:
deviceNumber
- CAN Device Id of Pigeon [0,62]canbus
- Name of the CANbus; can be a SocketCAN interface (on Linux), or a CANivore device name or serial number
-
Pigeon2
Create a Pigeon object that communicates with Pigeon on CAN Bus.- Parameters:
deviceNumber
- CAN Device Id of Pigeon [0,62]
-
-
Method Details
-
configMountPose
Configure the mounting pose of the Pigeon2.This is the Yaw-Pitch-Roll the Pigeon2 underwent to get to its current orientation, referenced from the robot's point of view.
This is only necessary if the Pigeon2 is mounted at an exotic angle near the gimbal lock point or not forward.
If the pigeon is relatively flat and pointed forward, this is not needed.
Examples:
If the Pigeon2 is pointed directly right, that corresponds to a -90 yaw, 0 pitch, and 0 roll, as it yaw'd 90 degrees clockwise.
If the Pigeon2 points upwards, that's a 0 yaw, -90 pitch, 0 roll, as it pitched 90 degrees clockwise.
- Parameters:
yaw
- Yaw angle needed to reach the current orientation in degrees.pitch
- Pitch angle needed to reach the current orientation in degrees.roll
- Roll angle needed to reach the current orientation in degrees.timeoutMs
- Config timeout in milliseconds.- Returns:
- Worst error code of all config sets.
-
configMountPose
Configure the mounting pose of the Pigeon2.This is the Yaw-Pitch-Roll the Pigeon2 underwent to get to its current orientation, referenced from the robot's point of view.
This is only necessary if the Pigeon2 is mounted at an exotic angle near the gimbal lock point or not forward.
If the pigeon is relatively flat and pointed forward, this is not needed.
Examples:
If the Pigeon2 is pointed directly right, that corresponds to a -90 yaw, 0 pitch, and 0 roll, as it yaw'd 90 degrees clockwise.
If the Pigeon2 points upwards, that's a 0 yaw, -90 pitch, 0 roll, as it pitched 90 degrees clockwise.
- Parameters:
yaw
- Yaw angle needed to reach the current orientation in degrees.pitch
- Pitch angle needed to reach the current orientation in degrees.roll
- Roll angle needed to reach the current orientation in degrees.- Returns:
- Worst error code of all config sets.
-
configMountPoseYaw
Configure the mounting pose Yaw of the Pigeon2. SeeconfigMountPose(double, double, double, int)
- Parameters:
yaw
- Yaw angle needed to reach the current orientation in degrees.timeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode of configSet
-
configMountPoseYaw
Configure the mounting pose Yaw of the Pigeon2. SeeconfigMountPose(double, double, double)
- Parameters:
yaw
- Yaw angle needed to reach the current orientation in degrees.- Returns:
- ErrorCode of configSet
-
configMountPosePitch
Configure the mounting pose Pitch of the Pigeon2. SeeconfigMountPose(double, double, double, int)
- Parameters:
pitch
- Pitch angle needed to reach the current orientation in degrees.timeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode of configSet
-
configMountPosePitch
Configure the mounting pose Pitch of the Pigeon2. SeeconfigMountPose(double, double, double)
- Parameters:
pitch
- Pitch angle needed to reach the current orientation in degrees.- Returns:
- ErrorCode of configSet
-
configMountPoseRoll
Configure the mounting pose Roll of the Pigeon2. SeeconfigMountPose(double, double, double, int)
- Parameters:
roll
- Roll angle needed to reach the current orientation in degrees.timeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode of configSet
-
configMountPoseRoll
Configure the mounting pose Roll of the Pigeon2. SeeconfigMountPose(double, double, double)
- Parameters:
roll
- Roll angle needed to reach the current orientation in degrees.- Returns:
- ErrorCode of configSet
-
configEnableCompass
Enables the magnetometer fusion for Pigeon2. This is **not** recommended for FRC use- Parameters:
enable
- Boolean to enable/disable magnetometer fusiontimeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode Status of the config response
-
configEnableCompass
Enables the magnetometer fusion for Pigeon2. This is **not** recommended for FRC use- Parameters:
enable
- Boolean to enable/disable magnetometer fusion- Returns:
- ErrorCode Status of the config response
-
configDisableTemperatureCompensation
Disables temperature compensation from Pigeon2.- Parameters:
disable
- Boolean to disable/enable temperature compensationtimeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode Status of the config response
-
configDisableTemperatureCompensation
Disables temperature compensation from Pigeon2.- Parameters:
disable
- Boolean to disable/enable temperature compensation- Returns:
- ErrorCode Status of the config response
-
configDisableNoMotionCalibration
Disables the no-motion calibration from Pigeon2- Parameters:
disable
- Boolean to disable/enable no-motion calibrationtimeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode Status of the config response
-
configDisableNoMotionCalibration
Disables the no-motion calibration from Pigeon2- Parameters:
disable
- Boolean to disable/enable no-motion calibration- Returns:
- ErrorCode Status of the config response
-
zeroGyroBiasNow
Performs an offset calibration on gyro bias- Parameters:
timeoutMs
- Config timeout in milliseconds.- Returns:
- ErrorCode Status of the config response
-
zeroGyroBiasNow
Performs an offset calibration on gyro bias- Returns:
- ErrorCode Status of the config response
-
configAllSettings
Configures all persistent settings.- Parameters:
allConfigs
- Object with all of the persistant settingstimeoutMs
- Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.- Returns:
- Error Code generated by function. 0 indicates no error.
-
configAllSettings
Configures all persistent settings.- Parameters:
allConfigs
- Object with all of the persistant settings- Returns:
- Error Code generated by function. 0 indicates no error.
-
getGravityVector
Get the Gravity Vector. This provides a vector that points toward ground. This is useful for applications like an arm, where the z-value of the gravity vector corresponds to the feed-forward needed to hold the arm steady. The gravity vector is calculated after the mount pose, so if the pigeon is where it was mounted, the gravity vector is {0, 0, 1}.- Parameters:
gravVector
- Pass in a double array of size 3 to get the gravity vector- Returns:
- Errorcode of getter
-
getFaults
Gets the fault status- Parameters:
toFill
- Container for fault statuses.- Returns:
- Error Code generated by function. 0 indicates no error.
-
getStickyFaults
Gets the sticky fault status- Parameters:
toFill
- Container for sticky fault statuses.- Returns:
- Error Code generated by function. 0 indicates no error.
-
getAllConfigs
Gets all persistant settings.- Parameters:
allConfigs
- Object with all of the persistant settingstimeoutMs
- Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
-
getAllConfigs
Gets all persistant settings.- Parameters:
allConfigs
- Object with all of the persistant settings
-