YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
yams::mechanisms::swerve::utility::SwerveInputStream< NumModules > Class Template Reference

#include <SwerveInputStream.hpp>

Public Types

using TelemetryVerbosity = SwerveDriveConfig::TelemetryVerbosity
 

Public Member Functions

 SwerveInputStream (SwerveDrive< NumModules > &drive, std::function< double()> x, std::function< double()> y, std::function< double()> rot)
 
 SwerveInputStream (SwerveDrive< NumModules > &drive, std::function< double()> x, std::function< double()> y, std::function< double()> headingX, std::function< double()> headingY)
 
SwerveInputStream Clone () const
 
SwerveInputStream & WithTelemetry (std::string name, TelemetryVerbosity verbosity)
 
std::optional< std::reference_wrapper< SwerveInputStreamTelemetry< NumModules > > > GetTelemetry ()
 
std::string GetCurrentModeName () const
 
double GetAxisDeadband () const
 
void SetAxisDeadband (double deadband)
 
double GetTranslationAxisScale () const
 
void SetTranslationAxisScale (double scale)
 
double GetOmegaAxisScale () const
 
void SetOmegaAxisScale (double scale)
 
wpi::units::meters_per_second_t GetMaximumChassisLinearVelocity () const
 
void SetMaximumChassisLinearVelocity (wpi::units::meters_per_second_t velocity)
 
wpi::units::radians_per_second_t GetMaximumChassisAngularVelocity () const
 
void SetMaximumChassisAngularVelocity (wpi::units::radians_per_second_t velocity)
 
bool IsTranslationCubeEnabled () const
 
void SetTranslationCubeEnabled (bool enabled)
 
bool IsOmegaCubeEnabled () const
 
void SetOmegaCubeEnabled (bool enabled)
 
bool IsAllianceRelativeEnabled () const
 
void SetAllianceRelativeEnabled (bool enabled)
 
bool IsRobotRelativeEnabled () const
 
void SetRobotRelativeEnabled (bool enabled)
 
SwerveInputStream & WithMaximumLinearVelocity (wpi::units::meters_per_second_t velocity)
 
SwerveInputStream & WithMaximumAngularVelocity (wpi::units::radians_per_second_t velocity)
 
SwerveInputStream & WithControllerRotationAxis (std::function< double()> rot)
 
SwerveInputStream & WithControllerHeadingAxis (std::function< double()> headingX, std::function< double()> headingY)
 
SwerveInputStream & WithDeadband (double deadband)
 
SwerveInputStream & Deadband (double deadband)
 
SwerveInputStream & WithScaleTranslation (double scale)
 
SwerveInputStream & WithScaleRotation (double scale)
 
SwerveInputStream & WithHeadingControl (std::function< bool()> trigger)
 
SwerveInputStream & WithHeading (std::function< wpi::units::radian_t()> heading)
 
SwerveInputStream & WithAim (std::function< wpi::math::Pose2d()> aimTarget, std::function< bool()> trigger)
 
SwerveInputStream & WithAimLookahead (wpi::units::second_t lookahead)
 
SwerveInputStream & WithAimFeedforward (wpi::math::SimpleMotorFeedforward< wpi::units::radians > feedforward)
 
SwerveInputStream & WithAimHeadingOffset (wpi::math::Rotation2d offset, std::function< bool()> enabled)
 
SwerveInputStream & WithAimHeadingOffset (wpi::math::Rotation2d offset)
 
bool IsAimLocked (wpi::units::radian_t tolerance)
 
wpi::math::Translation2d GetTargetVector (const wpi::math::Pose2d &target)
 
wpi::units::radians_per_second_t CalculateAngularVelocity (wpi::units::radian_t target)
 
SwerveInputStream & WithTranslationOnly (std::function< bool()> trigger)
 
SwerveInputStream & WithCubeRotationControllerAxis (std::function< bool()> enabled)
 
SwerveInputStream & WithCubeRotationControllerAxis ()
 
SwerveInputStream & WithCubeTranslationControllerAxis (std::function< bool()> enabled)
 
SwerveInputStream & WithCubeTranslationControllerAxis ()
 
SwerveInputStream & WithAllianceRelativeControl (std::function< bool()> enabled)
 
SwerveInputStream & WithAllianceRelativeControl ()
 
SwerveInputStream & WithRobotRelative (std::function< bool()> enabled)
 
SwerveInputStream & WithRobotRelative ()
 
SwerveInputStream & WithTranslationHeadingOffset (wpi::math::Rotation2d angle, std::function< bool()> enabled)
 
SwerveInputStream & WithTranslationHeadingOffset (wpi::math::Rotation2d angle)
 
wpi::math::ChassisVelocities Get ()
 
wpi::math::ChassisVelocities operator() ()
 

Static Public Member Functions

static SwerveInputStream Of (SwerveDrive< NumModules > &drive, std::function< double()> x, std::function< double()> y)
 

