YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
yams::motorcontrollers::local::NovaWrapper Class Reference

#include <NovaWrapper.hpp>

Inheritance diagram for yams::motorcontrollers::local::NovaWrapper:
Collaboration diagram for yams::motorcontrollers::local::NovaWrapper:

Public Member Functions

 NovaWrapper (thrifty::Nova *nova, wpi::math::DCMotor motor, SmartMotorControllerConfig *config)
 ~NovaWrapper ()
bool ApplyConfig (const SmartMotorControllerConfig &config) override
void SetupSimulation () override
void SimIterate () override
void SeedRelativeEncoder () override
void SynchronizeRelativeEncoder () override
void SetDutyCycle (double dutyCycle) override
double GetDutyCycle () override
void SetVoltage (wpi::units::volt_t voltage) override
wpi::units::volt_t GetVoltage () override
void SetPosition (wpi::units::turn_t angle) override
void SetPosition (wpi::units::meter_t distance) override
void SetVelocity (wpi::units::turns_per_second_t velocity) override
void SetVelocity (wpi::units::turns_per_second_t velocity, wpi::units::newton_t feedforwardForce) override
void SetVelocity (wpi::units::meters_per_second_t velocity) override
void SetEncoderPosition (wpi::units::turn_t angle) override
void SetEncoderPosition (wpi::units::meter_t distance) override
void SetEncoderVelocity (wpi::units::turns_per_second_t velocity) override
void SetEncoderVelocity (wpi::units::meters_per_second_t velocity) override
wpi::units::turn_t GetMechanismPosition () override
wpi::units::turns_per_second_t GetMechanismVelocity () override
wpi::units::turn_t GetRelativeMechanismPosition () override
wpi::units::turns_per_second_t GetRelativeMechanismVelocity () override
wpi::units::turns_per_second_squared_t GetMechanismAcceleration () override
wpi::units::turn_t GetRotorPosition () override
wpi::units::turns_per_second_t GetRotorVelocity () override
wpi::units::meter_t GetMeasurementPosition () override
wpi::units::meters_per_second_t GetMeasurementVelocity () override
wpi::units::meters_per_second_squared_t GetMeasurementAcceleration () override
std::optional< wpi::units::turn_t > GetExternalEncoderMechanismPosition () override
std::optional< wpi::units::turns_per_second_t > GetExternalEncoderMechanismVelocity () override
std::optional< wpi::units::ampere_t > GetSupplyCurrent () override
wpi::units::ampere_t GetStatorCurrent () override
wpi::units::celsius_t GetTemperature () override
wpi::math::DCMotor GetDCMotor () override
void SetZeroPower (MotorMode mode) override
void SetMotorInverted (bool inverted) override
void SetEncoderInverted (bool inverted) override
void SetKp (double kP) override
void SetKi (double kI) override
void SetKd (double kD) override
void SetFeedback (double kP, double kI, double kD) override
void SetKs (double kS) override
void SetKv (double kV) override
void SetKa (double kA) override
void SetKg (double kG) override
void SetFeedforward (double kS, double kV, double kA, double kG) override
void SetStatorCurrentLimit (wpi::units::ampere_t currentLimit) override
void SetSupplyCurrentLimit (wpi::units::ampere_t currentLimit) override
void SetClosedLoopRampRate (wpi::units::second_t rampRate) override
void SetOpenLoopRampRate (wpi::units::second_t rampRate) override
void SetMechanismUpperLimit (wpi::units::turn_t upperLimit) override
void SetMechanismLowerLimit (wpi::units::turn_t lowerLimit) override
void SetMechanismLimits (wpi::units::turn_t lower, wpi::units::turn_t upper) override
void SetMechanismLimitsEnabled (bool enabled) override
void SetMeasurementUpperLimit (wpi::units::meter_t upperLimit) override
void SetMeasurementLowerLimit (wpi::units::meter_t lowerLimit) override
void SetMotionProfileMaxVelocity (wpi::units::turns_per_second_t maxVelocity) override
void SetMotionProfileMaxVelocity (wpi::units::meters_per_second_t maxVelocity) override
void SetMotionProfileMaxAcceleration (wpi::units::turns_per_second_squared_t maxAcc) override
void SetMotionProfileMaxAcceleration (wpi::units::meters_per_second_squared_t maxAcc) override
void SetMotionProfileMaxJerk (wpi::units::angular_jerk::turns_per_second_cubed_t maxJerk) override
void SetExponentialProfile (std::optional< double > kV, std::optional< double > kA, std::optional< wpi::units::volt_t > maxInput) override
void SetClosedLoopSlot (ClosedLoopControllerSlot slot) override
void SetMechanismGearing (const gearing::MechanismGearing &gearing) override
void SetMechanismCircumference (wpi::units::meter_t circumference) override
SmartMotorControllerConfig & GetConfig () override
void * GetMotorController () override
void * GetMotorControllerConfig () override
void SetSimSupplier (std::shared_ptr< SimSupplier > supplier) override
void SetVelocity (wpi::units::meters_per_second_t velocity, wpi::units::newton_t feedforwardForce)
Public Member Functions inherited from yams::motorcontrollers::SmartMotorController
virtual ~SmartMotorController ()
SimSupplier * GetSimSupplier () const
void SetVelocity (wpi::units::meters_per_second_t velocity, wpi::units::newton_t feedforwardForce)
wpi::math::DCMotor GetMechanismDCMotor ()
void SetMechanismSimSupplier (std::shared_ptr< SimSupplier > supplier)
double GetMechanismDutyCycle (double dutyCycle)
wpi::units::second_t GetClosedLoopControllerPeriod () const
virtual std::optional< wpi::units::second_t > GetVelocityMeasurementDelay () const
void StartClosedLoopController ()
void StopClosedLoopController ()
bool IsClosedLoopControllerStopped () const
math::LQRController * GetLQRController ()
math::ADRCController * GetADRCController ()
void IterateClosedLoopController ()
void SetupTelemetry (std::shared_ptr< wpi::nt::NetworkTable > dataTable, std::shared_ptr< wpi::nt::NetworkTable > tuningTable)
void SetupTelemetry ()
void SetupLiveTuning ()
void UpdateTelemetry ()
bool TuningEnabled () const
void ApplyTuningValues ()
void StopLiveTuning ()
const std::vector< SmartMotorController * > & GetLooselyCoupledFollowers () const
void AddCloseHook (std::function< void()> hook)
SmartMotorController & WithTelemetry (telemetry::SmartMotorControllerTelemetryConfig config)
virtual telemetry::UnsupportedTelemetryFields GetUnsupportedTelemetryFields ()
ClosedLoopControllerSlot GetClosedLoopControllerSlot () const
std::optional< wpi::units::turn_t > GetMechanismPositionSetpoint () const
std::optional< wpi::units::turns_per_second_t > GetMechanismSetpointVelocity () const
std::optional< wpi::units::meter_t > GetMeasurementPositionSetpoint () const
std::optional< wpi::units::meters_per_second_t > GetMeasurementSetpointVelocity () const
std::optional< wpi::units::newton_t > GetSetpointFeedforwardForce () const
std::string GetName () const
bool IsMotor (const wpi::math::DCMotor &a, const wpi::math::DCMotor &b) const
void CheckConfigSafety ()
void Close ()

