Class NovaWrapper
java.lang.Object
yams.core.motorcontrollers.SmartMotorController
yams.core.motorcontrollers.local.NovaWrapper
Nova wrapper for The Thrifty Bot's Thrifty Nova motor controller, using ThriftyLib 2027.
The closed loop controller runs on the SystemCore and commands the Nova with voltage, like the profiled controllers of the other wrappers. ThriftyLib's simulation ignores the Nova's onboard PID gains, so running the loop on the SystemCore keeps simulation and the robot the same.
External encoders, given to
SmartMotorControllerConfig.withExternalEncoder(Object):
Motor.FeedbackSensorType.ABS: an absolute encoder wired to the Nova's data port. Its type comes from the vendor config, such asNovaConfig.absoluteEncoderType(Motor.AbsoluteEncoderType.REV_ENCODER).Motor.FeedbackSensorType.QUAD: a quadrature encoder wired to the Nova's data port. Its type comes from the vendor config, such asNovaConfig.quadratureEncoderType(Motor.QuadratureEncoderType.custom(2048)).CanEncoder: a Thrifty CAN Encoder on the same CAN bus.
Example
// Configure and create a Nova driving a NEO on CAN bus 0, CAN ID 3
SmartMotorControllerConfig config = new SmartMotorControllerConfig()
.withMotorInverted(false)
.withStatorCurrentLimit(Amps.of(40))
.withClosedLoopController(0.2, 0, 0)
.withVendorConfig(new NovaConfigBatch(NovaConfig.tempThrottleEnable(true)));
SmartMotorController motor = new NovaWrapper(new Nova(0, 3, MotorType.NEO),
DCMotor.getNEO(1), config);
-
Nested Class Summary
Nested classes/interfaces inherited from class SmartMotorController
SmartMotorController.ClosedLoopControllerSlot -
Field Summary
Fields inherited from class SmartMotorController
m_batterySimUUID, m_closedLoopControllerThread, m_closeHooks, m_config, m_expoProfile, m_expoState, m_lastClosedLoopMechanismPosition, m_looseFollowers, m_lqr, m_pid, m_simSupplier, m_slot, m_systemCoreClosedLoopAlert, m_trapezoidProfile, m_trapState, parentTable, setpointFeedforwardForce, setpointPosition, setpointVelocity, telemetry, telemetryConfig, telemetryTable, tuningTable -
Constructor Summary
ConstructorsConstructorDescriptionNovaWrapper(com.thrifty.nova.Nova controller, org.wpilib.math.system.DCMotor motor, SmartMotorControllerConfig<?> config) Construct the Nova Wrapper for the genericSmartMotorController. -
Method Summary
Modifier and TypeMethodDescriptionbooleanapplyConfig(SmartMotorControllerConfig<?> config) Apply theSmartMotorControllerConfigto theSmartMotorController.Get theSmartMotorControllerConfigfor theSmartMotorControllerorg.wpilib.math.system.DCMotorGet theDCMotormodeling the motor controlled by the motor controller.doubleGet the duty cycle output of the motor controller.Optional<org.wpilib.units.measure.Angle> Get the mechanismAnglefrom the external (absolute) encoder, scaled by the configured external encoderMechanismGearing.Optional<org.wpilib.units.measure.AngularVelocity> Get the mechanismAngularVelocityfrom the external (absolute) encoder, scaled by the configured external encoderMechanismGearing.org.wpilib.units.measure.LinearAccelerationGet the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfigorg.wpilib.units.measure.DistanceGet the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfig.org.wpilib.units.measure.LinearVelocityGet the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfig.org.wpilib.units.measure.AngularAccelerationGet the MechanismAngularAcceleration, calculating it on the robot controller if necessary by taking the derivative of the velocity.org.wpilib.units.measure.Angleorg.wpilib.units.measure.AngularVelocityGet the MechanismAngularVelocitytaking the configuredMechanismGearinginto the measurement applied via theSmartMotorControllerConfig.Get the Motor Controller Object passed into theSmartMotorController.Get the motor controller object config generated bySmartMotorControllerbased off theSmartMotorControllerConfigorg.wpilib.units.measure.AngleGet the mechanismAnglefrom the relative encoder in the motor, scaled by the configuredMechanismGearing.org.wpilib.units.measure.AngularVelocityGet the mechanismAngularVelocityfrom the relative encoder in the motor, scaled by the configuredMechanismGearing.org.wpilib.units.measure.AngleGet the rotations of the motor with the relative encoder since the motor controller powered on scaled to the mechanism rotations.org.wpilib.units.measure.AngularVelocityGets the angular velocity of the motor.org.wpilib.units.measure.CurrentGet the stator current of the motor controller.Optional<org.wpilib.units.measure.Current> Get the supply current of the motor controller.org.wpilib.units.measure.TemperatureGet theSmartMotorControllertemperature.org.wpilib.util.Pair<Optional<List<SmartMotorControllerTelemetry.BooleanTelemetryField>>, Optional<List<SmartMotorControllerTelemetry.DoubleTelemetryField>>> Get a list of unsupported telemetry fields if any exist.org.wpilib.units.measure.VoltageGet the voltage output of the motor.voidSeed the relative encoder with the position from the absolute encoder.voidsetClosedLoopRampRate(org.wpilib.units.measure.Time rampRate) Set the closed loop ramp rate.voidSet the closed loop controller slot to use.voidsetDutyCycle(double dutyCycle) Set the dutycycle output of the motor controller.voidsetEncoderInverted(boolean inverted) Set the phase of the encoder attached to the brushless motor.voidsetEncoderPosition(org.wpilib.units.measure.Angle angle) Set the encoder positionvoidsetEncoderPosition(org.wpilib.units.measure.Distance distance) Set the encoder position.voidsetEncoderVelocity(org.wpilib.units.measure.AngularVelocity velocity) Set the encoder velocityvoidsetEncoderVelocity(org.wpilib.units.measure.LinearVelocity velocity) Set the encoder velocity.voidsetExponentialProfile(OptionalDouble kV, OptionalDouble kA, Optional<org.wpilib.units.measure.Voltage> maxInput) Set the exponential profile fields.voidsetFeedback(double kP, double kI, double kD) Set the closed loop feedback controller PID.voidsetFeedforward(double kS, double kV, double kA, double kG) Set the feedforward controller.voidsetKa(double kA) Acceleration feedforward element.voidsetKd(double kD) Set kD for the feedback controller PID.voidsetKg(double kG) kSin feedforward element.voidsetKi(double kI) Set kI for the feedback controller PID.voidsetKp(double kP) Set kP for the feedback controller PID.voidsetKs(double kS) Static feedforward element.voidsetKv(double kV) Velocity feedforward element.voidsetMeasurementLowerLimit(org.wpilib.units.measure.Distance lowerLimit) Set the measurement lower limit, only works if mechanism circumference is defined.voidsetMeasurementUpperLimit(org.wpilib.units.measure.Distance upperLimit) Set the measurement upper limit, only works if mechanism circumference is defined.voidsetMechanismCircumference(org.wpilib.units.measure.Distance circumference) Update the mechanism circumference used for linear position/velocity conversions.voidsetMechanismGearing(MechanismGearing gearing) Update the mechanism gearing used for position/velocity conversions.voidsetMechanismLimits(org.wpilib.units.measure.Angle lower, org.wpilib.units.measure.Angle upper) Set the Mechanism limits for the motor controller.voidsetMechanismLimitsEnabled(boolean enabled) Enable or disable the mechanism/measurement limits in the motor controller.voidsetMechanismLowerLimit(org.wpilib.units.measure.Angle lowerLimit) Set the mechanism lower limit.voidsetMechanismUpperLimit(org.wpilib.units.measure.Angle upperLimit) Set the mechanism upper limit.voidsetMotionProfileMaxAcceleration(org.wpilib.units.measure.AngularAcceleration maxAcceleration) Set the maximum acceleration for the trapezoidal profile for the feedback controller.voidsetMotionProfileMaxAcceleration(org.wpilib.units.measure.LinearAcceleration maxAcceleration) Set the maximum acceleration of the trapezoidal profile for the feedback controller.voidsetMotionProfileMaxJerk(org.wpilib.units.measure.Velocity<org.wpilib.units.AngularAccelerationUnit> maxJerk) Set the maximum jerk for the trapezoidal profile for the feedback controller.voidsetMotionProfileMaxVelocity(org.wpilib.units.measure.AngularVelocity maxVelocity) Set the maximum velocity for the trapezoidal profile for the feedback controller.voidsetMotionProfileMaxVelocity(org.wpilib.units.measure.LinearVelocity maxVelocity) Set the maximum velocity of the trapezoidal profile for the feedback controller.voidsetMotorInverted(boolean inverted) Set the inversion state of the motor.voidsetOpenLoopRampRate(org.wpilib.units.measure.Time rampRate) Set the open loop ramp rate.voidsetPosition(org.wpilib.units.measure.Angle angle) Set the MechanismAngleusing the PID and feedforward fromSmartMotorControllerConfig.voidsetPosition(org.wpilib.units.measure.Distance distance) Set the MechanismDistanceusing the PID and feedforward fromSmartMotorControllerConfig.voidsetStatorCurrentLimit(org.wpilib.units.measure.Current currentLimit) Set the stator current limit for the device.voidsetSupplyCurrentLimit(org.wpilib.units.measure.Current currentLimit) Set the supply current limit.voidSetup the simulation for the wrapper.voidsetVelocity(org.wpilib.units.measure.AngularVelocity angularVelocity) Set the MechanismAngularVelocityusing the PID and feedforward fromSmartMotorControllerConfig.voidsetVelocity(org.wpilib.units.measure.AngularVelocity angularVelocity, org.wpilib.units.measure.Force feedforwardForce) Set the MechanismAngularVelocityusing the PID and feedforward fromSmartMotorControllerConfig, with an additional feedforwardForceapplied on top, e.g.voidsetVelocity(org.wpilib.units.measure.LinearVelocity velocity) Set the MechanismLinearVelocityusing the PID and feedforward fromSmartMotorControllerConfig.voidsetVoltage(org.wpilib.units.measure.Voltage voltage) Set the voltage output of the motor controller.voidsetZeroPower(MotorMode mode) Set the motor zero power mode from COAST or BRAKE.voidSimulation iteration.voidCheck if the relative encoder is out of sync with absolute encoder within defined tolerances.Methods inherited from class SmartMotorController
addCloseHook, applyTuningValues, buildAlertId, checkConfigSafety, close, create, getClosedLoopControllerPeriod, getClosedLoopControllerSlot, getExponentialProfileState, getLooselyCoupledFollowers, getMeasurementPositionSetpoint, getMechanismPositionSetpoint, getMechanismSetpointVelocity, getName, getSetpointFeedforwardForce, getSimSupplier, getTrapezoidalProfileState, getVelocityMeasurementDelay, isMotor, iterateClosedLoopController, setSimSupplier, setupLiveTuning, setupTelemetry, setupTelemetry, setVelocity, startClosedLoopController, stopClosedLoopController, stopLiveTuning, toString, tuningEnabled, updateTelemetry
-
Constructor Details
-
NovaWrapper
public NovaWrapper(com.thrifty.nova.Nova controller, org.wpilib.math.system.DCMotor motor, SmartMotorControllerConfig<?> config) Construct the Nova Wrapper for the genericSmartMotorController.- Parameters:
controller-Novato use.motor-DCMotorconnected to theNova.config-SmartMotorControllerConfigto apply to theNova. Its vendor config, if any, must be aNovaConfig.Config, such as aNovaConfigBatch, and is applied before the YAMS config.- Throws:
SmartMotorControllerConfigurationException- if the vendor config is not aNovaConfig.Config.SmartMotorControllerConfigurationException- ifapplyConfig(SmartMotorControllerConfig)rejects the config.IllegalArgumentException- ifapplyConfig(SmartMotorControllerConfig)rejects the config.
-
-
Method Details
-
setupSimulation
public void setupSimulation()Description copied from class:SmartMotorControllerSetup the simulation for the wrapper.- Specified by:
setupSimulationin classSmartMotorController
-
seedRelativeEncoder
public void seedRelativeEncoder()Description copied from class:SmartMotorControllerSeed the relative encoder with the position from the absolute encoder.- Specified by:
seedRelativeEncoderin classSmartMotorController
-
synchronizeRelativeEncoder
public void synchronizeRelativeEncoder()Description copied from class:SmartMotorControllerCheck if the relative encoder is out of sync with absolute encoder within defined tolerances.- Specified by:
synchronizeRelativeEncoderin classSmartMotorController
-
simIterate
public void simIterate()Description copied from class:SmartMotorControllerSimulation iteration.- Specified by:
simIteratein classSmartMotorController
-
setZeroPower
Description copied from class:SmartMotorControllerSet the motor zero power mode from COAST or BRAKE.- Specified by:
setZeroPowerin classSmartMotorController- Parameters:
mode-MotorModeselected.
-
setEncoderVelocity
public void setEncoderVelocity(org.wpilib.units.measure.AngularVelocity velocity) Set the encoder velocity- Specified by:
setEncoderVelocityin classSmartMotorController- Parameters:
velocity-AngularVelocityof the Mechanism.- Throws:
UnsupportedOperationException- if called outside of simulation, since Thrifty Novas do not support setting encoder velocity.
-
setEncoderVelocity
public void setEncoderVelocity(org.wpilib.units.measure.LinearVelocity velocity) Set the encoder velocity.- Specified by:
setEncoderVelocityin classSmartMotorController- Parameters:
velocity- MeasurementLinearVelocity- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.UnsupportedOperationException- if called outside of simulation, since Thrifty Novas do not support setting encoder velocity.
-
setEncoderPosition
public void setEncoderPosition(org.wpilib.units.measure.Angle angle) Description copied from class:SmartMotorControllerSet the encoder position- Specified by:
setEncoderPositionin classSmartMotorController- Parameters:
angle- Current MechanismAngle.
-
setEncoderPosition
public void setEncoderPosition(org.wpilib.units.measure.Distance distance) Set the encoder position.- Specified by:
setEncoderPositionin classSmartMotorController- Parameters:
distance- Current MeasurementDistance.- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
setPosition
public void setPosition(org.wpilib.units.measure.Angle angle) Description copied from class:SmartMotorControllerSet the MechanismAngleusing the PID and feedforward fromSmartMotorControllerConfig.- Specified by:
setPositionin classSmartMotorController- Parameters:
angle- Mechanism angle to set.
-
setPosition
public void setPosition(org.wpilib.units.measure.Distance distance) Set the MechanismDistanceusing the PID and feedforward fromSmartMotorControllerConfig.- Specified by:
setPositionin classSmartMotorController- Parameters:
distance- MechanismDistanceto set.- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
setVelocity
public void setVelocity(org.wpilib.units.measure.LinearVelocity velocity) Set the MechanismLinearVelocityusing the PID and feedforward fromSmartMotorControllerConfig.- Overrides:
setVelocityin classSmartMotorController- Parameters:
velocity- MechanismLinearVelocityto target.- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
setVelocity
public void setVelocity(org.wpilib.units.measure.AngularVelocity angularVelocity) Description copied from class:SmartMotorControllerSet the MechanismAngularVelocityusing the PID and feedforward fromSmartMotorControllerConfig.- Specified by:
setVelocityin classSmartMotorController- Parameters:
angularVelocity- MechanismAngularVelocityto target.
-
setVelocity
public void setVelocity(org.wpilib.units.measure.AngularVelocity angularVelocity, org.wpilib.units.measure.Force feedforwardForce) Description copied from class:SmartMotorControllerSet the MechanismAngularVelocityusing the PID and feedforward fromSmartMotorControllerConfig, with an additional feedforwardForceapplied on top, e.g. from a PathPlanner set-point generator. Applied whether the motor controller's native closed-loop velocity control or an LQR/software motion profile loop is driving the mechanism.- Specified by:
setVelocityin classSmartMotorController- Parameters:
angularVelocity- MechanismAngularVelocityto target.feedforwardForce- Additional feedforwardForceapplied to the mechanism, ornullfor none.
-
applyConfig
Apply theSmartMotorControllerConfigto theSmartMotorController.- Specified by:
applyConfigin classSmartMotorController- Parameters:
config-SmartMotorControllerConfigto use.- Returns:
- Successful Application of the configuration.
- Throws:
SmartMotorControllerConfigurationException- if different open and closed loop ramp rates are configured.SmartMotorControllerConfigurationException- if a zero offset or discontinuity point is configured for a quadrature encoder.SmartMotorControllerConfigurationException- if an external encoder option is configured without an external encoder.SmartMotorControllerConfigurationException- if a vendor control request is configured.SmartMotorControllerConfigurationException- if a required config option is left unhandled during validation.IllegalArgumentException- if a closed loop control period is configured while not in closed loop mode.IllegalArgumentException- if a closed loop tolerance is configured with an LQR controller.IllegalArgumentException- if the external encoder is notMotor.FeedbackSensorType.ABS,Motor.FeedbackSensorType.QUADor aCanEncoder.IllegalArgumentException- if a follower is not aNova.IllegalArgumentException- if relative encoder inversion is configured.
-
getDutyCycle
public double getDutyCycle()Description copied from class:SmartMotorControllerGet the duty cycle output of the motor controller.- Specified by:
getDutyCyclein classSmartMotorController- Returns:
- DutyCycle of the motor controller.
-
setDutyCycle
public void setDutyCycle(double dutyCycle) Description copied from class:SmartMotorControllerSet the dutycycle output of the motor controller.- Specified by:
setDutyCyclein classSmartMotorController- Parameters:
dutyCycle- Value between [-1,1]
-
getSupplyCurrent
Description copied from class:SmartMotorControllerGet the supply current of the motor controller.- Specified by:
getSupplyCurrentin classSmartMotorController- Returns:
- The supply current of the motor controller.
-
getStatorCurrent
public org.wpilib.units.measure.Current getStatorCurrent()Description copied from class:SmartMotorControllerGet the stator current of the motor controller.- Specified by:
getStatorCurrentin classSmartMotorController- Returns:
- Stator current
-
getVoltage
public org.wpilib.units.measure.Voltage getVoltage()Description copied from class:SmartMotorControllerGet the voltage output of the motor.- Specified by:
getVoltagein classSmartMotorController- Returns:
- Voltage output of the motor.
-
setVoltage
public void setVoltage(org.wpilib.units.measure.Voltage voltage) Description copied from class:SmartMotorControllerSet the voltage output of the motor controller. Useful for Sysid.- Specified by:
setVoltagein classSmartMotorController- Parameters:
voltage- Voltage to set the motor controller output to.
-
getDCMotor
public org.wpilib.math.system.DCMotor getDCMotor()Description copied from class:SmartMotorControllerGet theDCMotormodeling the motor controlled by the motor controller.- Specified by:
getDCMotorin classSmartMotorController- Returns:
DCMotorof the controlled motor.
-
getMeasurementVelocity
public org.wpilib.units.measure.LinearVelocity getMeasurementVelocity()Get the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfig.- Specified by:
getMeasurementVelocityin classSmartMotorController- Returns:
- Measurement velocity of the mechanism post-gearing.
- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
getMeasurementPosition
public org.wpilib.units.measure.Distance getMeasurementPosition()Get the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfig.- Specified by:
getMeasurementPositionin classSmartMotorController- Returns:
- Measurement velocity of the mechanism post-gearing.
- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
getMeasurementAcceleration
public org.wpilib.units.measure.LinearAcceleration getMeasurementAcceleration()Get the usable measurement of the motor for mechanisms operating under distance units converted with theSmartMotorControllerConfig- Specified by:
getMeasurementAccelerationin classSmartMotorController- Returns:
- Measurement acceleration of the mechanism post-gearing.
- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
getMechanismVelocity
public org.wpilib.units.measure.AngularVelocity getMechanismVelocity()Description copied from class:SmartMotorControllerGet the MechanismAngularVelocitytaking the configuredMechanismGearinginto the measurement applied via theSmartMotorControllerConfig. UsesSmartMotorController.getExternalEncoderMechanismVelocity()when the external (absolute) encoder is enabled withSmartMotorControllerConfig.withUseExternalFeedbackEncoder(boolean), otherwiseSmartMotorController.getRelativeMechanismVelocity().- Specified by:
getMechanismVelocityin classSmartMotorController- Returns:
- Mechanism
AngularVelocity
-
getMechanismAcceleration
public org.wpilib.units.measure.AngularAcceleration getMechanismAcceleration()Description copied from class:SmartMotorControllerGet the MechanismAngularAcceleration, calculating it on the robot controller if necessary by taking the derivative of the velocity.- Specified by:
getMechanismAccelerationin classSmartMotorController- Returns:
- Mechanism
AngularAcceleration
-
getMechanismPosition
public org.wpilib.units.measure.Angle getMechanismPosition()Description copied from class:SmartMotorControllerGet the mechanismAngletaking the configuredMechanismGearingfromSmartMotorControllerConfig. UsesSmartMotorController.getExternalEncoderMechanismPosition()when the external (absolute) encoder is enabled withSmartMotorControllerConfig.withUseExternalFeedbackEncoder(boolean), otherwiseSmartMotorController.getRelativeMechanismPosition().- Specified by:
getMechanismPositionin classSmartMotorController- Returns:
- Mechanism
Angle
-
getRelativeMechanismVelocity
public org.wpilib.units.measure.AngularVelocity getRelativeMechanismVelocity()Description copied from class:SmartMotorControllerGet the mechanismAngularVelocityfrom the relative encoder in the motor, scaled by the configuredMechanismGearing. Never uses the external (absolute) encoder.- Specified by:
getRelativeMechanismVelocityin classSmartMotorController- Returns:
- Mechanism
AngularVelocityfrom the relative encoder.
-
getRelativeMechanismPosition
public org.wpilib.units.measure.Angle getRelativeMechanismPosition()Description copied from class:SmartMotorControllerGet the mechanismAnglefrom the relative encoder in the motor, scaled by the configuredMechanismGearing. Never uses the external (absolute) encoder.- Specified by:
getRelativeMechanismPositionin classSmartMotorController- Returns:
- Mechanism
Anglefrom the relative encoder.
-
getRotorVelocity
public org.wpilib.units.measure.AngularVelocity getRotorVelocity()Description copied from class:SmartMotorControllerGets the angular velocity of the motor.- Specified by:
getRotorVelocityin classSmartMotorController- Returns:
AngularVelocityof the relative motor encoder.
-
getRotorPosition
public org.wpilib.units.measure.Angle getRotorPosition()Description copied from class:SmartMotorControllerGet the rotations of the motor with the relative encoder since the motor controller powered on scaled to the mechanism rotations.- Specified by:
getRotorPositionin classSmartMotorController- Returns:
Angleof the relative encoder in the motor.
-
getExternalEncoderMechanismPosition
Description copied from class:SmartMotorControllerGet the mechanismAnglefrom the external (absolute) encoder, scaled by the configured external encoderMechanismGearing. Available whether or not the external encoder is used for feedback.- Specified by:
getExternalEncoderMechanismPositionin classSmartMotorController- Returns:
- Mechanism
Anglefrom the external encoder, or empty if none is attached.
-
getExternalEncoderMechanismVelocity
Description copied from class:SmartMotorControllerGet the mechanismAngularVelocityfrom the external (absolute) encoder, scaled by the configured external encoderMechanismGearing. Available whether or not the external encoder is used for feedback.- Specified by:
getExternalEncoderMechanismVelocityin classSmartMotorController- Returns:
- Mechanism
AngularVelocityfrom the external encoder, or empty if none is attached.
-
setMotorInverted
public void setMotorInverted(boolean inverted) Description copied from class:SmartMotorControllerSet the inversion state of the motor.- Specified by:
setMotorInvertedin classSmartMotorController- Parameters:
inverted- Inverted motor.
-
setEncoderInverted
public void setEncoderInverted(boolean inverted) Set the phase of the encoder attached to the brushless motor.- Specified by:
setEncoderInvertedin classSmartMotorController- Parameters:
inverted- Phase of the encoder.- Throws:
UnsupportedOperationException- always, since the Thrifty Nova's internal encoder cannot be inverted.
-
setMotionProfileMaxVelocity
public void setMotionProfileMaxVelocity(org.wpilib.units.measure.LinearVelocity maxVelocity) Set the maximum velocity of the trapezoidal profile for the feedback controller.- Specified by:
setMotionProfileMaxVelocityin classSmartMotorController- Parameters:
maxVelocity- Maximum velocity, will be translated to MetersPerSecond.- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
setMotionProfileMaxAcceleration
public void setMotionProfileMaxAcceleration(org.wpilib.units.measure.LinearAcceleration maxAcceleration) Set the maximum acceleration of the trapezoidal profile for the feedback controller.- Specified by:
setMotionProfileMaxAccelerationin classSmartMotorController- Parameters:
maxAcceleration- Maximum acceleration, will be translated to MetersPerSecondPerSecond.- Throws:
SmartMotorControllerConfigurationException- if the mechanism circumference is not configured.
-
setMotionProfileMaxVelocity
public void setMotionProfileMaxVelocity(org.wpilib.units.measure.AngularVelocity maxVelocity) Description copied from class:SmartMotorControllerSet the maximum velocity for the trapezoidal profile for the feedback controller.- Specified by:
setMotionProfileMaxVelocityin classSmartMotorController- Parameters:
maxVelocity- Maximum velocity, will be translated to RotationsPerSecond.
-
setMotionProfileMaxAcceleration
public void setMotionProfileMaxAcceleration(org.wpilib.units.measure.AngularAcceleration maxAcceleration) Description copied from class:SmartMotorControllerSet the maximum acceleration for the trapezoidal profile for the feedback controller.- Specified by:
setMotionProfileMaxAccelerationin classSmartMotorController- Parameters:
maxAcceleration- Maximum acceleration, will be translated to RotationsPerSecondPerSecond.
-
setMotionProfileMaxJerk
public void setMotionProfileMaxJerk(org.wpilib.units.measure.Velocity<org.wpilib.units.AngularAccelerationUnit> maxJerk) Description copied from class:SmartMotorControllerSet the maximum jerk for the trapezoidal profile for the feedback controller.- Specified by:
setMotionProfileMaxJerkin classSmartMotorController- Parameters:
maxJerk- Maximum jerk, will be translated to RotationsPerSecondPerSecondPerSecond.
-
setExponentialProfile
public void setExponentialProfile(OptionalDouble kV, OptionalDouble kA, Optional<org.wpilib.units.measure.Voltage> maxInput) Description copied from class:SmartMotorControllerSet the exponential profile fields.- Specified by:
setExponentialProfilein classSmartMotorController- Parameters:
kV- kV for the exponential profile.kA- kA for the exponential profile.maxInput- Maximum input for the exponential profile.
-
setKp
public void setKp(double kP) Description copied from class:SmartMotorControllerSet kP for the feedback controller PID.- Specified by:
setKpin classSmartMotorController- Parameters:
kP- kP
-
setKi
public void setKi(double kI) Description copied from class:SmartMotorControllerSet kI for the feedback controller PID.- Specified by:
setKiin classSmartMotorController- Parameters:
kI- kI.
-
setKd
public void setKd(double kD) Description copied from class:SmartMotorControllerSet kD for the feedback controller PID.- Specified by:
setKdin classSmartMotorController- Parameters:
kD- kD for the feedback controller PID.
-
setFeedback
public void setFeedback(double kP, double kI, double kD) Description copied from class:SmartMotorControllerSet the closed loop feedback controller PID.- Specified by:
setFeedbackin classSmartMotorController- Parameters:
kP- kP; Proportional scalar.kI- kI; Integral scalar.kD- kD; derivative scalar.
-
setKs
public void setKs(double kS) Description copied from class:SmartMotorControllerStatic feedforward element.- Specified by:
setKsin classSmartMotorController- Parameters:
kS- kS; Static feedforward.
-
setKv
public void setKv(double kV) Description copied from class:SmartMotorControllerVelocity feedforward element.- Specified by:
setKvin classSmartMotorController- Parameters:
kV- kV; Velocity feedforward.
-
setKa
public void setKa(double kA) Description copied from class:SmartMotorControllerAcceleration feedforward element.- Specified by:
setKain classSmartMotorController- Parameters:
kA- kA; Acceleration feedforward.
-
setKg
public void setKg(double kG) Description copied from class:SmartMotorControllerkSin feedforward element.- Specified by:
setKgin classSmartMotorController- Parameters:
kG- kG; Gravity feedforward.
-
setFeedforward
public void setFeedforward(double kS, double kV, double kA, double kG) Description copied from class:SmartMotorControllerSet the feedforward controller.- Specified by:
setFeedforwardin classSmartMotorController- Parameters:
kS- kS; Static feedforward.kV- kV; Velocity feedforward.kA- kA; Acceleration feedforward.kG- kG; Gravity feedforward.
-
setStatorCurrentLimit
public void setStatorCurrentLimit(org.wpilib.units.measure.Current currentLimit) Description copied from class:SmartMotorControllerSet the stator current limit for the device.- Specified by:
setStatorCurrentLimitin classSmartMotorController- Parameters:
currentLimit- Stator current limit.
-
setSupplyCurrentLimit
public void setSupplyCurrentLimit(org.wpilib.units.measure.Current currentLimit) Description copied from class:SmartMotorControllerSet the supply current limit.- Specified by:
setSupplyCurrentLimitin classSmartMotorController- Parameters:
currentLimit- Supply current limit.
-
setClosedLoopRampRate
public void setClosedLoopRampRate(org.wpilib.units.measure.Time rampRate) Set the closed loop ramp rate. The ramp rate is how fast the motor can go from 0-100, measured in seconds.The Thrifty Nova has one ramp rate, for both open and closed loop control.
- Specified by:
setClosedLoopRampRatein classSmartMotorController- Parameters:
rampRate- Time from 0 to 100.
-
setOpenLoopRampRate
public void setOpenLoopRampRate(org.wpilib.units.measure.Time rampRate) Set the open loop ramp rate. The ramp rate is how fast the motor can go from 0 to 100, measured in Seconds.The Thrifty Nova has one ramp rate, for both open and closed loop control.
- Specified by:
setOpenLoopRampRatein classSmartMotorController- Parameters:
rampRate- Time it takes to go from 0 to 100.
-
setMeasurementUpperLimit
public void setMeasurementUpperLimit(org.wpilib.units.measure.Distance upperLimit) Set the measurement upper limit, only works if mechanism circumference is defined.- Specified by:
setMeasurementUpperLimitin classSmartMotorController- Parameters:
upperLimit- Upper limit, will be translated to meters.- Throws:
SmartMotorControllerConfigurationException- if a lower limit is configured and it is greater than or equal to the new upper limit.
-
setMeasurementLowerLimit
public void setMeasurementLowerLimit(org.wpilib.units.measure.Distance lowerLimit) Set the measurement lower limit, only works if mechanism circumference is defined.- Specified by:
setMeasurementLowerLimitin classSmartMotorController- Parameters:
lowerLimit- Lower limit, will be translated to meters.- Throws:
SmartMotorControllerConfigurationException- if an upper limit is configured and the new lower limit is greater than or equal to it.
-
setMechanismUpperLimit
public void setMechanismUpperLimit(org.wpilib.units.measure.Angle upperLimit) Set the mechanism upper limit.- Specified by:
setMechanismUpperLimitin classSmartMotorController- Parameters:
upperLimit- Upper limit, will be translated to rotations.- Throws:
SmartMotorControllerConfigurationException- if a lower limit is configured and it is greater than or equal to the new upper limit.
-
setMechanismLowerLimit
public void setMechanismLowerLimit(org.wpilib.units.measure.Angle lowerLimit) Set the mechanism lower limit.- Specified by:
setMechanismLowerLimitin classSmartMotorController- Parameters:
lowerLimit- Lower limit, will be translated to rotations.- Throws:
SmartMotorControllerConfigurationException- if an upper limit is configured and the new lower limit is greater than or equal to it.
-
setMechanismLimits
public void setMechanismLimits(org.wpilib.units.measure.Angle lower, org.wpilib.units.measure.Angle upper) Set the Mechanism limits for the motor controller.- Specified by:
setMechanismLimitsin classSmartMotorController- Parameters:
lower- Lower limit, will be translated to rotations.upper- Upper limit, will be translated to rotations.- Throws:
SmartMotorControllerConfigurationException- if both limits are non-null and the lower limit is greater than or equal to the upper limit.
-
setMechanismLimitsEnabled
public void setMechanismLimitsEnabled(boolean enabled) Description copied from class:SmartMotorControllerEnable or disable the mechanism/measurement limits in the motor controller.- Specified by:
setMechanismLimitsEnabledin classSmartMotorController- Parameters:
enabled- Application of the limits
-
setMechanismGearing
Description copied from class:SmartMotorControllerUpdate the mechanism gearing used for position/velocity conversions.- Specified by:
setMechanismGearingin classSmartMotorController- Parameters:
gearing- NewMechanismGearingto apply.
-
setMechanismCircumference
public void setMechanismCircumference(org.wpilib.units.measure.Distance circumference) Description copied from class:SmartMotorControllerUpdate the mechanism circumference used for linear position/velocity conversions.- Specified by:
setMechanismCircumferencein classSmartMotorController- Parameters:
circumference- New mechanism circumference.
-
setClosedLoopSlot
Description copied from class:SmartMotorControllerSet the closed loop controller slot to use.- Specified by:
setClosedLoopSlotin classSmartMotorController- Parameters:
slot- Slot to use.
-
getTemperature
public org.wpilib.units.measure.Temperature getTemperature()Description copied from class:SmartMotorControllerGet theSmartMotorControllertemperature.- Specified by:
getTemperaturein classSmartMotorController- Returns:
Temperature
-
getConfig
Description copied from class:SmartMotorControllerGet theSmartMotorControllerConfigfor theSmartMotorController- Specified by:
getConfigin classSmartMotorController- Returns:
SmartMotorControllerConfigused.
-
getMotorController
Description copied from class:SmartMotorControllerGet the Motor Controller Object passed into theSmartMotorController.- Specified by:
getMotorControllerin classSmartMotorController- Returns:
- Motor Controller object.
-
getMotorControllerConfig
Get the motor controller object config generated bySmartMotorControllerbased off theSmartMotorControllerConfig- Specified by:
getMotorControllerConfigin classSmartMotorController- Returns:
- The vendor config given to
SmartMotorControllerConfig.withVendorConfig(Object), or null without one. ThriftyLib configs are write-only actions; read the Nova's configuration back from((Nova) getMotorController()).status().
-
getUnsupportedTelemetryFields
public org.wpilib.util.Pair<Optional<List<SmartMotorControllerTelemetry.BooleanTelemetryField>>, Optional<List<SmartMotorControllerTelemetry.DoubleTelemetryField>>> getUnsupportedTelemetryFields()Description copied from class:SmartMotorControllerGet a list of unsupported telemetry fields if any exist.- Specified by:
getUnsupportedTelemetryFieldsin classSmartMotorController- Returns:
- Optional list of unsupported telemetry fields.
-