Class Pigeon2

java.lang.Object
com.ctre.phoenix.sensors.BasePigeon
com.ctre.phoenix.sensors.Pigeon2
Direct Known Subclasses:
WPI_Pigeon2

public class Pigeon2 extends BasePigeon
Pigeon 2 Class. Class supports communicating over CANbus.
 
 // 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 Details

    • Pigeon2

      public Pigeon2(int deviceNumber, String canbus)
      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

      public Pigeon2(int deviceNumber)
      Create a Pigeon object that communicates with Pigeon on CAN Bus.
      Parameters:
      deviceNumber - CAN Device Id of Pigeon [0,62]
  • Method Details

    • configMountPose

      public ErrorCode configMountPose(double yaw, double pitch, double roll, int timeoutMs)
      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

      public ErrorCode configMountPose(double yaw, double pitch, double roll)
      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

      public ErrorCode configMountPoseYaw(double yaw, int timeoutMs)
      Configure the mounting pose Yaw of the Pigeon2. See configMountPose(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

      public ErrorCode configMountPoseYaw(double yaw)
      Configure the mounting pose Yaw of the Pigeon2. See configMountPose(double, double, double)
      Parameters:
      yaw - Yaw angle needed to reach the current orientation in degrees.
      Returns:
      ErrorCode of configSet
    • configMountPosePitch

      public ErrorCode configMountPosePitch(double pitch, int timeoutMs)
      Configure the mounting pose Pitch of the Pigeon2. See configMountPose(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

      public ErrorCode configMountPosePitch(double pitch)
      Configure the mounting pose Pitch of the Pigeon2. See configMountPose(double, double, double)
      Parameters:
      pitch - Pitch angle needed to reach the current orientation in degrees.
      Returns:
      ErrorCode of configSet
    • configMountPoseRoll

      public ErrorCode configMountPoseRoll(double roll, int timeoutMs)
      Configure the mounting pose Roll of the Pigeon2. See configMountPose(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

      public ErrorCode configMountPoseRoll(double roll)
      Configure the mounting pose Roll of the Pigeon2. See configMountPose(double, double, double)
      Parameters:
      roll - Roll angle needed to reach the current orientation in degrees.
      Returns:
      ErrorCode of configSet
    • configEnableCompass

      public ErrorCode configEnableCompass(boolean enable, int timeoutMs)
      Enables the magnetometer fusion for Pigeon2. This is **not** recommended for FRC use
      Parameters:
      enable - Boolean to enable/disable magnetometer fusion
      timeoutMs - Config timeout in milliseconds.
      Returns:
      ErrorCode Status of the config response
    • configEnableCompass

      public ErrorCode configEnableCompass(boolean enable)
      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

      public ErrorCode configDisableTemperatureCompensation(boolean disable, int timeoutMs)
      Disables temperature compensation from Pigeon2.
      Parameters:
      disable - Boolean to disable/enable temperature compensation
      timeoutMs - 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

      public ErrorCode configDisableNoMotionCalibration(boolean disable, int timeoutMs)
      Disables the no-motion calibration from Pigeon2
      Parameters:
      disable - Boolean to disable/enable no-motion calibration
      timeoutMs - Config timeout in milliseconds.
      Returns:
      ErrorCode Status of the config response
    • configDisableNoMotionCalibration

      public ErrorCode configDisableNoMotionCalibration(boolean disable)
      Disables the no-motion calibration from Pigeon2
      Parameters:
      disable - Boolean to disable/enable no-motion calibration
      Returns:
      ErrorCode Status of the config response
    • zeroGyroBiasNow

      public ErrorCode zeroGyroBiasNow(int timeoutMs)
      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

      public ErrorCode configAllSettings(Pigeon2Configuration settings, int timeoutMs)
      Configures all persistent settings.
      Parameters:
      allConfigs - Object with all of the persistant settings
      timeoutMs - 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

      public ErrorCode getGravityVector(double[] gravVector)
      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

      public void getAllConfigs(Pigeon2Configuration allConfigs, int timeoutMs)
      Gets all persistant settings.
      Parameters:
      allConfigs - Object with all of the persistant settings
      timeoutMs - 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

      public void getAllConfigs(Pigeon2Configuration allConfigs)
      Gets all persistant settings.
      Parameters:
      allConfigs - Object with all of the persistant settings