Additional Inherited Members

Public Types inherited from yams::motorcontrollers::SmartMotorController
using ClosedLoopControllerSlot = SmartMotorControllerConfig::ClosedLoopControllerSlot
using MotorMode = SmartMotorControllerConfig::MotorMode
using ControlMode = SmartMotorControllerConfig::ControlMode
Protected Member Functions inherited from yams::motorcontrollers::SmartMotorController
 SmartMotorController ()
void LoadLooselyCoupledFollowers ()
void Follow (SmartMotorController &leader, bool inverted)
double CalculateSimDutyCycle (double dutyCycle)
void ConfigureSoftwarePID (const SmartMotorControllerConfig &config)
void ForwardPositionToFollowers (wpi::units::turn_t pos)
void ForwardPositionToFollowers (wpi::units::meter_t dist)
void ForwardVelocityToFollowers (wpi::units::turns_per_second_t vel)
void ForwardVelocityToFollowers (wpi::units::meters_per_second_t vel)
bool UsesSystemCoreController () const
void ApplyADRCConfig (const SmartMotorControllerConfig &config)
const void * BatterySimKey () const
Protected Attributes inherited from yams::motorcontrollers::SmartMotorController
SmartMotorControllerConfig * m_config {nullptr}
ClosedLoopControllerSlot m_slot {ClosedLoopControllerSlot::SLOT_0}
std::shared_ptr< SimSupplier > m_simSupplier
std::vector< SmartMotorController * > m_looseFollowers
bool m_iteratedByLeader {false}
bool m_simulatesMechanism {false}
std::optional< wpi::math::PIDController > m_pid
std::optional< math::LQRController > m_lqr
std::optional< math::ADRCController > m_adrc
std::optional< wpi::math::TrapezoidProfile< wpi::units::turns >::State > m_trapState
std::optional< wpi::math::ExponentialProfile< wpi::units::turns, wpi::units::volts >::State > m_expoState
std::optional< wpi::math::TrapezoidProfile< wpi::units::meters >::State > m_linearTrapState
std::optional< wpi::math::ExponentialProfile< wpi::units::meters, wpi::units::volts >::State > m_linearExpoState
std::optional< wpi::units::turn_t > m_lastClosedLoopMechanismPosition
std::optional< double > m_lastClosedLoopVoltage
std::optional< wpi::units::turn_t > m_setpointPosition
std::optional< wpi::units::turns_per_second_t > m_setpointVelocity
std::optional< wpi::units::newton_t > m_setpointFeedforwardForce
std::vector< std::function< void()> > m_closeHooks
std::unique_ptr< wpi::Notifier > m_closedLoopControllerThread
bool m_closedLoopControllerRunning {false}
std::shared_ptr< wpi::nt::NetworkTable > m_parentTable
std::shared_ptr< wpi::nt::NetworkTable > m_telemetryTable
std::shared_ptr< wpi::nt::NetworkTable > m_tuningTable
telemetry::SmartMotorControllerTelemetry m_telemetry
telemetry::SmartMotorControllerTelemetryConfig m_telemetryConfig
bool m_telemetryConfigExplicit {false}
std::shared_ptr< telemetry::SmartMotorControllerTelemetryConfig > m_specifiedTelemetryConfig
bool m_liveTuningRegistered {false}
bool m_closed {false}
Static Protected Attributes inherited from yams::motorcontrollers::SmartMotorController
static constexpr double kClosedLoopRampFullScaleVolts = 12.0