Member Typedef Documentation

◆ TelemetryVerbosity

Constructor & Destructor Documentation

◆ SwerveInputStream() [1/2]

template<size_t NumModules = 4>
yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SwerveInputStream ( SwerveDrive< NumModules > &  drive,
std::function< double()>  x,
std::function< double()>  y,
std::function< double()>  rot 
)
inline

◆ SwerveInputStream() [2/2]

template<size_t NumModules = 4>
yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SwerveInputStream ( SwerveDrive< NumModules > &  drive,
std::function< double()>  x,
std::function< double()>  y,
std::function< double()>  headingX,
std::function< double()>  headingY 
)
inline

Member Function Documentation

◆ CalculateAngularVelocity()

template<size_t NumModules = 4>
wpi::units::radians_per_second_t yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::CalculateAngularVelocity ( wpi::units::radian_t  target)
inline

Angular velocity that turns the robot to a heading in the gyro's frame, from the drive's rotation controller and the WithAimFeedforward feedforward if there is one.

◆ Clone()

template<size_t NumModules = 4>
SwerveInputStream yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::Clone ( ) const
inline

Copy this stream. Unlike a plain copy, the clone has no telemetry, so it does not publish under this stream's name.

◆ Deadband()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::Deadband ( double  deadband)
inline

The same as WithDeadband.

◆ Get()

template<size_t NumModules = 4>
wpi::math::ChassisVelocities yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::Get ( )
inline

◆ GetAxisDeadband()

template<size_t NumModules = 4>
double yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetAxisDeadband ( ) const
inline

◆ GetCurrentModeName()

template<size_t NumModules = 4>
std::string yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetCurrentModeName ( ) const
inline

◆ GetMaximumChassisAngularVelocity()

template<size_t NumModules = 4>
wpi::units::radians_per_second_t yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetMaximumChassisAngularVelocity ( ) const
inline

◆ GetMaximumChassisLinearVelocity()

template<size_t NumModules = 4>
wpi::units::meters_per_second_t yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetMaximumChassisLinearVelocity ( ) const
inline

◆ GetOmegaAxisScale()

template<size_t NumModules = 4>
double yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetOmegaAxisScale ( ) const
inline

◆ GetTargetVector()

template<size_t NumModules = 4>
wpi::math::Translation2d yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetTargetVector ( const wpi::math::Pose2d &  target)
inline

Field relative vector from the robot to a target, from where the robot will be after the WithAimLookahead time if there is one. Useful for shooting on the move.

◆ GetTelemetry()

template<size_t NumModules = 4>
std::optional< std::reference_wrapper< SwerveInputStreamTelemetry< NumModules > > > yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetTelemetry ( )
inline

Get this stream's telemetry, created by WithTelemetry(name, verbosity).

Returns
The SwerveInputStreamTelemetry, or empty if telemetry is not enabled.

◆ GetTranslationAxisScale()

template<size_t NumModules = 4>
double yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::GetTranslationAxisScale ( ) const
inline

◆ IsAimLocked()

template<size_t NumModules = 4>
bool yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::IsAimLocked ( wpi::units::radian_t  tolerance)
inline

True while aiming is enabled and the robot's heading is within the tolerance of its aim heading. Only updates while the stream is being read.

◆ IsAllianceRelativeEnabled()

template<size_t NumModules = 4>
bool yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::IsAllianceRelativeEnabled ( ) const
inline

◆ IsOmegaCubeEnabled()

template<size_t NumModules = 4>
bool yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::IsOmegaCubeEnabled ( ) const
inline

◆ IsRobotRelativeEnabled()

template<size_t NumModules = 4>
bool yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::IsRobotRelativeEnabled ( ) const
inline

◆ IsTranslationCubeEnabled()

template<size_t NumModules = 4>
bool yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::IsTranslationCubeEnabled ( ) const
inline

◆ Of()

template<size_t NumModules = 4>
static SwerveInputStream yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::Of ( SwerveDrive< NumModules > &  drive,
std::function< double()>  x,
std::function< double()>  y 
)
inlinestatic

◆ operator()()

template<size_t NumModules = 4>
wpi::math::ChassisVelocities yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::operator() ( )
inline

◆ SetAllianceRelativeEnabled()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetAllianceRelativeEnabled ( bool  enabled)
inline

◆ SetAxisDeadband()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetAxisDeadband ( double  deadband)
inline

◆ SetMaximumChassisAngularVelocity()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetMaximumChassisAngularVelocity ( wpi::units::radians_per_second_t  velocity)
inline

◆ SetMaximumChassisLinearVelocity()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetMaximumChassisLinearVelocity ( wpi::units::meters_per_second_t  velocity)
inline

◆ SetOmegaAxisScale()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetOmegaAxisScale ( double  scale)
inline

◆ SetOmegaCubeEnabled()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetOmegaCubeEnabled ( bool  enabled)
inline

