|
Valkyrie 2026
|
A field-relative position controller utilizing Profiled PID loops for 3-axis robot alignment. More...
#include <valkyrie/WorldAlign.h>
Public Types | |
| using | TranslationalPIDF_t = valor::PIDF<units::meter, units::meters_per_second> |
| using | RotationalPIDF_t = valor::PIDF<units::radian, units::radians_per_second> |
Public Member Functions | |
| WorldAlign () | |
| Constructs a WorldAlign object. | |
| void | SetPID (TranslationalPIDF_t x, TranslationalPIDF_t y, RotationalPIDF_t rot) |
| A convenience method to set the PID gains for all three controllers at once. | |
| TranslationalPIDF_t | GetXPID () const |
| Gets the PID gains for the X-axis controller. | |
| TranslationalPIDF_t | GetYPID () const |
| Gets the PID gains for the Y-axis controller. | |
| RotationalPIDF_t | GetRotationalPID () const |
| Gets the PID gains for the rotation controller. | |
| void | ResetControllers (frc::Pose2d, frc::ChassisSpeeds) |
| Resets all controllers with the current robot state. This synchronizes the controller's internal state with the actual robot position and velocity. | |
| void | SetGoal (frc::Pose2d goal, frc::ChassisSpeeds state) |
| Sets the desired goal state for the alignment controllers. | |
| void | SetPositionTolerance (units::meter_t xTol, units::meter_t yTol, units::radian_t rotTol) |
| void | SetVelocityTolerance (units::meters_per_second_t xTol, units::meters_per_second_t yTol, units::radians_per_second_t rotTol) |
| std::pair< frc::Pose2d, frc::ChassisSpeeds > | GetGoal () const |
| Gets the current goal. | |
| std::pair< frc::Pose2d, frc::ChassisSpeeds > | GetSetpoint () const |
| frc::ChassisSpeeds | Calculate (frc::Pose2d pose, frc::ChassisSpeeds currentSpeeds) |
| Calculates the required chassis speeds to reach the last set goal. This is an overload that uses the currently stored goal state. | |
| constexpr bool | AtGoal () const |
| constexpr bool | AtSetpoint () const |
| ProfiledPIDController< units::meter, units::meters_per_second > & | GetXController () |
| ProfiledPIDController< units::meter, units::meters_per_second > & | GetYController () |
| ProfiledPIDController< units::radian, units::radians_per_second > & | GetRotationalController () |
| void | LoggablePeriodic () override |
| Periodic callback for logging updates. | |
| Public Member Functions inherited from valor::Loggable | |
| Loggable (std::string_view name) | |
| Construct a Loggable that registers a top-level table name. | |
| Loggable (std::shared_ptr< nt::NetworkTable > table) | |
| Construct a Loggable that uses an existing NetworkTable. | |
| Loggable ()=default | |
| Default construct an uninitialized Loggable. | |
| void | LogChild (std::string_view name, Loggable *child) |
| Register a child Loggable under a named subtree. | |
| void | LogChild (std::string_view name, wpi::Sendable *child) |
| Register a child Sendable under a named subtree. | |
| bool | WriteLog (std::string_view field, bool data) |
| double | WriteLog (std::string_view field, double data) |
| void | WriteLog (std::string_view field, const std::vector< double > &data) |
|
template<typename U> requires units::traits::is_unit_t_v<U> | |
| U | WriteLog (std::string_view field, U data) |
| void | WriteLog (std::string_view field, std::string_view data) |
|
template<typename E> requires std::is_enum_v<E> | |
| void | WriteLog (std::string_view field, E data) |
|
template<typename T> requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>) | |
| void | WriteLog (std::string_view field, const T &data) |
|
template<typename T> requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>) | |
| void | WriteLog (std::string_view field, const std::vector< T > &data) |
| bool | ReadLog (std::string_view field, bool defaultValue) |
| double | ReadLog (std::string_view field, double defaultValue) |
|
template<typename U> requires units::traits::is_unit_t_v<U> | |
| U | ReadLog (std::string_view field, U defaultValue) |
Additional Inherited Members | |
| Static Public Member Functions inherited from valor::Loggable | |
| static constexpr Loggable & | GetRoot () |
| Protected Member Functions inherited from valor::Loggable | |
| virtual void | OnLoggingStart () |
| Hook invoked when logging is started for this object. | |
A field-relative position controller utilizing Profiled PID loops for 3-axis robot alignment.
WorldAlign provides a high-level interface for driving a robot to a specific target pose (X, Y, and Rotation) within the world coordinate frame. It encapsulates three independent frc::ProfiledPIDController instances, allowing for smooth, trapezoidal motion-profiled movement towards a goal.
This class is designed to handle:
| valor::WorldAlign::WorldAlign | ( | ) |
Constructs a WorldAlign object.
This controller uses three independent ProfiledPIDControllers to align the robot to a target pose in the world coordinate frame (field-relative).
| frc::ChassisSpeeds valor::WorldAlign::Calculate | ( | frc::Pose2d | pose, |
| frc::ChassisSpeeds | currentSpeeds ) |
Calculates the required chassis speeds to reach the last set goal. This is an overload that uses the currently stored goal state.
| pose | The current pose of the robot in the world frame. |
| currentSpeeds | The current chassis speeds of the robot (must be field-relative). |
| std::pair< frc::Pose2d, frc::ChassisSpeeds > valor::WorldAlign::GetGoal | ( | ) | const |
Gets the current goal.
|
inline |
Gets the PID gains for the rotation controller.
|
inline |
Gets the PID gains for the X-axis controller.
|
inline |
Gets the PID gains for the Y-axis controller.
|
overridevirtual |
Periodic callback for logging updates.
If a derived class needs to perform periodic updates to published values, override this method. It is intended to be called by the logging framework; this base class provides an empty implementation.
Reimplemented from valor::Loggable.
| void valor::WorldAlign::ResetControllers | ( | frc::Pose2d | , |
| frc::ChassisSpeeds | ) |
Resets all controllers with the current robot state. This synchronizes the controller's internal state with the actual robot position and velocity.
| pose | The current pose of the robot in the world frame. |
| velocity | The current chassis speeds of the robot (must be field-relative). |
| void valor::WorldAlign::SetGoal | ( | frc::Pose2d | goal, |
| frc::ChassisSpeeds | state ) |
Sets the desired goal state for the alignment controllers.
| goal | The target pose (position and rotation) in the world frame. |
| state | The target state vector (final position and velocity) for each axis. |
| void valor::WorldAlign::SetPID | ( | TranslationalPIDF_t | x, |
| TranslationalPIDF_t | y, | ||
| RotationalPIDF_t | rot ) |