Detailed Description

SmartMotorController implementation for The Thrifty Bot's Thrifty Nova, using ThriftyLib 2027.

The closed loop runs on the Nova: its voltage position and velocity loops with the slot's PID gains, and, with a trapezoidal profile, its motion profile, with the motion profile slot's kS, kV, kA and kG and a constant or cosine gravity. The Nova applies a feedforward only with a motion profile, so a feedforward needs a trapezoidal profile. An LQR, an exponential profile and a velocity trapezoidal profile run on the SystemCore instead, and command the Nova with voltage. The Nova has two closed loop slots, SLOT_0 and SLOT_1. ThriftyLib's simulation ignores the Nova's closed loop, so in simulation a NovaSimSupplier runs it.

Supported external encoders (WithExternalEncoder):

  • thrifty::Motor::FeedbackSensorType::ABS: an absolute encoder on the Nova's data port. Its type comes from the vendor config, such as thrifty::NovaConfig::AbsoluteEncoderType(thrifty::Motor::AbsoluteEncoderType::REV_ENCODER).
  • thrifty::Motor::FeedbackSensorType::QUAD: a quadrature encoder on the Nova's data port. Its type comes from the vendor config, such as thrifty::NovaConfig::QuadratureEncoderType(thrifty::Motor::QuadratureEncoderType::Custom(2048)).
  • thrifty::CanEncoder*: a Thrifty CAN Encoder on the same CAN bus.

An absolute or CAN external encoder reads the continuous wrapping range, or [0, 1) without continuous wrapping; the Nova closes its loop on one over [0, 1) only.

The vendor config, if any, must be a thrifty::NovaConfigBatch; it is applied before the YAMS config, which overrides it.

Example usage (inside a subsystem constructor)