◆ SetRobotRelativeEnabled()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetRobotRelativeEnabled ( bool  enabled)
inline

◆ SetTranslationAxisScale()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetTranslationAxisScale ( double  scale)
inline

◆ SetTranslationCubeEnabled()

template<size_t NumModules = 4>
void yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::SetTranslationCubeEnabled ( bool  enabled)
inline

◆ WithAim()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAim ( std::function< wpi::math::Pose2d()>  aimTarget,
std::function< bool()>  trigger 
)
inline

◆ WithAimFeedforward()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAimFeedforward ( wpi::math::SimpleMotorFeedforward< wpi::units::radians >  feedforward)
inline

Add a feedforward to the aim rotation, so the robot keeps up with a target whose direction is changing. The feedforward is calculated from the robot's current angular velocity to the angular velocity the rotation controller asks for, and its result is added to that angular velocity.

◆ WithAimHeadingOffset() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAimHeadingOffset ( wpi::math::Rotation2d  offset)
inline

◆ WithAimHeadingOffset() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAimHeadingOffset ( wpi::math::Rotation2d  offset,
std::function< bool()>  enabled 
)
inline

Rotate the aim heading by an offset while enabled, for a shooter that does not point out of the front of the robot. The offset is counter-clockwise positive.

◆ WithAimLookahead()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAimLookahead ( wpi::units::second_t  lookahead)
inline

Aim from where the robot will be after a delay, instead of where it is now. The pose is moved along the robot's field relative velocity by this time before the direction to the target is worked out.

A game piece leaves the robot a moment after the aim was calculated: the camera, the loop, the motors and the feed all take time, and the robot keeps moving through all of it. Add those delays together for a starting value, then tune it. It is often 100 to 200 milliseconds.

This assumes the robot keeps its current velocity, so it works best while driving in a straight line.

◆ WithAllianceRelativeControl() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAllianceRelativeControl ( )
inline

◆ WithAllianceRelativeControl() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithAllianceRelativeControl ( std::function< bool()>  enabled)
inline

◆ WithControllerHeadingAxis()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithControllerHeadingAxis ( std::function< double()>  headingX,
std::function< double()>  headingY 
)
inline

◆ WithControllerRotationAxis()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithControllerRotationAxis ( std::function< double()>  rot)
inline

◆ WithCubeRotationControllerAxis() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithCubeRotationControllerAxis ( )
inline

◆ WithCubeRotationControllerAxis() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithCubeRotationControllerAxis ( std::function< bool()>  enabled)
inline

◆ WithCubeTranslationControllerAxis() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithCubeTranslationControllerAxis ( )
inline

◆ WithCubeTranslationControllerAxis() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithCubeTranslationControllerAxis ( std::function< bool()>  enabled)
inline

◆ WithDeadband()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithDeadband ( double  deadband)
inline

◆ WithHeading()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithHeading ( std::function< wpi::units::radian_t()>  heading)
inline

◆ WithHeadingControl()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithHeadingControl ( std::function< bool()>  trigger)
inline

◆ WithMaximumAngularVelocity()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithMaximumAngularVelocity ( wpi::units::radians_per_second_t  velocity)
inline

◆ WithMaximumLinearVelocity()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithMaximumLinearVelocity ( wpi::units::meters_per_second_t  velocity)
inline

◆ WithRobotRelative() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithRobotRelative ( )
inline

◆ WithRobotRelative() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithRobotRelative ( std::function< bool()>  enabled)
inline

◆ WithScaleRotation()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithScaleRotation ( double  scale)
inline

◆ WithScaleTranslation()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithScaleTranslation ( double  scale)
inline

◆ WithTelemetry()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithTelemetry ( std::string  name,
TelemetryVerbosity  verbosity 
)
inline

Publish this stream's telemetry under SwerveInputStream/<name>, updated every time the stream is read. At HIGH the stream is also live tunable: see SwerveInputStreamTelemetry. Replaces any telemetry this stream already had; NONE turns it off.

The telemetry is created when the stream is first read or GetTelemetry() is called, so copies made while building the stream do not publish. A copy of a stream with telemetry publishes under the same name once read; use Clone() for a copy without telemetry.

Parameters
nameName of the stream in NetworkTables (e.g., "drive").
verbosityTelemetryVerbosity to publish at.
Returns
this, for chaining.

◆ WithTranslationHeadingOffset() [1/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithTranslationHeadingOffset ( wpi::math::Rotation2d  angle)
inline

◆ WithTranslationHeadingOffset() [2/2]

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithTranslationHeadingOffset ( wpi::math::Rotation2d  angle,
std::function< bool()>  enabled 
)
inline

◆ WithTranslationOnly()

template<size_t NumModules = 4>
SwerveInputStream & yams::mechanisms::swerve::utility::SwerveInputStream< NumModules >::WithTranslationOnly ( std::function< bool()>  trigger)
inline

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