Class CANdiSimState

java.lang.Object
com.ctre.phoenix6.sim.CANdiSimState

public class CANdiSimState extends Object
Class to control the state of a simulated CANdi.
  • Field Details

    • Pwm1Orientation

      The orientation of the PWM1 sensor relative to the robot chassis.

      This value should not be changed based on the CANdi PWM1 invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.

    • Pwm2Orientation

      The orientation of the PWM2 sensor relative to the robot chassis.

      This value should not be changed based on the CANdi PWM2 invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.

    • QuadratureOrientation

      The orientation of the Quadrature sensor relative to the robot chassis.

      This value should not be changed based on the CANdi Quadrature invert. Rather, this value should be changed when the mechanical linkage between the sensor and the robot changes.

    • QuadratureEdgesPerRotation

      The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the CANdi.
  • Constructor Details

    • CANdiSimState

      public CANdiSimState(CoreCANdi device)
      Creates an object to control the state of the given CANdi.

      Note the recommended method of accessing simulation features is to use CoreCANdi.getSimState()

      Parameters:
      device - Device to which this simulation state is attached
    • CANdiSimState

      public CANdiSimState(CoreCANdi device, ChassisReference pwm1Orientation, ChassisReference pwm2Orientation, ChassisReference quadratureOrientation)
      Creates an object to control the state of the given CANdi.

      Note the recommended method of accessing simulation features is to use CoreCANdi.getSimState()

      Parameters:
      device - Device to which this simulation state is attached
      pwm1Orientation - Orientation of the PWM1 sensor relative to the robot chassis
      pwm2Orientation - Orientation of the PWM2 sensor relative to the robot chassis
      quadratureOrientation - Orientation of the Quadrature sensor relative to the robot chassis
  • Method Details

    • setSupplyVoltage

      public StatusCode setSupplyVoltage(double volts)
      Sets the simulated supply voltage of the CANdi.

      The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.

      Parameters:
      volts - The supply voltage in Volts
      Returns:
      Status code
    • setSupplyVoltage

      Sets the simulated supply voltage of the CANdi.

      The minimum allowed supply voltage is 4 V - values below this will be promoted to 4 V.

      Parameters:
      voltage - The supply voltage
      Returns:
      Status code
    • setOutputCurrent

      public StatusCode setOutputCurrent(double amps)
      Sets the simulated output current of the CANdi.
      Parameters:
      amps - The output current in amps
      Returns:
      Status code
    • setOutputCurrent

      Sets the simulated output current of the CANdi.
      Parameters:
      current - The output current
      Returns:
      Status code
    • setPwm1RiseRise

      public StatusCode setPwm1RiseRise(double timeSeconds)
      Sets the simulated PWM1 Rise to Rise timing of the CANdi.
      Parameters:
      timeSeconds - The time between two Rise events in seconds
      Returns:
      Status code
    • setPwm1RiseRise

      Sets the simulated PWM1 Rise to Rise timing of the CANdi.
      Parameters:
      time - The time between two Rise events
      Returns:
      Status code
    • setPwm1RiseFall

      public StatusCode setPwm1RiseFall(double timeSeconds)
      Sets the simulated PWM1 Rise to Fall timing of the CANdi.
      Parameters:
      timeSeconds - The time between the Rise and Fall events in seconds
      Returns:
      Status code
    • setPwm1RiseFall

      Sets the simulated PWM1 Rise to Fall timing of the CANdi.
      Parameters:
      time - The time between the Rise and Fall events
      Returns:
      Status code
    • setPwm1Connected

      public StatusCode setPwm1Connected(boolean connected)
      Sets whether a PWM sensor is connected to the S1 pin.
      Parameters:
      connected - True if sensor is connected
      Returns:
      Status code
    • setPwm1Position

      public StatusCode setPwm1Position(double rotations)
      Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S1 pin.
      Parameters:
      rotations - The new position in rotations
      Returns:
      Status code
    • setPwm1Position

      public StatusCode setPwm1Position(Angle position)
      Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S1 pin.
      Parameters:
      position - The new position
      Returns:
      Status code
    • setPwm1Velocity

      public StatusCode setPwm1Velocity(double rps)
      Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S1 pin.
      Parameters:
      rps - The new velocity in rotations per second
      Returns:
      Status code
    • setPwm1Velocity

      Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S1 pin.
      Parameters:
      velocity - The new velocity
      Returns:
      Status code
    • setPwm2RiseRise

      public StatusCode setPwm2RiseRise(double timeSeconds)
      Sets the simulated PWM2 Rise to Rise timing of the CANdi.
      Parameters:
      timeSeconds - The time between two Rise events in seconds
      Returns:
      Status code
    • setPwm2RiseRise

      Sets the simulated PWM2 Rise to Rise timing of the CANdi.
      Parameters:
      time - The time between two Rise events
      Returns:
      Status code
    • setPwm2RiseFall

      public StatusCode setPwm2RiseFall(double timeSeconds)
      Sets the simulated PWM2 Rise to Fall timing of the CANdi.
      Parameters:
      timeSeconds - The time between the Rise and Fall events in seconds
      Returns:
      Status code
    • setPwm2RiseFall

      Sets the simulated PWM2 Rise to Fall timing of the CANdi.
      Parameters:
      time - The time between the Rise and Fall events
      Returns:
      Status code
    • setPwm2Connected

      public StatusCode setPwm2Connected(boolean connected)
      Sets whether a PWM sensor is connected to the S2 pin.
      Parameters:
      connected - True if sensor is connected
      Returns:
      Status code
    • setPwm2Position

      public StatusCode setPwm2Position(double rotations)
      Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S2 pin.
      Parameters:
      rotations - The new position in rotations
      Returns:
      Status code
    • setPwm2Position

      public StatusCode setPwm2Position(Angle position)
      Sets the simulated pulse width position of the CANdi. This is the position of an external PWM encoder connected to the S2 pin.
      Parameters:
      position - The new position
      Returns:
      Status code
    • setPwm2Velocity

      public StatusCode setPwm2Velocity(double rps)
      Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S2 pin.
      Parameters:
      rps - The new velocity in rotations per second
      Returns:
      Status code
    • setPwm2Velocity

      Sets the simulated pulse width velocity of the CANdi. This is the velocity of an external PWM encoder connected to the S2 pin.
      Parameters:
      velocity - The new velocity
      Returns:
      Status code
    • setRawQuadraturePosition

      public StatusCode setRawQuadraturePosition(double rotations)
      Sets the simulated raw quadrature position of the CANdi.

      Inputs to this function over time should be continuous, as user calls of CoreCANdi.setQuadraturePosition(double) will be accounted for in the callee.

      The CANdi integrates this to calculate the true reported quadrature position.

      When using the WPI Sim GUI, you will notice a readonly position and settable rawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes to rawPositionInput will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.

      Parameters:
      rotations - The raw position in rotations
      Returns:
      Status code
    • setRawQuadraturePosition

      Sets the simulated raw quadrature position of the CANdi.

      Inputs to this function over time should be continuous, as user calls of CoreCANdi.setQuadraturePosition(double) will be accounted for in the callee.

      The CANdi integrates this to calculate the true reported quadrature position.

      When using the WPI Sim GUI, you will notice a readonly position and settable rawPositionInput. The readonly signal is the emulated position which will match self-test in Tuner and the hardware API. Changes to rawPositionInput will be integrated into the emulated position. This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.

      Parameters:
      position - The raw position
      Returns:
      Status code
    • setQuadratureVelocity

      public StatusCode setQuadratureVelocity(double rps)
      Sets the simulated quadrature velocity of the CANdi.
      Parameters:
      rps - The new velocity in rotations per second
      Returns:
      Status code
    • setQuadratureVelocity

      Sets the simulated pulse width velocity of the CANdi.
      Parameters:
      velocity - The new velocity
      Returns:
      Status code
    • setS1State

      Sets the state of the S1 pin
      Parameters:
      state - The state to set the S1 pin to
      Returns:
      Status code
    • setS2State

      Sets the state of the S2 pin
      Parameters:
      state - The state to set the S2 pin to
      Returns:
      Status code