using namespace yams::motorcontrollers;
// Declare as subsystem members:
// thrifty::Nova m_nova{0, 3, thrifty::Motor::NEO};
// SmartMotorControllerConfig m_cfg;
// std::optional<NovaWrapper> m_smc;
m_cfg.WithSubsystem(this)
.WithFeedback(1.0, 0.0, 0.0)
.WithStatorCurrentLimit(40.0_A)
.WithMotorInverted(false)
.WithVendorConfig(thrifty::NovaConfigBatch{thrifty::NovaConfig::TempThrottleEnable(true)})
.WithClosedLoopMode()
m_smc.emplace(&m_nova, wpi::math::DCMotor::NEO(1), &m_cfg);
Definition A301Wrapper.hpp:17
Definition ADRCConfig.hpp:20

Constructor & Destructor Documentation

◆ NovaWrapper()

yams::motorcontrollers::local::NovaWrapper::NovaWrapper ( thrifty::Nova * nova,
wpi::math::DCMotor motor,
SmartMotorControllerConfig * config )

Construct a NovaWrapper around a Thrifty Nova.

Parameters
novaPointer to the Nova hardware object (must outlive this wrapper).
motorDC motor model used for simulation.
configPointer to the SmartMotorControllerConfig (must outlive this wrapper).

◆ ~NovaWrapper()

yams::motorcontrollers::local::NovaWrapper::~NovaWrapper ( )

Member Function Documentation

◆ ApplyConfig()

bool yams::motorcontrollers::local::NovaWrapper::ApplyConfig ( const SmartMotorControllerConfig & config)
overridevirtual

Apply a SmartMotorControllerConfig to the underlying hardware.

Parameters
configConfiguration to apply.
Returns
true if the configuration was applied successfully.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetConfig()

SmartMotorControllerConfig & yams::motorcontrollers::local::NovaWrapper::GetConfig ( )
overridevirtual

Get a mutable reference to the current configuration.

Returns
Reference to the SmartMotorControllerConfig.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetDCMotor()

wpi::math::DCMotor yams::motorcontrollers::local::NovaWrapper::GetDCMotor ( )
overridevirtual

Get the DC motor model associated with this controller.

Returns
wpi::math::DCMotor model.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetDutyCycle()

double yams::motorcontrollers::local::NovaWrapper::GetDutyCycle ( )
overridevirtual

Get the current motor duty cycle.

Returns
Duty cycle in [-1, 1].

Implements yams::motorcontrollers::SmartMotorController.

◆ GetExternalEncoderMechanismPosition()

std::optional< wpi::units::turn_t > yams::motorcontrollers::local::NovaWrapper::GetExternalEncoderMechanismPosition ( )
overridevirtual

Get the mechanism position from the external (absolute) encoder (applies the external encoder gearing). Available whether or not the external encoder is used for feedback.

Returns
Mechanism position in turns from the external encoder, or empty if none is attached.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetExternalEncoderMechanismVelocity()

std::optional< wpi::units::turns_per_second_t > yams::motorcontrollers::local::NovaWrapper::GetExternalEncoderMechanismVelocity ( )
overridevirtual

Get the mechanism velocity from the external (absolute) encoder (applies the external encoder gearing). Available whether or not the external encoder is used for feedback.

Returns
Mechanism velocity in turns per second from the external encoder, or empty if none is attached.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementAcceleration()

wpi::units::meters_per_second_squared_t yams::motorcontrollers::local::NovaWrapper::GetMeasurementAcceleration ( )
overridevirtual

Get the linear measurement acceleration.

Returns
Linear acceleration in meters per second squared.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementPosition()

wpi::units::meter_t yams::motorcontrollers::local::NovaWrapper::GetMeasurementPosition ( )
overridevirtual

Get the linear measurement position (applies circumference conversion).

Returns
Linear position in meters.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMeasurementVelocity()

wpi::units::meters_per_second_t yams::motorcontrollers::local::NovaWrapper::GetMeasurementVelocity ( )
overridevirtual

Get the linear measurement velocity (applies circumference conversion).

Returns
Linear velocity in meters per second.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismAcceleration()

wpi::units::turns_per_second_squared_t yams::motorcontrollers::local::NovaWrapper::GetMechanismAcceleration ( )
overridevirtual

