YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
yams::mechanisms::SmartMechanism Class Referenceabstract

#include <SmartMechanism.hpp>

Inheritance diagram for yams::mechanisms::SmartMechanism:
Inheritance graph
[legend]
Collaboration diagram for yams::mechanisms::SmartMechanism:
Collaboration graph
[legend]

Public Member Functions

 SmartMechanism ()
 
virtual ~SmartMechanism ()=default
 
virtual void SimIterate ()=0
 
virtual void UpdateTelemetry ()=0
 
virtual void VisualizationUpdate ()=0
 
virtual std::string GetName () const =0
 
virtual wpi::math::Pose3d GetPose3d () const =0
 
wpi::cmd::CommandPtr Set (double dutycycle)
 
wpi::cmd::CommandPtr Set (std::function< double()> dutycycle)
 
wpi::cmd::CommandPtr SetVoltage (wpi::units::volt_t volts)
 
wpi::cmd::CommandPtr SetVoltage (std::function< wpi::units::volt_t()> volts)
 
void SetMechanismVelocitySetpoint (wpi::units::turns_per_second_t velocity)
 
void SetMeasurementVelocitySetpoint (wpi::units::meters_per_second_t velocity)
 
void SetMechanismPositionSetpoint (wpi::units::turn_t angle)
 
void SetMeasurementPositionSetpoint (wpi::units::meter_t distance)
 
void SetVoltageSetpoint (wpi::units::volt_t voltage)
 
void SetDutyCycleSetpoint (double dutycycle)
 
motorcontrollers::SmartMotorController * GetMotorController ()
 
std::optional< wpi::units::turn_t > GetMechanismSetpoint ()
 
std::optional< wpi::units::meter_t > GetMeasurementSetpoint ()
 
wpi::Mechanism2d * GetMechanismWindow ()
 

Protected Attributes

wpi::cmd::SubsystemBase * m_subsystem {nullptr}
 
motorcontrollers::SmartMotorController * m_smc {nullptr}
 
std::optional< wpi::Mechanism2d > m_mechanismWindow
 

Detailed Description

Abstract base class for all YAMS smart mechanisms.

Provides common open-loop command factories and setpoint helpers that delegate to the underlying SmartMotorController.

Constructor & Destructor Documentation

◆ SmartMechanism()

yams::mechanisms::SmartMechanism::SmartMechanism ( )
inline

◆ ~SmartMechanism()

virtual yams::mechanisms::SmartMechanism::~SmartMechanism ( )
virtualdefault

Member Function Documentation

◆ GetMeasurementSetpoint()

std::optional< wpi::units::meter_t > yams::mechanisms::SmartMechanism::GetMeasurementSetpoint ( )

Get the current setpoint as a distance: the mechanism setpoint converted with the mechanism circumference.

Returns
Optional distance setpoint, empty when there is no position setpoint or the mechanism circumference is not configured.

◆ GetMechanismSetpoint()

std::optional< wpi::units::turn_t > yams::mechanisms::SmartMechanism::GetMechanismSetpoint ( )

Get the current mechanism angle setpoint if one has been set.

Returns
Optional angle setpoint.

◆ GetMechanismWindow()

wpi::Mechanism2d * yams::mechanisms::SmartMechanism::GetMechanismWindow ( )

Get a pointer to the Mechanism2d window, or nullptr if not initialised.

Returns
Pointer to the Mechanism2d window.

◆ GetMotorController()

motorcontrollers::SmartMotorController * yams::mechanisms::SmartMechanism::GetMotorController ( )

Get the underlying SmartMotorController.

◆ GetName()

virtual std::string yams::mechanisms::SmartMechanism::GetName ( ) const
pure virtual

◆ GetPose3d()

virtual wpi::math::Pose3d yams::mechanisms::SmartMechanism::GetPose3d ( ) const
pure virtual

Get the mechanism's pose relative to the robot, worked out from its motor's position and where it is mounted, as set in its MechanismPositionConfig. Publish it as a component of an AdvantageScope robot model, whose part is modeled at the mechanism's zero position about its mount.

