Class DifferentialMotorConstants<MotorConfigsT extends ParentConfiguration>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSensor sources for a differential CTR Electronics' CANdi⢠branded device.static enumSensor sources for a differential Pigeon 2. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe alignment of the differential leader and follower motors, ignoring the configured inverts.Name of the CAN bus the mechanism is on.doubleThe update rate of the closed-loop controllers.intCAN ID of the follower motor in the differential mechanism.The initial configs used to configure the differential follower.booleanWhether the follower should overwrite some of its initial configs with common configs from theLeaderInitialConfigs, such as current limits.intCAN ID of the leader motor in the differential mechanism.The initial configs used to configure the differential leader.doubleThe ratio of sensor rotations to the differential mechanism's difference output, where a ratio greater than 1 is a reduction. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionwithAlignment(MotorAlignmentValue newAlignment) Modifies the Alignment parameter and returns itself.withCANBusName(String newCANBusName) Modifies the CANBusName parameter and returns itself.withClosedLoopRate(double newClosedLoopRate) Modifies the ClosedLoopRate parameter and returns itself.withClosedLoopRate(Frequency newClosedLoopRate) Modifies the ClosedLoopRate parameter and returns itself.withFollowerId(int newFollowerId) Modifies the FollowerId parameter and returns itself.withFollowerInitialConfigs(MotorConfigsT newFollowerInitialConfigs) Modifies the FollowerInitialConfigs parameter and returns itself.withFollowerUsesCommonLeaderConfigs(boolean newFollowerUsesCommonLeaderConfigs) Modifies the FollowerUsesCommonLeaderConfigs parameter and returns itself.withLeaderId(int newLeaderId) Modifies the LeaderId parameter and returns itself.withLeaderInitialConfigs(MotorConfigsT newLeaderInitialConfigs) Modifies the LeaderInitialConfigs parameter and returns itself.withSensorToDifferentialRatio(double newSensorToDifferentialRatio) Modifies the SensorToDifferentialRatio parameter and returns itself.
-
Field Details
-
CANBusName
Name of the CAN bus the mechanism is on. Possible CAN bus strings are:- "rio" for the native roboRIO CAN bus
- CANivore name or serial number
- SocketCAN interface (non-FRC Linux only)
- "*" for any CANivore seen by the program
- empty string (default) to select the default for the system:
- "rio" on roboRIO
- "can0" on Linux
- "*" on Windows
-
LeaderId
CAN ID of the leader motor in the differential mechanism. The leader will have the differential output added to its regular output. -
FollowerId
CAN ID of the follower motor in the differential mechanism. The follower will have the differential output subtracted from its regular output. -
Alignment
The alignment of the differential leader and follower motors, ignoring the configured inverts. -
SensorToDifferentialRatio
The ratio of sensor rotations to the differential mechanism's difference output, where a ratio greater than 1 is a reduction.When not using a separate sensor on the difference axis, the sensor is considered half of the difference between the two motor controllers' mechanism positions/velocities. As a result, this should be set to the gear ratio on the difference axis in that scenario, or any gear ratio between the sensor and the mechanism differential when using another sensor source.
-
ClosedLoopRate
The update rate of the closed-loop controllers. This determines the update rate of the differential leader's DifferentialOutput status signal, the follower's Position and Velocity signals, and the relevant signals for any other selected differential sensor. -
LeaderInitialConfigs
The initial configs used to configure the differential leader. The default value is the factory-default.Users may change the initial configuration as they need. Any config that's not referenced in the
DifferentialMotorConstantsclass is available to be changed.The list of configs that will be overwritten is as follows:
-
DifferentialSensorsConfigs(automatic based on the devices used)
-
-
FollowerInitialConfigs
The initial configs used to configure the differential follower. The default value is the factory-default.Users may change the initial configuration as they need. Any config that's not referenced in the
DifferentialMotorConstantsclass is available to be changed.The list of configs that will be overwritten is as follows:
-
DifferentialSensorsConfigs(factory defaulted) -
MotorOutputConfigs.Inverted(determined fromAlignmentand theLeaderInitialConfigsinvert)
FollowerUsesCommonLeaderConfigsis set to true (default), the following configs are copied fromLeaderInitialConfigs: -
-
FollowerUsesCommonLeaderConfigs
Whether the follower should overwrite some of its initial configs with common configs from theLeaderInitialConfigs, such as current limits. The list of configs that are copied is documented inFollowerInitialConfigs.
-
-
Constructor Details
-
DifferentialMotorConstants
public DifferentialMotorConstants()
-
-
Method Details
-
withCANBusName
Modifies the CANBusName parameter and returns itself.Name of the CAN bus the mechanism is on. Possible CAN bus strings are:
- "rio" for the native roboRIO CAN bus
- CANivore name or serial number
- SocketCAN interface (non-FRC Linux only)
- "*" for any CANivore seen by the program
- empty string (default) to select the default for the system:
- "rio" on roboRIO
- "can0" on Linux
- "*" on Windows
- Parameters:
newCANBusName- Parameter to modify- Returns:
- this object
-
withLeaderId
Modifies the LeaderId parameter and returns itself.CAN ID of the leader motor in the differential mechanism. The leader will have the differential output added to its regular output.
- Parameters:
newLeaderId- Parameter to modify- Returns:
- this object
-
withFollowerId
Modifies the FollowerId parameter and returns itself.CAN ID of the follower motor in the differential mechanism. The follower will have the differential output subtracted from its regular output.
- Parameters:
newFollowerId- Parameter to modify- Returns:
- this object
-
withAlignment
Modifies the Alignment parameter and returns itself.The alignment of the differential leader and follower motors, ignoring the configured inverts.
- Parameters:
newAlignment- Parameter to modify- Returns:
- this object
-
withSensorToDifferentialRatio
public DifferentialMotorConstants<MotorConfigsT> withSensorToDifferentialRatio(double newSensorToDifferentialRatio) Modifies the SensorToDifferentialRatio parameter and returns itself.The ratio of sensor rotations to the differential mechanism's difference output, where a ratio greater than 1 is a reduction.
When not using a separate sensor on the difference axis, the sensor is considered half of the difference between the two motor controllers' mechanism positions/velocities. As a result, this should be set to the gear ratio on the difference axis in that scenario, or any gear ratio between the sensor and the mechanism differential when using another sensor source.
- Parameters:
newSensorToDifferentialRatio- Parameter to modify- Returns:
- this object
-
withClosedLoopRate
Modifies the ClosedLoopRate parameter and returns itself.The update rate of the closed-loop controllers. This determines the update rate of the differential leader's DifferentialOutput status signal, the follower's Position and Velocity signals, and the relevant signals for any other selected differential sensor.
- Parameters:
newClosedLoopRate- Parameter to modify- Returns:
- this object
-
withClosedLoopRate
Modifies the ClosedLoopRate parameter and returns itself.The update rate of the closed-loop controllers. This determines the update rate of the differential leader's DifferentialOutput status signal, the follower's Position and Velocity signals, and the relevant signals for any other selected differential sensor.
- Parameters:
newClosedLoopRate- Parameter to modify- Returns:
- this object
-
withLeaderInitialConfigs
public DifferentialMotorConstants<MotorConfigsT> withLeaderInitialConfigs(MotorConfigsT newLeaderInitialConfigs) Modifies the LeaderInitialConfigs parameter and returns itself.The initial configs used to configure the differential leader. The default value is the factory-default.
Users may change the initial configuration as they need. Any config that's not referenced in the
DifferentialMotorConstantsclass is available to be changed.The list of configs that will be overwritten is as follows:
-
DifferentialSensorsConfigs(automatic based on the devices used)
- Parameters:
newLeaderInitialConfigs- Parameter to modify- Returns:
- this object
-
-
withFollowerInitialConfigs
public DifferentialMotorConstants<MotorConfigsT> withFollowerInitialConfigs(MotorConfigsT newFollowerInitialConfigs) Modifies the FollowerInitialConfigs parameter and returns itself.The initial configs used to configure the differential follower. The default value is the factory-default.
Users may change the initial configuration as they need. Any config that's not referenced in the
DifferentialMotorConstantsclass is available to be changed.The list of configs that will be overwritten is as follows:
-
DifferentialSensorsConfigs(factory defaulted) -
MotorOutputConfigs.Inverted(determined fromAlignmentand theLeaderInitialConfigsinvert)
FollowerUsesCommonLeaderConfigsis set to true (default), the following configs are copied fromLeaderInitialConfigs:- Parameters:
newFollowerInitialConfigs- Parameter to modify- Returns:
- this object
-
-
withFollowerUsesCommonLeaderConfigs
public DifferentialMotorConstants<MotorConfigsT> withFollowerUsesCommonLeaderConfigs(boolean newFollowerUsesCommonLeaderConfigs) Modifies the FollowerUsesCommonLeaderConfigs parameter and returns itself.Whether the follower should overwrite some of its initial configs with common configs from the
LeaderInitialConfigs, such as current limits. The list of configs that are copied is documented inFollowerInitialConfigs.- Parameters:
newFollowerUsesCommonLeaderConfigs- Parameter to modify- Returns:
- this object
-