Get the mechanism acceleration (derived from velocity).

Returns
Mechanism acceleration in turns per second squared.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismPosition()

wpi::units::turn_t yams::motorcontrollers::local::NovaWrapper::GetMechanismPosition ( )
overridevirtual

Get the mechanism position (applies gearing). Uses the external (absolute) encoder when one is configured with SmartMotorControllerConfig::WithUseExternalFeedbackEncoder(), otherwise the relative encoder. Use GetRelativeMechanismPosition() to only read the relative encoder.

Returns
Mechanism position in turns.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMechanismVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::local::NovaWrapper::GetMechanismVelocity ( )
overridevirtual

Get the mechanism velocity (applies gearing). Uses the external (absolute) encoder when one is configured with SmartMotorControllerConfig::WithUseExternalFeedbackEncoder(), otherwise the relative encoder. Use GetRelativeMechanismVelocity() to only read the relative encoder.

Returns
Mechanism velocity in turns per second.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMotorController()

void * yams::motorcontrollers::local::NovaWrapper::GetMotorController ( )
overridevirtual

Get a raw pointer to the underlying Nova.

Returns
Pointer to the thrifty::Nova instance.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetMotorControllerConfig()

void * yams::motorcontrollers::local::NovaWrapper::GetMotorControllerConfig ( )
overridevirtual

Get a raw pointer to the vendor config given to WithVendorConfig().

ThriftyLib configs are write-only actions; read the Nova's configuration back from thrifty::Nova::Status().

Returns
Pointer to the thrifty::NovaConfigBatch, or nullptr without one.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRelativeMechanismPosition()

wpi::units::turn_t yams::motorcontrollers::local::NovaWrapper::GetRelativeMechanismPosition ( )
overridevirtual

Get the mechanism position from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.

Returns
Mechanism position in turns from the relative encoder.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRelativeMechanismVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::local::NovaWrapper::GetRelativeMechanismVelocity ( )
overridevirtual

Get the mechanism velocity from the relative encoder in the motor (applies gearing). Never uses the external (absolute) encoder.

Returns
Mechanism velocity in turns per second from the relative encoder.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRotorPosition()

wpi::units::turn_t yams::motorcontrollers::local::NovaWrapper::GetRotorPosition ( )
overridevirtual

Get the raw rotor position (no gearing applied).

Returns
Rotor position in turns.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetRotorVelocity()

wpi::units::turns_per_second_t yams::motorcontrollers::local::NovaWrapper::GetRotorVelocity ( )
overridevirtual

Get the raw rotor velocity (no gearing applied).

Returns
Rotor velocity in turns per second.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetStatorCurrent()

wpi::units::ampere_t yams::motorcontrollers::local::NovaWrapper::GetStatorCurrent ( )
overridevirtual

Get the stator (output) current draw.

Returns
Stator current.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetSupplyCurrent()

std::optional< wpi::units::ampere_t > yams::motorcontrollers::local::NovaWrapper::GetSupplyCurrent ( )
overridevirtual

Get the supply (input) current draw.

Returns
Supply current, or empty if not supported by the hardware.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetTemperature()

wpi::units::celsius_t yams::motorcontrollers::local::NovaWrapper::GetTemperature ( )
overridevirtual

Get the motor controller temperature.

Returns
Temperature in degrees Celsius.

Implements yams::motorcontrollers::SmartMotorController.

◆ GetVoltage()

wpi::units::volt_t yams::motorcontrollers::local::NovaWrapper::GetVoltage ( )
overridevirtual

Get the voltage currently applied to the motor.

Returns
Applied voltage.

Implements yams::motorcontrollers::SmartMotorController.

◆ SeedRelativeEncoder()

void yams::motorcontrollers::local::NovaWrapper::SeedRelativeEncoder ( )
overridevirtual

Seed the relative encoder from the absolute sensor position (one-shot on startup).

Implements yams::motorcontrollers::SmartMotorController.

◆ SetClosedLoopRampRate()

void yams::motorcontrollers::local::NovaWrapper::SetClosedLoopRampRate ( wpi::units::second_t rampRate)
overridevirtual

The Nova has one ramp rate, for both open and closed loop control.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetClosedLoopSlot()