Implemented in yams::mechanisms::positional::Arm, yams::mechanisms::positional::Elevator, yams::mechanisms::positional::Pivot, and yams::mechanisms::velocity::FlyWheel.

◆ Set() [1/2]

wpi::cmd::CommandPtr yams::mechanisms::SmartMechanism::Set ( double  dutycycle)

Run the motor at a fixed duty-cycle. Stops the closed-loop controller while the command is running and restarts it on finish.

Parameters
dutycycle[-1, 1] duty cycle to apply.
Returns
CommandPtr that requires m_subsystem.

◆ Set() [2/2]

wpi::cmd::CommandPtr yams::mechanisms::SmartMechanism::Set ( std::function< double()>  dutycycle)

Run the motor at a supplier-provided duty-cycle.

Parameters
dutycycleSupplier returning a [-1, 1] value each loop.
Returns
CommandPtr that requires m_subsystem.

◆ SetDutyCycleSetpoint()

void yams::mechanisms::SmartMechanism::SetDutyCycleSetpoint ( double  dutycycle)

Stop the closed-loop controller and apply a duty cycle immediately.

Parameters
dutycycle[-1, 1] duty cycle.

◆ SetMeasurementPositionSetpoint()

void yams::mechanisms::SmartMechanism::SetMeasurementPositionSetpoint ( wpi::units::meter_t  distance)

Start closed-loop control and set a linear measurement position setpoint.

◆ SetMeasurementVelocitySetpoint()

void yams::mechanisms::SmartMechanism::SetMeasurementVelocitySetpoint ( wpi::units::meters_per_second_t  velocity)

Start closed-loop control and set a linear measurement velocity setpoint.

◆ SetMechanismPositionSetpoint()

void yams::mechanisms::SmartMechanism::SetMechanismPositionSetpoint ( wpi::units::turn_t  angle)

Start closed-loop control and set a mechanism angle setpoint.

◆ SetMechanismVelocitySetpoint()

void yams::mechanisms::SmartMechanism::SetMechanismVelocitySetpoint ( wpi::units::turns_per_second_t  velocity)

Start closed-loop control and set a mechanism angular velocity setpoint.

◆ SetVoltage() [1/2]

wpi::cmd::CommandPtr yams::mechanisms::SmartMechanism::SetVoltage ( std::function< wpi::units::volt_t()>  volts)

Run the motor at a supplier-provided voltage.

Parameters
voltsSupplier returning a voltage each loop.
Returns
CommandPtr that requires m_subsystem.

◆ SetVoltage() [2/2]

wpi::cmd::CommandPtr yams::mechanisms::SmartMechanism::SetVoltage ( wpi::units::volt_t  volts)

Run the motor at a fixed voltage.

Parameters
voltsVoltage to apply.
Returns
CommandPtr that requires m_subsystem.

◆ SetVoltageSetpoint()

void yams::mechanisms::SmartMechanism::SetVoltageSetpoint ( wpi::units::volt_t  voltage)

Stop the closed-loop controller and apply a voltage immediately.

Parameters
voltageVoltage to apply.

◆ SimIterate()

virtual void yams::mechanisms::SmartMechanism::SimIterate ( )
pure virtual

◆ UpdateTelemetry()

virtual void yams::mechanisms::SmartMechanism::UpdateTelemetry ( )
pure virtual

◆ VisualizationUpdate()

virtual void yams::mechanisms::SmartMechanism::VisualizationUpdate ( )
pure virtual

Member Data Documentation

◆ m_mechanismWindow

std::optional<wpi::Mechanism2d> yams::mechanisms::SmartMechanism::m_mechanismWindow
protected

Optional 2D visualisation window published to SmartDashboard.

◆ m_smc

motorcontrollers::SmartMotorController* yams::mechanisms::SmartMechanism::m_smc {nullptr}
protected

Motor controller driving this mechanism.

◆ m_subsystem

wpi::cmd::SubsystemBase* yams::mechanisms::SmartMechanism::m_subsystem {nullptr}
protected

Subsystem that this mechanism belongs to (provides command requirements).


The documentation for this class was generated from the following file: