|
YAMS
Yet Another Mechanism System
|
#include <SwerveModule.hpp>

Public Member Functions | |
| SwerveModule (config::SwerveModuleConfig *config) | |
| void | SetupTelemetry (const std::string &mechName) |
| void | SeedAzimuthEncoder () |
| std::string | GetName () const |
| wpi::units::degree_t | GetRawAbsoluteEncoderAngle () const |
| const config::SwerveModuleConfig & | GetConfig () const |
| wpi::math::SwerveModuleVelocity | SetSwerveModuleState (wpi::math::SwerveModuleVelocity state) |
| wpi::math::SwerveModuleVelocity | SetSwerveModuleState (wpi::math::SwerveModuleVelocity state, wpi::units::newton_t feedforwardForce) |
| config::SwerveModuleConfig & | GetMutableConfig () |
| wpi::math::SwerveModuleVelocity | SetAzimuthAngle (wpi::math::Rotation2d angle) |
| SwerveModuleVelocityWithAzimuth | GetState () const |
| wpi::math::SwerveModulePosition | GetPosition () const |
| void | UpdateTelemetry () |
| void | SimIterate () |
| motorcontrollers::SmartMotorController * | GetDriveMotorController () const |
| motorcontrollers::SmartMotorController * | GetAzimuthMotorController () const |
| wpi::units::meters_per_second_t | GetCouplingVelocity () const |
Public Attributes | |
| motorcontrollers::SmartMotorController * | m_driveMotorController |
| motorcontrollers::SmartMotorController * | m_azimuthMotorController |
A single swerve module comprising a drive motor and an azimuth (steering) motor.
Each module holds references to two SmartMotorControllers (drive and azimuth) and a SwerveModuleConfig that describes its physical properties and absolute encoder. Modules are normally owned by the subsystem and handed to SwerveDrive by pointer.
|
explicit |
Construct a SwerveModule from a SwerveModuleConfig.
| config | Module configuration. Must contain a telemetry name and a location. |
| std::invalid_argument | if telemetry name or location is not set. |
| motorcontrollers::SmartMotorController * yams::mechanisms::swerve::SwerveModule::GetAzimuthMotorController | ( | ) | const |
Get the azimuth motor controller.
| const config::SwerveModuleConfig & yams::mechanisms::swerve::SwerveModule::GetConfig | ( | ) | const |
Get the module configuration.
| wpi::units::meters_per_second_t yams::mechanisms::swerve::SwerveModule::GetCouplingVelocity | ( | ) | const |
Wheel velocity the drive encoder reads because the azimuth is turning.
| motorcontrollers::SmartMotorController * yams::mechanisms::swerve::SwerveModule::GetDriveMotorController | ( | ) | const |
Get the drive motor controller.
| config::SwerveModuleConfig & yams::mechanisms::swerve::SwerveModule::GetMutableConfig | ( | ) |
Get the module config for changing it, as WithModuleStateOptimization does.
| std::string yams::mechanisms::swerve::SwerveModule::GetName | ( | ) | const |
Get the module name (from telemetry config).
| wpi::math::SwerveModulePosition yams::mechanisms::swerve::SwerveModule::GetPosition | ( | ) | const |
Get the current measured module position (distance and heading).
| wpi::units::degree_t yams::mechanisms::swerve::SwerveModule::GetRawAbsoluteEncoderAngle | ( | ) | const |
Get the absolute encoder angle without any offsets applied.
| SwerveModuleVelocityWithAzimuth yams::mechanisms::swerve::SwerveModule::GetState | ( | ) | const |
Get the current measured module state (speed and heading).
| void yams::mechanisms::swerve::SwerveModule::SeedAzimuthEncoder | ( | ) |
Seed the azimuth encoder from the absolute encoder reading (real robot only).
| wpi::math::SwerveModuleVelocity yams::mechanisms::swerve::SwerveModule::SetAzimuthAngle | ( | wpi::math::Rotation2d | angle | ) |
Turn the wheel to the given angle without driving it, as for locking the drive in place or tuning the azimuth motor. The velocity deadband is skipped, since it would hold the wheel where it is.
| angle | Angle to turn the wheel to. |
| wpi::math::SwerveModuleVelocity yams::mechanisms::swerve::SwerveModule::SetSwerveModuleState | ( | wpi::math::SwerveModuleVelocity | state | ) |
Command the module to a target state.
Applies optimization (direction flip, velocity deadband, cosine compensation) before setting drive velocity and azimuth position.
| state | Target module state. |
| wpi::math::SwerveModuleVelocity yams::mechanisms::swerve::SwerveModule::SetSwerveModuleState | ( | wpi::math::SwerveModuleVelocity | state, |
| wpi::units::newton_t | feedforwardForce | ||
| ) |
Set the swerve module state with a feedforward force on the drive wheel, for following a trajectory that supplies module forces. The force follows the state: it is reversed when optimization reverses the wheel, and scaled by cosine compensation.
| state | Desired module state. |
| feedforwardForce | Force the wheel should apply along the requested direction. |
| void yams::mechanisms::swerve::SwerveModule::SetupTelemetry | ( | const std::string & | mechName | ) |
Setup telemetry for the module; the SwerveModuleTelemetry config used is either the one supplied via SwerveModuleConfig::WithTelemetry(name, SwerveModuleTelemetryConfig) or a default built from SwerveModuleConfig::GetTelemetryVerbosity() (defaulting to TelemetryVerbosity::HIGH).
| mechName | Telemetry name of the parent SwerveDrive. |
| void yams::mechanisms::swerve::SwerveModule::SimIterate | ( | ) |
Advance the simulation model for both drive and azimuth motors.
| void yams::mechanisms::swerve::SwerveModule::UpdateTelemetry | ( | ) |
Publish drive and azimuth motor telemetry to NetworkTables.
| motorcontrollers::SmartMotorController* yams::mechanisms::swerve::SwerveModule::m_azimuthMotorController |
| motorcontrollers::SmartMotorController* yams::mechanisms::swerve::SwerveModule::m_driveMotorController |