void yams::motorcontrollers::local::NovaWrapper::SetClosedLoopSlot ( ClosedLoopControllerSlot slot)
overridevirtual

Select the active closed-loop gain slot.

Parameters
slotGain slot to activate.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetDutyCycle()

void yams::motorcontrollers::local::NovaWrapper::SetDutyCycle ( double dutyCycle)
overridevirtual

Command a duty-cycle output to the motor.

Parameters
dutyCycleNormalized duty cycle in [-1, 1].

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderInverted()

void yams::motorcontrollers::local::NovaWrapper::SetEncoderInverted ( bool inverted)
overridevirtual

The Nova's internal encoder cannot be inverted; always throws std::runtime_error.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderPosition() [1/2]

void yams::motorcontrollers::local::NovaWrapper::SetEncoderPosition ( wpi::units::meter_t distance)
overridevirtual

Write a linear distance into the encoder (seeds the position).

Parameters
distanceLinear distance to write.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderPosition() [2/2]

void yams::motorcontrollers::local::NovaWrapper::SetEncoderPosition ( wpi::units::turn_t angle)
overridevirtual

Write a mechanism angle into the encoder (seeds the position).

Parameters
angleMechanism angle to write.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderVelocity() [1/2]

void yams::motorcontrollers::local::NovaWrapper::SetEncoderVelocity ( wpi::units::meters_per_second_t velocity)
overridevirtual

Linear version of SetEncoderVelocity(turns_per_second_t); throws without a mechanism circumference.

Parameters
velocityMechanism linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetEncoderVelocity() [2/2]

void yams::motorcontrollers::local::NovaWrapper::SetEncoderVelocity ( wpi::units::turns_per_second_t velocity)
overridevirtual

Set the simulated mechanism velocity. Throws std::runtime_error outside of simulation, since Thrifty Novas do not support setting the encoder velocity.

Parameters
velocityMechanism velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetExponentialProfile()

void yams::motorcontrollers::local::NovaWrapper::SetExponentialProfile ( std::optional< double > kV,
std::optional< double > kA,
std::optional< wpi::units::volt_t > maxInput )
overridevirtual

Update the exponential profile. Missing values keep the configured ones.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetFeedback()

void yams::motorcontrollers::local::NovaWrapper::SetFeedback ( double kP,
double kI,
double kD )
overridevirtual

Set all three PID feedback gains at once (live update).

Parameters
kPProportional gain.
kIIntegral gain.
kDDerivative gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetFeedforward()

void yams::motorcontrollers::local::NovaWrapper::SetFeedforward ( double kS,
double kV,
double kA,
double kG )
overridevirtual

Set all four feedforward gains at once (live update).

Parameters
kSStatic friction voltage.
kVVelocity feedforward coefficient.
kAAcceleration feedforward coefficient.
kGGravity feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKa()

void yams::motorcontrollers::local::NovaWrapper::SetKa ( double kA)
overridevirtual

Set the acceleration feedforward coefficient (live update).

Parameters
kAAcceleration feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKd()

void yams::motorcontrollers::local::NovaWrapper::SetKd ( double kD)
overridevirtual

Set the derivative gain (live update).

Parameters
kDDerivative gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKg()

void yams::motorcontrollers::local::NovaWrapper::SetKg ( double kG)
overridevirtual

Set the gravity feedforward coefficient (live update).

Parameters
kGGravity feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKi()

void yams::motorcontrollers::local::NovaWrapper::SetKi ( double kI)
overridevirtual

Set the integral gain (live update).

Parameters
kIIntegral gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKp()

void yams::motorcontrollers::local::NovaWrapper::SetKp ( double kP)
overridevirtual

Set the proportional gain (live update).

Parameters
kPProportional gain.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKs()

void yams::motorcontrollers::local::NovaWrapper::SetKs ( double kS)
overridevirtual

Set the static friction feedforward (live update).

Parameters
kSStatic friction voltage.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetKv()

void yams::motorcontrollers::local::NovaWrapper::SetKv ( double kV)
overridevirtual

Set the velocity feedforward coefficient (live update).

Parameters
kVVelocity feedforward coefficient.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMeasurementLowerLimit()

