Package yams.motorcontrollers
Class SmartMotorControllerConfig
java.lang.Object
yams.motorcontrollers.SmartMotorControllerConfig
Smart motor controller config.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControl mode for a motor controller.static enumIdle mode for theSmartMotorControllerstatic enumAll possible options that must be checked and applied during motor config application.static enumTelemetry verbosity for theSmartMotorController -
Constructor Summary
ConstructorsConstructorDescriptionConstruct theSmartMotorControllerConfigwith aSubsystemadded later.SmartMotorControllerConfig(Subsystem subsystem) Construct theSmartMotorControllerConfigfor theSubsystem -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the follower motors so they are not reappliedclone()convertFromMechanism(Angle rotations) convertFromMechanism(AngularAcceleration acceleration) convertFromMechanism(AngularVelocity velocity) convertToMechanism(Distance distance) convertToMechanism(LinearAcceleration acceleration) convertToMechanism(LinearVelocity velocity) Get theArmFeedforwardif it is set.Get the controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.Get the closed loop maximum voltage.Get the period of theSmartMotorControllerclosed loop period.Get the closed loop ramp rate.Get theSmartMotorControllerclosed loop controller tolerance.Get theElevatorFeedforwardOptionalbooleanGet the encoder inversion stateGet the controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.Get the external encoder.Get the external encoder gearing, default is 1:1 on a MAXPlanetary.booleanGet whether or not the external encoder is inverted.Get the feedback synchronization threshold.Get the follower motors to theSmartMotorControllerConfigGet the gearing to convert rotor rotations to mechanisms rotations connected to theSmartMotorControllerGet the idle mode for theSmartMotorControllerGet the loosely coupled follower motors.Get the discontinuity point for theSmartMotorControllerencoder.Get the mechanism to distance ratio for theSmartMotorControllerLower limit of the mechanism.Upper limit of the mechanism.Get the discontinuity point for theSmartMotorControllerencoder.doublegetMOI()Get the Moment of Inertia of theSmartMotorController's mechanism for theDCMotorSim.Get the motor controller mdoe to use.booleanGet the motor inversion stateGet the open loop ramp rate.Get the simple closed loop controller without motion profiling.Get theSimpleMotorFeedforwardOptional.Get the telemetry configurationGet the starting mechanism position of theSmartMotorControllerGet the stator stall current limit.Get the subsystem controlled by theSmartMotorControllerGet the supply stall current limit.Telemetry name.Get the temperature cut off for theSmartMotorControllerbooleanUse the external feedback sensor.Get Telemetry verbosity.Get the voltage compensation for theSmartMotorControllerGet the zero offset for theSmartMotorControllervoidReset the validation checks for all required options to be applied toSmartMotorControllerfromSmartMotorController.applyConfig(SmartMotorControllerConfig).voidValidate all required options are at least fetched and handled in eachSmartMotorControllerwrapper.voidValidate external encoder config options for the config.withClosedLoopController(double kP, double kI, double kD) Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.withClosedLoopController(double kP, double kI, double kD, AngularVelocity maxVelocity, AngularAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController.withClosedLoopController(double kP, double kI, double kD, LinearVelocity maxVelocity, LinearAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController.withClosedLoopController(PIDController controller) Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.withClosedLoopController(ProfiledPIDController controller) Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), outputs are in Volts.Set the closed loop controller for theSmartMotorControllerwith an exponential profile, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), outputs are in Volts.Set the closed loop maximum voltage output.Modify the period of the PID controller for the motor controller.Modify the period of the PID controller for the motor controller.withClosedLoopRampRate(Time rate) Set the closed loop ramp rate.withClosedLoopTolerance(Angle tolerance) Set the closed loop tolerance of the mechanism controller.withClosedLoopTolerance(Distance tolerance) Set theSmartMotorControllerclosed loop controller tolerance via distance.withContinuousWrapping(Angle bottom, Angle top) Set continuous wrapping for theSmartMotorControllerwithControlMode(SmartMotorControllerConfig.ControlMode controlMode) Set the control mode for theSmartMotorControllerwithEncoderInverted(boolean inverted) Set the encoder inversion state.withExternalEncoder(Object externalEncoder) Set the external encoder which is attached to the motor type sent used bySmartMotorControllerwithExternalEncoderGearing(double reductionRatio) Set the external encoder gearing.withExternalEncoderGearing(MechanismGearing externalEncoderGearing) Set the external encoder gearing.withExternalEncoderInverted(boolean externalEncoderInverted) Set the external encoder inversion state.Set the zero offset of theSmartMotorController's external Encoder.withExternalEncoderZeroOffset(Distance distance) Set the zero offset of theSmartMotorController's external Encoder.Set the feedback synchronization threshhold so the relative encoder synchronizes with the absolute encoder at this point.withFeedforward(ArmFeedforward armFeedforward) Configure theArmFeedforwardfor thewithFeedforward(ElevatorFeedforward elevatorFeedforward) ConfigureElevatorFeedforwardfor theSmartMotorControllerwithFeedforward(SimpleMotorFeedforward simpleFeedforward) Set theSimpleMotorFeedforwardforSmartMotorController, units are in RotationswithFollowers(Pair<Object, Boolean>... followers) Set the follower motors of theSmartMotorControllerwithGearing(double reductionRatio) Set theMechanismGearingfor theSmartMotorController.withGearing(MechanismGearing gear) Set theMechanismGearingfor theSmartMotorController.Set theSmartMotorControllerto brake or coast mode.withLooselyCoupledFollowers(SmartMotorController... followers) Applies loosely coupled follower motors to theSmartMotorController.withMechanismCircumference(Distance circumference) Set the mechanism circumference to allow distance calculations on theSmartMotorController.withMomentOfInertia(double MOI) Add the mechanism moment of inertia to theSmartMotorControllers simulation when not run under a formal mechanism.withMomentOfInertia(Distance length, Mass weight) Add the mechanism moment of inertia to theSmartMotorControllers simulation when not run under a formal mechanism.withMotorInverted(boolean motorInverted) Set the motor inversion state.withOpenLoopRampRate(Time rate) Set the open loop ramp rate.withSimClosedLoopController(double kP, double kI, double kD) Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured).withSimClosedLoopController(double kP, double kI, double kD, AngularVelocity maxVelocity, AngularAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController.withSimClosedLoopController(double kP, double kI, double kD, LinearVelocity maxVelocity, LinearAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController.withSimClosedLoopController(PIDController controller) Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured).withSimClosedLoopController(ProfiledPIDController controller) Set the closed loop controller for theSmartMotorController.Set the closed loop controller for theSmartMotorController.withSimFeedforward(ArmFeedforward armFeedforward) Configure theArmFeedforwardfor thewithSimFeedforward(ElevatorFeedforward elevatorFeedforward) ConfigureElevatorFeedforwardfor theSmartMotorControllerwithSimFeedforward(SimpleMotorFeedforward simpleFeedforward) Set theSimpleMotorFeedforwardforSmartMotorController, units are in Rotations.withSoftLimit(Angle low, Angle high) Set the angle soft limits.withSoftLimit(Distance low, Distance high) Set the distance soft limits.withStartingPosition(Angle startingAngle) Set the starting angle of theSmartMotorControllerwithStartingPosition(Distance startingAngle) Set the starting angle of theSmartMotorControllerwithStatorCurrentLimit(Current stallCurrent) Set the stall stator current limit for theSmartMotorControllerwithSubsystem(Subsystem subsystem) Sets theSubsystemfor theSmartMotorControllerConfigto pass along toSmartMotorControllerandSmartMechanisms.withSupplyCurrentLimit(Current supplyCurrent) Set the stall supply current limit for theSmartMotorControllerwithTelemetry(String telemetryName, SmartMotorControllerConfig.TelemetryVerbosity verbosity) Set the telemetry for theSmartMotorControllerwithTelemetry(String telemetryName, SmartMotorControllerTelemetryConfig telemetryConfig) Set the telemetry for theSmartMotorControllerwith aSmartMotorControllerTelemetryConfigSet the telemetry for theSmartMotorControllerwithTemperatureCutoff(Temperature cutoff) Set theTemperaturecut off for theSmartMotorController/withUseExternalFeedbackEncoder(boolean useExternalEncoder) Set the external encoder to be the primary feedback device for the PID controller.withVoltageCompensation(Voltage voltageCompensation) Set the voltage compensation for theSmartMotorControllerwithWheelDiameter(Distance diameter) Set the wheel diameter for the mechanism.withWheelRadius(Distance radius) Set the wheel radius for the mechanism.
-
Constructor Details
-
SmartMotorControllerConfig
Construct theSmartMotorControllerConfigfor theSubsystem- Parameters:
subsystem-Subsystemto use.
-
SmartMotorControllerConfig
public SmartMotorControllerConfig()Construct theSmartMotorControllerConfigwith aSubsystemadded later.- Implementation Note:
- You must use
withSubsystem(Subsystem)before passing off toSmartMotorController
-
-
Method Details
-
clone
-
withSubsystem
Sets theSubsystemfor theSmartMotorControllerConfigto pass along toSmartMotorControllerandSmartMechanisms. Must be set if aSubsystemwas not defined previously.- Parameters:
subsystem-Subsystemto use.- Returns:
SmartMotorControllerConfigfor chaining.- Implementation Note:
- Does not copy the entire config, should NEVER be reused.
-
withExternalEncoderInverted
Set the external encoder inversion state.- Parameters:
externalEncoderInverted- External encoder inversion state.- Returns:
SmartMotorControllerConfigfor chaining.
-
withControlMode
public SmartMotorControllerConfig withControlMode(SmartMotorControllerConfig.ControlMode controlMode) Set the control mode for theSmartMotorController- Parameters:
controlMode-SmartMotorControllerConfig.ControlModeto apply.- Returns:
SmartMotorControllerConfigfor chaining.
-
withFeedbackSynchronizationThreshold
Set the feedback synchronization threshhold so the relative encoder synchronizes with the absolute encoder at this point.- Parameters:
angle-Angleto exceed.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopControllerMaximumVoltage
Set the closed loop maximum voltage output.- Parameters:
volts- Maximum voltage.- Returns:
SmartMotorControllerConfigfor chaining.
-
withStartingPosition
Set the starting angle of theSmartMotorController- Parameters:
startingAngle- Starting Mechanism Angle.- Returns:
SmartMotorControllerConfigfor chaining.
-
withStartingPosition
Set the starting angle of theSmartMotorController- Parameters:
startingAngle- Starting Mechanism Distance.- Returns:
SmartMotorControllerConfigfor chaining.
-
withUseExternalFeedbackEncoder
Set the external encoder to be the primary feedback device for the PID controller.- Parameters:
useExternalEncoder- External encoder as primary feedback device for the PID controller.- Returns:
SmartMotorControllerConfigfor chaining
-
withEncoderInverted
Set the encoder inversion state.- Parameters:
inverted- Encoder inversion state.- Returns:
SmartMotorControllerConfigfor chaining.
-
withMotorInverted
Set the motor inversion state.- Parameters:
motorInverted- Motor inversion state.- Returns:
SmartMotorControllerConfigfor chaining.
-
withTemperatureCutoff
Set theTemperaturecut off for theSmartMotorController/- Parameters:
cutoff- maximumTemperature- Returns:
SmartMotorControllerConfigfor chaining.
-
withExternalEncoderZeroOffset
Set the zero offset of theSmartMotorController's external Encoder.- Parameters:
distance- Zero offset in distance.- Returns:
SmartMotorControllerConfigfor chaining.
-
withExternalEncoderZeroOffset
Set the zero offset of theSmartMotorController's external Encoder.- Parameters:
angle-Angleto 0.- Returns:
SmartMotorControllerConfigfor chaining.
-
withContinuousWrapping
Set continuous wrapping for theSmartMotorController- Parameters:
bottom- Bottom value to wrap to.top- Top value to wrap to.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopTolerance
Set the closed loop tolerance of the mechanism controller.- Parameters:
tolerance- Closed loop controller tolerance- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopTolerance
Set theSmartMotorControllerclosed loop controller tolerance via distance.- Parameters:
tolerance-Distancetolerance.- Returns:
SmartMotorControllerConfigfpr chaining.
-
getClosedLoopTolerance
Get theSmartMotorControllerclosed loop controller tolerance.- Returns:
Angletolerance.
-
withTelemetry
public SmartMotorControllerConfig withTelemetry(String telemetryName, SmartMotorControllerConfig.TelemetryVerbosity verbosity) Set the telemetry for theSmartMotorController- Parameters:
telemetryName- Name for theSmartMotorControllerverbosity- Verbosity of the Telemetry for theSmartMotorController- Returns:
SmartMotorControllerConfigfor chaining.
-
withTelemetry
public SmartMotorControllerConfig withTelemetry(SmartMotorControllerConfig.TelemetryVerbosity verbosity) Set the telemetry for theSmartMotorController- Parameters:
verbosity- Verbosity of the Telemetry for theSmartMotorController- Returns:
SmartMotorControllerConfigfor chaining.
-
withTelemetry
public SmartMotorControllerConfig withTelemetry(String telemetryName, SmartMotorControllerTelemetryConfig telemetryConfig) Set the telemetry for theSmartMotorControllerwith aSmartMotorControllerTelemetryConfig- Parameters:
telemetryName- Name for theSmartMotorControllertelemetryConfig- Config that specifies what to log.- Returns:
SmartMotorControllerConfigfor chaining.
-
getSmartControllerTelemetryConfig
Get the telemetry configuration- Returns:
- Telemetry configuration.
-
getStatorStallCurrentLimit
Get the stator stall current limit.- Returns:
- Stator current limit.
-
withSoftLimit
Set the distance soft limits.- Parameters:
low- Low distance soft limit.high- High distance soft limit.- Returns:
SmartMotorControllerConfigfor chaining.
-
withMomentOfInertia
Add the mechanism moment of inertia to theSmartMotorControllers simulation when not run under a formal mechanism.- Parameters:
length- Length of the mechanism for MOI.weight- Weight of the mechanism for MOI.- Returns:
SmartMotorControllerConfigfor chaining
-
withMomentOfInertia
Add the mechanism moment of inertia to theSmartMotorControllers simulation when not run under a formal mechanism.- Parameters:
MOI- Known moment of inertia.- Returns:
SmartMotorControllerConfigfor chaining
-
withSoftLimit
Set the angle soft limits.- Parameters:
low- Low angle soft limit.high- High angle soft limit.- Returns:
SmartMotorControllerConfigfor chaining.
-
getSupplyStallCurrentLimit
Get the supply stall current limit.- Returns:
- Supply stall current limit.
-
getVoltageCompensation
Get the voltage compensation for theSmartMotorController- Returns:
- Ideal voltage
-
getIdleMode
Get the idle mode for theSmartMotorController- Returns:
SmartMotorControllerConfig.MotorMode
-
getMOI
public double getMOI()Get the Moment of Inertia of theSmartMotorController's mechanism for theDCMotorSim.- Returns:
- Moment of Inertia in JKgMetersSquared.
-
getMechanismLowerLimit
Lower limit of the mechanism.- Returns:
- Lower angle soft limit.
-
getMechanismUpperLimit
Upper limit of the mechanism.- Returns:
- Higher angle soft limit.
-
withIdleMode
Set theSmartMotorControllerto brake or coast mode.- Parameters:
idleMode-SmartMotorControllerConfig.MotorModeidle mode- Returns:
SmartMotorControllerConfigfor chaining.
-
withVoltageCompensation
Set the voltage compensation for theSmartMotorController- Parameters:
voltageCompensation- Ideal voltage value.- Returns:
SmartMotorControllerConfigfor chaining.
-
withFollowers
@SafeVarargs public final SmartMotorControllerConfig withFollowers(Pair<Object, Boolean>... followers) Set the follower motors of theSmartMotorController- Parameters:
followers- Base motor types (NOTSmartMotorController!) to configure as followers, must be same brand as theSmartMotorControllerwith inversion from the base motor.- Returns:
SmartMotorControllerConfigfor chaining
-
withLooselyCoupledFollowers
public final SmartMotorControllerConfig withLooselyCoupledFollowers(SmartMotorController... followers) Applies loosely coupled follower motors to theSmartMotorController.- Parameters:
followers-SmartMotorControllers to configure as followers.- Returns:
SmartMotorControllerConfigfor chaining- Implementation Requirements:
- Configurations are not transferred!
- Implementation Note:
- ONLY the position and velocity requests will be forwarded.
-
clearFollowers
public void clearFollowers()Clear the follower motors so they are not reapplied -
withStatorCurrentLimit
Set the stall stator current limit for theSmartMotorController- Parameters:
stallCurrent- Stall stator current limit for theSmartMotorController.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSupplyCurrentLimit
Set the stall supply current limit for theSmartMotorController- Parameters:
supplyCurrent- Supply current limit.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopRampRate
Set the closed loop ramp rate. The ramp rate is the minimum time it should take to go from 0 power to full power in the motor controller while using PID.- Parameters:
rate- time to go from 0 to full throttle.- Returns:
SmartMotorControllerConfigfor chaining.
-
withOpenLoopRampRate
Set the open loop ramp rate. The ramp rate is the minimum time it should take to go from 0 power to full power in the motor controller while not using PID.- Parameters:
rate- time to go from 0 to full throttle.- Returns:
SmartMotorControllerConfigfor chaining.
-
withExternalEncoder
Set the external encoder which is attached to the motor type sent used bySmartMotorController- Parameters:
externalEncoder- External encoder attached to theSmartMotorController- Returns:
SmartMotorControllerConfigfor chaining.
-
getFollowers
Get the follower motors to theSmartMotorControllerConfig- Returns:
- Follower motor list.
-
withGearing
Set theMechanismGearingfor theSmartMotorController.- Parameters:
gear-MechanismGearingrepresenting the gearbox and sprockets to the final axis.- Returns:
SmartMotorControllerConfigfor chaining.
-
withGearing
Set theMechanismGearingfor theSmartMotorController.- Parameters:
reductionRatio- Reduction ratio, for example, a ratio of "3:1" is 3; a ratio of "1:2" is 0.5.- Returns:
SmartMotorControllerConfigfor chaining.
-
withMechanismCircumference
Set the mechanism circumference to allow distance calculations on theSmartMotorController.- Parameters:
circumference- Circumference of the actuating spool or sprocket+chain attached the mechanism actuator.- Returns:
SmartMotorControllerConfigfor chaining.
-
withWheelRadius
Set the wheel radius for the mechanism.- Parameters:
radius- Radius of the wheels asDistance- Returns:
SmartMotorControllerConfigfor chaining.
-
withWheelDiameter
Set the wheel diameter for the mechanism.- Parameters:
diameter- Diameter of the wheels asDistance- Returns:
SmartMotorControllerConfigfor chaining.
-
getMechanismCircumference
Get the mechanism to distance ratio for theSmartMotorController- Returns:
- Rotations/Distance ratio to convert mechanism rotations to distance.
-
withClosedLoopControlPeriod
Modify the period of the PID controller for the motor controller.- Parameters:
time- Period of the motor controller PID.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopControlPeriod
Modify the period of the PID controller for the motor controller.- Parameters:
time- Period of the motor controller PID.- Returns:
SmartMotorControllerConfigfor chaining.
-
getArmFeedforward
Get theArmFeedforwardif it is set.- Returns:
Optionalof theArmFeedforward.
-
withSimFeedforward
Configure theArmFeedforwardfor the- Parameters:
armFeedforward- Arm feedforward for theSmartMotorController- Returns:
SmartMotorControllerConfigfor chaining.
-
withFeedforward
Configure theArmFeedforwardfor the- Parameters:
armFeedforward- Arm feedforward for theSmartMotorController- Returns:
SmartMotorControllerConfigfor chaining.
-
getElevatorFeedforward
Get theElevatorFeedforwardOptional- Returns:
ElevatorFeedforwardOptional
-
withSimFeedforward
ConfigureElevatorFeedforwardfor theSmartMotorController- Parameters:
elevatorFeedforward-ElevatorFeedforwardto set.- Returns:
SmartMotorControllerConfigfor chaining.
-
withFeedforward
ConfigureElevatorFeedforwardfor theSmartMotorController- Parameters:
elevatorFeedforward-ElevatorFeedforwardto set.- Returns:
SmartMotorControllerConfigfor chaining.
-
getSimpleFeedforward
Get theSimpleMotorFeedforwardOptional.- Returns:
SimpleMotorFeedforwardOptional
-
withSimClosedLoopController
public SmartMotorControllerConfig withSimClosedLoopController(ExponentialProfilePIDController controller) Set the closed loop controller for theSmartMotorController. The units passed in are in Rotations (or Meters if Mechanism Circumference is configured), and outputs are in Volts.- Parameters:
controller-ProfiledPIDControllerto use, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), and output is Voltage.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSimClosedLoopController
Set the closed loop controller for theSmartMotorController. The units passed in are in Rotations (or Meters if Mechanism Circumference is configured), and outputs are in Volts.- Parameters:
controller-ProfiledPIDControllerto use, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), and output is Voltage.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSimClosedLoopController
Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured).- Parameters:
kP- KP scalar for the PID Controller.kI- KI scalar for the PID Controller.kD- KD scalar for the PID Controller.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSimClosedLoopController
Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured).- Parameters:
controller-PIDControllerto use.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSimClosedLoopController
public SmartMotorControllerConfig withSimClosedLoopController(double kP, double kI, double kD, LinearVelocity maxVelocity, LinearAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController. Units are Meters.- Parameters:
kP- KP scalar for the PID Controller.kI- KI scalar for the PID Controller.kD- KD scalar for the PID Controller.maxVelocity- Maximum linear velocity for the Trapezoidal profile.maxAcceleration- Maximum linear acceleration for the Trapezoidal profile.- Returns:
SmartMotorControllerConfigfor chaining.
-
withSimClosedLoopController
public SmartMotorControllerConfig withSimClosedLoopController(double kP, double kI, double kD, AngularVelocity maxVelocity, AngularAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController. Units are Rotations.- Parameters:
kP- KP scalar for the PID Controller, the units passed in are in Rotations.kI- KI scalar for the PID Controller, the units passed in are in Rotations.kD- KD scalar for the PID Controller, the units passed in are in Rotations.maxVelocity- Maximum angular velocity for the Trapezoidal profile.maxAcceleration- Maximum angular acceleration for the Trapezoidal profile.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), outputs are in Volts.- Parameters:
controller-ProfiledPIDControllerto use, the units passed in are in Rotations and output is Voltage.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
public SmartMotorControllerConfig withClosedLoopController(ExponentialProfilePIDController controller) Set the closed loop controller for theSmartMotorControllerwith an exponential profile, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), outputs are in Volts.- Parameters:
controller-ExponentialProfilePIDControllerto use, the units passed in are in Rotations and output is Voltage.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Parameters:
kP- KP scalar for the PID Controller, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.kI- KI scalar for the PID Controller, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.kD- KD scalar for the PID Controller, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
Set the closed loop controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Parameters:
controller-PIDControllerto use, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
public SmartMotorControllerConfig withClosedLoopController(double kP, double kI, double kD, LinearVelocity maxVelocity, LinearAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController. Units are Meters.- Parameters:
kP- KP scalar for the PID Controller, the units passed in are in Meters and output is Voltage.kI- KI scalar for the PID Controller, the units passed in are in Meters and output is Voltage.kD- KD scalar for the PID Controller, the units passed in are in Meters and output is Voltage.maxVelocity- Maximum linear velocity for the Trapezoidal profile.maxAcceleration- Maximum linear acceleration for the Trapezoidal profile.- Returns:
SmartMotorControllerConfigfor chaining.
-
withClosedLoopController
public SmartMotorControllerConfig withClosedLoopController(double kP, double kI, double kD, AngularVelocity maxVelocity, AngularAcceleration maxAcceleration) Set the closed loop controller for theSmartMotorController. Units are Meters.- Parameters:
kP- KP scalar for the PID Controller, the units passed in are in Rotations and output is Voltage.kI- KI scalar for the PID Controller, the units passed in are in Rotations and output is Voltage.kD- KD scalar for the PID Controller, the units passed in are in Rotations and output is Voltage.maxVelocity- Maximum angular velocity for the Trapezoidal profile.maxAcceleration- Maximum angular acceleration for the Trapezoidal profile.- Returns:
SmartMotorControllerConfigfor chaining.
-
getClosedLoopController
Get the controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Returns:
ProfiledPIDController
-
getExponentiallyProfiledClosedLoopController
Get the controller for theSmartMotorController, the units passed in are in Rotations (or Meters if Mechanism Circumference is configured), the outputs are in Volts.- Returns:
ExponentialProfilePIDController
-
getSimpleClosedLoopController
Get the simple closed loop controller without motion profiling.- Returns:
PIDControllerif it exists.
-
withSimFeedforward
Set theSimpleMotorFeedforwardforSmartMotorController, units are in Rotations.- Parameters:
simpleFeedforward-SimpleMotorFeedforward- Returns:
SmartMotorControllerConfigfor chaining.
-
withFeedforward
Set theSimpleMotorFeedforwardforSmartMotorController, units are in Rotations- Parameters:
simpleFeedforward-SimpleMotorFeedforward- Returns:
SmartMotorControllerConfigfor chaining.
-
getClosedLoopControlPeriod
Get the period of theSmartMotorControllerclosed loop period.- Returns:
SmartMotorControllerclosed loop controller period.
-
getGearing
Get the gearing to convert rotor rotations to mechanisms rotations connected to theSmartMotorController- Returns:
MechanismGearingrepresenting the gearbox and sprockets attached to theSmartMotorController.
-
getExternalEncoder
Get the external encoder.- Returns:
- Attached external encoder.
-
getOpenLoopRampRate
Get the open loop ramp rate.- Returns:
- Open loop ramp rate.
-
getClosedLoopRampRate
Get the closed loop ramp rate.- Returns:
- Closed loop ramp.
-
getVerbosity
Get Telemetry verbosity.- Returns:
- Verbosity for telemetry.
-
getTelemetryName
Telemetry name.- Returns:
- Telemetry name for NetworkTables.
-
getSubsystem
Get the subsystem controlled by theSmartMotorController- Returns:
Subsystemcontrolled.
-
convertToMechanism
- Parameters:
velocity- Linear velocity to convert.- Returns:
- Equivalent angular velocity.
-
convertToMechanism
- Parameters:
acceleration- Linear acceleration to convert.- Returns:
- Equivalent angular acceleration.
-
convertToMechanism
-
convertFromMechanism
- Parameters:
rotations- Rotations to convert.- Returns:
- Distance of the mechanism.
-
convertFromMechanism
- Parameters:
velocity- Velocity to convert.- Returns:
- Velocity of the mechanism.
-
convertFromMechanism
- Parameters:
acceleration- Rotations to convert.- Returns:
- Acceleration of the mechanism.
-
getZeroOffset
Get the zero offset for theSmartMotorController- Returns:
Angleoffset.
-
getTemperatureCutoff
Get the temperature cut off for theSmartMotorController- Returns:
- Maximum
Temperature
-
getEncoderInverted
public boolean getEncoderInverted()Get the encoder inversion state- Returns:
- encoder inversion state
-
getMotorInverted
public boolean getMotorInverted()Get the motor inversion state- Returns:
- moto inversion state.
-
getUseExternalFeedback
public boolean getUseExternalFeedback()Use the external feedback sensor.- Returns:
- Use the attached absolute encoder.
-
getStartingPosition
Get the starting mechanism position of theSmartMotorController- Returns:
- Starting Mechanism position.
-
getClosedLoopControllerMaximumVoltage
Get the closed loop maximum voltage.- Returns:
- Maximum voltage in Volts.
-
getFeedbackSynchronizationThreshold
Get the feedback synchronization threshold.- Returns:
- Feedback synchronization threshold.
-
getMotorControllerMode
Get the motor controller mdoe to use.- Returns:
SmartMotorControllerConfig.ControlModeto use.
-
getExternalEncoderGearing
Get the external encoder gearing, default is 1:1 on a MAXPlanetary.- Returns:
- External encoder gearing.
-
withExternalEncoderGearing
public SmartMotorControllerConfig withExternalEncoderGearing(MechanismGearing externalEncoderGearing) Set the external encoder gearing.- Parameters:
externalEncoderGearing- External encoder gearing.- Returns:
SmartMotorControllerConfigfor chaining.
-
withExternalEncoderGearing
Set the external encoder gearing.- Parameters:
reductionRatio- External encoder gearing. For example, a ratio of "3:1" is 3; "1:2" is 0.5- Returns:
SmartMotorControllerConfigfor chaining.
-
getMaxDiscontinuityPoint
Get the discontinuity point for theSmartMotorControllerencoder.- Returns:
Anglewhere the encoder wraps around.
-
getMinDiscontinuityPoint
Get the discontinuity point for theSmartMotorControllerencoder.- Returns:
Anglewhere the encoder wraps around.
-
getLooselyCoupledFollowers
Get the loosely coupled follower motors.- Returns:
SmartMotorControllerlist of loosely coupled followers.
-
resetValidationCheck
public void resetValidationCheck()Reset the validation checks for all required options to be applied toSmartMotorControllerfromSmartMotorController.applyConfig(SmartMotorControllerConfig). -
validateBasicOptions
public void validateBasicOptions()Validate all required options are at least fetched and handled in eachSmartMotorControllerwrapper. -
validateExternalEncoderOptions
public void validateExternalEncoderOptions()Validate external encoder config options for the config. -
getExternalEncoderInverted
public boolean getExternalEncoderInverted()Get whether or not the external encoder is inverted.- Returns:
- External encoder inversion state
-