4#include <frc/geometry/Pose2d.h>
5#include <frc/geometry/Transform2d.h>
6#include <frc/kinematics/ChassisSpeeds.h>
7#include <frc/trajectory/TrapezoidProfile.h>
8#include <networktables/NetworkTableInstance.h>
9#include <networktables/StructTopic.h>
10#include <units/angle.h>
11#include <units/angular_velocity.h>
12#include <units/base.h>
13#include <units/length.h>
14#include <units/time.h>
15#include <units/velocity.h>
16#include <valkyrie/Loggable.h>
17#include <valkyrie/controllers/PIDF.h>
18#include <valkyrie/controllers/ProfiledPIDController.h>
19#include <valkyrie/drivetrain/swerve/Swerve.h>
64 void SetPID(TranslationalPIDF_t x, TranslationalPIDF_t y, RotationalPIDF_t rot);
70 inline TranslationalPIDF_t
GetXPID()
const {
return xController.GetPID(); }
76 inline TranslationalPIDF_t
GetYPID()
const {
return yController.GetPID(); }
82 inline RotationalPIDF_t
GetRotationalPID()
const {
return rotationalController.GetPID(); }
97 void SetGoal(frc::Pose2d goal, frc::ChassisSpeeds state);
99 void SetPositionTolerance(units::meter_t xTol, units::meter_t yTol, units::radian_t rotTol);
101 void SetVelocityTolerance(units::meters_per_second_t xTol, units::meters_per_second_t yTol, units::radians_per_second_t rotTol);
107 std::pair<frc::Pose2d, frc::ChassisSpeeds>
GetGoal()
const;
109 std::pair<frc::Pose2d, frc::ChassisSpeeds> GetSetpoint()
const;
118 frc::ChassisSpeeds
Calculate(frc::Pose2d pose, frc::ChassisSpeeds currentSpeeds);
120 constexpr bool AtGoal()
const {
return xController.AtGoal() && yController.AtGoal() && rotationalController.AtGoal(); }
124 inline ProfiledPIDController<units::meter, units::meters_per_second>& GetXController() {
return xController; }
126 inline ProfiledPIDController<units::meter, units::meters_per_second>& GetYController() {
return yController; }
128 inline ProfiledPIDController<units::radian, units::radians_per_second>& GetRotationalController() {
return rotationalController; }
134 ProfiledPIDController<units::radian, units::radians_per_second> rotationalController{{}};
136 frc::Pose2d currPosition;
137 frc::ChassisSpeeds currSpeed;
140class WorldAlignCommand :
public WorldAlign,
public frc2::CommandHelper<frc2::Command, WorldAlignCommand> {
144 void Initialize()
override;
146 void Execute()
override;
148 bool IsFinished()
override;
150 constexpr void EnableRotation(
bool e) { rotationEnabled = e; }
154 bool rotationEnabled =
true;
Base helper for publishing and subscribing values to NetworkTables.
Definition Loggable.h:53
Definition ProfiledPIDController.h:12
constexpr bool AtSetpoint() const
Definition ProfiledPIDController.h:132
void SetGoal(frc::Pose2d goal, frc::ChassisSpeeds state)
Sets the desired goal state for the alignment controllers.
TranslationalPIDF_t GetXPID() const
Gets the PID gains for the X-axis controller.
Definition WorldAlign.h:70
TranslationalPIDF_t GetYPID() const
Gets the PID gains for the Y-axis controller.
Definition WorldAlign.h:76
void ResetControllers(frc::Pose2d, frc::ChassisSpeeds)
Resets all controllers with the current robot state. This synchronizes the controller's internal stat...
void LoggablePeriodic() override
Periodic callback for logging updates.
std::pair< frc::Pose2d, frc::ChassisSpeeds > GetGoal() const
Gets the current goal.
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 ...
RotationalPIDF_t GetRotationalPID() const
Gets the PID gains for the rotation controller.
Definition WorldAlign.h:82
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.
Container to hold PID and feed forward values for the motor controller.
Definition PIDF.h:26