void yams::motorcontrollers::local::NovaWrapper::SetMeasurementLowerLimit ( wpi::units::meter_t lowerLimit)
overridevirtual

Set the lower linear soft limit for the measurement.

Parameters
lowerLimitLower distance limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMeasurementUpperLimit()

void yams::motorcontrollers::local::NovaWrapper::SetMeasurementUpperLimit ( wpi::units::meter_t upperLimit)
overridevirtual

Set the upper linear soft limit for the measurement.

Parameters
upperLimitUpper distance limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismCircumference()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismCircumference ( wpi::units::meter_t circumference)
overridevirtual

Update the mechanism circumference used for linear position/velocity conversions.

The base implementation updates the config; wrappers override it to also reconfigure the hardware.

Parameters
circumferenceNew mechanism circumference.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetMechanismGearing()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismGearing ( const gearing::MechanismGearing & gearing)
overridevirtual

Update the mechanism gearing and rebuild the simulated motor, which depends on it.

Parameters
gearingNew mechanism gearing.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLimits()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismLimits ( wpi::units::turn_t lower,
wpi::units::turn_t upper )
overridevirtual

Set both angular soft limits for the mechanism.

Parameters
lowerLower angle limit.
upperUpper angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLimitsEnabled()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismLimitsEnabled ( bool enabled)
overridevirtual

The closed loop controller on the SystemCore enforces the mechanism limits.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismLowerLimit()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismLowerLimit ( wpi::units::turn_t lowerLimit)
overridevirtual

Set the lower angular soft limit for the mechanism.

Parameters
lowerLimitLower angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMechanismUpperLimit()

void yams::motorcontrollers::local::NovaWrapper::SetMechanismUpperLimit ( wpi::units::turn_t upperLimit)
overridevirtual

Set the upper angular soft limit for the mechanism.

Parameters
upperLimitUpper angle limit.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxAcceleration() [1/2]

void yams::motorcontrollers::local::NovaWrapper::SetMotionProfileMaxAcceleration ( wpi::units::meters_per_second_squared_t maxAcc)
overridevirtual

Set the maximum linear acceleration for the motion profile.

Parameters
maxAccMaximum linear acceleration.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxAcceleration() [2/2]

void yams::motorcontrollers::local::NovaWrapper::SetMotionProfileMaxAcceleration ( wpi::units::turns_per_second_squared_t maxAcc)
overridevirtual

Set the maximum angular acceleration for the motion profile.

Parameters
maxAccMaximum mechanism angular acceleration.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxJerk()

void yams::motorcontrollers::local::NovaWrapper::SetMotionProfileMaxJerk ( wpi::units::angular_jerk::turns_per_second_cubed_t maxJerk)
overridevirtual

Set the maximum jerk of a velocity trapezoidal profile (its acceleration constraint). Has no effect on position profiles.

Parameters
maxJerkMaximum angular jerk.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxVelocity() [1/2]

void yams::motorcontrollers::local::NovaWrapper::SetMotionProfileMaxVelocity ( wpi::units::meters_per_second_t maxVelocity)
overridevirtual

Set the maximum linear velocity for the motion profile.

Parameters
maxVelocityMaximum linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotionProfileMaxVelocity() [2/2]

void yams::motorcontrollers::local::NovaWrapper::SetMotionProfileMaxVelocity ( wpi::units::turns_per_second_t maxVelocity)
overridevirtual

Set the maximum angular velocity for the motion profile.

Parameters
maxVelocityMaximum mechanism angular velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetMotorInverted()

void yams::motorcontrollers::local::NovaWrapper::SetMotorInverted ( bool inverted)
overridevirtual

Set the motor output direction.

Parameters
invertedtrue to invert the motor direction.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetOpenLoopRampRate()

void yams::motorcontrollers::local::NovaWrapper::SetOpenLoopRampRate ( wpi::units::second_t rampRate)
overridevirtual

The Nova has one ramp rate, for both open and closed loop control.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetPosition() [1/2]

void yams::motorcontrollers::local::NovaWrapper::SetPosition ( wpi::units::meter_t distance)
overridevirtual

Command a linear measurement position setpoint (closed-loop).

Parameters
distanceTarget linear distance.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetPosition() [2/2]

void yams::motorcontrollers::local::NovaWrapper::SetPosition ( wpi::units::turn_t angle)
overridevirtual

Command a mechanism angle position setpoint (closed-loop).

Parameters
angleTarget mechanism angle.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetSimSupplier()

void yams::motorcontrollers::local::NovaWrapper::SetSimSupplier ( std::shared_ptr< SimSupplier > supplier)
overridevirtual

Attach the mechanism's SimSupplier, driven by a simulated Nova, which runs the Nova's closed loop as ThriftyLib's simulation does not.

Parameters
supplierMechanism's SimSupplier, or nullptr to detach.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetStatorCurrentLimit()

void yams::motorcontrollers::local::NovaWrapper::SetStatorCurrentLimit ( wpi::units::ampere_t currentLimit)
overridevirtual

Set the stator (output) current limit.

Parameters
currentLimitMaximum stator current.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetSupplyCurrentLimit()

void yams::motorcontrollers::local::NovaWrapper::SetSupplyCurrentLimit ( wpi::units::ampere_t currentLimit)
overridevirtual

Set the supply (input) current limit.

Parameters
currentLimitMaximum supply current.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetupSimulation()

void yams::motorcontrollers::local::NovaWrapper::SetupSimulation ( )
overridevirtual

Initialize the DCMotorSim used for simulation.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [1/4]

void yams::motorcontrollers::local::NovaWrapper::SetVelocity ( wpi::units::meters_per_second_t velocity)
overridevirtual

Command a linear measurement velocity setpoint (closed-loop).

Parameters
velocityTarget linear velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [2/4]

void yams::motorcontrollers::SmartMotorController::SetVelocity ( wpi::units::meters_per_second_t velocity,
wpi::units::newton_t feedforwardForce )

Command a linear velocity setpoint with an additional feedforward force applied on top.

Throws SmartMotorControllerConfigurationException if the mechanism circumference is not configured.

Parameters
velocityTarget linear velocity.
feedforwardForceAdditional feedforward force at the mechanism.

◆ SetVelocity() [3/4]

void yams::motorcontrollers::local::NovaWrapper::SetVelocity ( wpi::units::turns_per_second_t velocity)
overridevirtual

Command a mechanism angular velocity setpoint (closed-loop).

Parameters
velocityTarget mechanism angular velocity.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetVelocity() [4/4]

void yams::motorcontrollers::local::NovaWrapper::SetVelocity ( wpi::units::turns_per_second_t velocity,
wpi::units::newton_t feedforwardForce )
overridevirtual

Command a velocity setpoint with an additional feedforward force, added by the SystemCore closed loop.

Parameters
velocityTarget mechanism angular velocity.
feedforwardForceAdditional feedforward force at the mechanism.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SetVoltage()

void yams::motorcontrollers::local::NovaWrapper::SetVoltage ( wpi::units::volt_t voltage)
overridevirtual

Command a voltage output to the motor.

Parameters
voltageVoltage to apply.

Implements yams::motorcontrollers::SmartMotorController.

◆ SetZeroPower()

void yams::motorcontrollers::local::NovaWrapper::SetZeroPower ( MotorMode mode)
overridevirtual

Set the idle (neutral) mode of the motor.

Parameters
modeCOAST or BRAKE.

Implements yams::motorcontrollers::SmartMotorController.

◆ SimIterate()

void yams::motorcontrollers::local::NovaWrapper::SimIterate ( )
overridevirtual

Advance the motor simulation by one loop iteration. Each motor controller's SimIterate() calls this last, with SmartMotorController::SimIterate(): it iterates the loosely coupled followers reading this motor controller's mechanism's simulation, which a mechanism steps right before. Each follower's iterates its own.

Reimplemented from yams::motorcontrollers::SmartMotorController.

◆ SynchronizeRelativeEncoder()

void yams::motorcontrollers::local::NovaWrapper::SynchronizeRelativeEncoder ( )
overridevirtual

Periodically re-synchronize the relative encoder to the absolute sensor.

Implements yams::motorcontrollers::SmartMotorController.


The documentation for this class was generated from the following file:
  • /home/runner/work/YAMS/YAMS/yams/cpp/include/yams/motorcontrollers/local/NovaWrapper.hpp