4#include <frc/controller/PIDController.h>
5#include <frc/controller/ProfiledPIDController.h>
6#include <frc/geometry/Pose2d.h>
7#include <frc/geometry/Transform2d.h>
8#include <frc/kinematics/ChassisSpeeds.h>
9#include <frc/trajectory/TrapezoidProfile.h>
10#include <networktables/NetworkTableInstance.h>
11#include <networktables/StructTopic.h>
12#include <units/angle.h>
13#include <units/angular_velocity.h>
14#include <units/base.h>
15#include <units/length.h>
16#include <units/time.h>
17#include <units/velocity.h>
19#include "valkyrie/Loggable.h"
20#include "valkyrie/controllers/PIDF.h"
60 WorldAlign(TranslationalPIDF_t xPIDF, TranslationalPIDF_t yPIDF, RotationalPIDF_t rotationalPIDF,
61 frc::TrapezoidProfile<units::meter>::Constraints xConstraints, frc::TrapezoidProfile<units::meter>::Constraints yConstraints,
62 frc::TrapezoidProfile<units::radian>::Constraints rotConstraints);
73 template <
class Distance,
class Velocity = units::compound_unit<Distance, units::inverse<units::seconds>>,
74 class Acceleration = units::compound_unit<Velocity, units::inverse<units::seconds>>>
76 units::unit_t<Distance> distance{0};
77 units::unit_t<Velocity> velocity{0};
78 units::unit_t<Acceleration> acceleration{0};
93 void SetPID(TranslationalPIDF_t x, TranslationalPIDF_t y, RotationalPIDF_t rot);
117 std::tuple<TranslationalPIDF_t, TranslationalPIDF_t, RotationalPIDF_t>
GetPID();
172 void SetConstraints(frc::TrapezoidProfile<units::meter>::Constraints x, frc::TrapezoidProfile<units::meter>::Constraints y,
173 frc::TrapezoidProfile<units::radian>::Constraints rot);
201 units::radian_t maximum = units::radian_t{std::numbers::pi});
233 std::pair<frc::Pose2d, StateVector>
GetGoal();
242 frc::ChassisSpeeds
Calculate(frc::Pose2d pose, frc::ChassisSpeeds currentSpeeds);
256 frc::ProfiledPIDController<units::meter> xController, yController;
257 frc::ProfiledPIDController<units::radian> rotationalController;
259 TranslationalPIDF_t xPIDF, yPIDF;
260 RotationalPIDF_t rotationalPIDF;
262 frc::Pose2d goalPosition, currPosition;
263 frc::ChassisSpeeds currSpeed;
265 double calculatedXVal, calculatedYVal;
Base helper for publishing and subscribing values to NetworkTables.
Definition Loggable.h:218
void SetRotationalConstraints(frc::TrapezoidProfile< units::radian >::Constraints)
Sets the motion constraints for the rotation controller.
void SetXPID(TranslationalPIDF_t)
Sets the PID gains for the X-axis controller.
void SetYPID(TranslationalPIDF_t)
Sets the PID gains for the Y-axis controller.
void EnableContinuousRotation(bool enable=true, units::radian_t minimum=units::radian_t{-std::numbers::pi}, units::radian_t maximum=units::radian_t{std::numbers::pi})
Enables or disables continuous input for the rotation controller. Continuous input is necessary for r...
void ResetRotationalController(frc::Rotation2d, units::radians_per_second_t)
Resets the rotation controller with a new angle and angular velocity.
WorldAlign(TranslationalPIDF_t xPIDF, TranslationalPIDF_t yPIDF, RotationalPIDF_t rotationalPIDF, frc::TrapezoidProfile< units::meter >::Constraints xConstraints, frc::TrapezoidProfile< units::meter >::Constraints yConstraints, frc::TrapezoidProfile< units::radian >::Constraints rotConstraints)
Constructs a WorldAlign object.
TranslationalPIDF_t GetYPID()
Gets the PID gains for the Y-axis controller.
std::pair< frc::Pose2d, StateVector > GetGoal()
Gets the current goal.
void ResetControllers(frc::Pose2d, frc::ChassisSpeeds)
Resets all controllers with the current robot state. This synchronizes the controller's internal stat...
std::tuple< TranslationalPIDF_t, TranslationalPIDF_t, RotationalPIDF_t > GetPID()
Gets the PID gains for all three controllers.
TranslationalPIDF_t GetXPID()
Gets the PID gains for the X-axis controller.
RotationalPIDF_t GetRotationalPID()
Gets the PID gains for the rotation controller.
frc::TrapezoidProfile< units::meter >::Constraints GetYConstraints()
Gets the motion constraints for the Y-axis controller.
frc::TrapezoidProfile< units::radian >::Constraints GetRotationalConstraints()
Gets the motion constraints for the rotation controller.
void LoggablePeriodic() override
Periodic callback for logging updates.
frc::TrapezoidProfile< units::meter >::Constraints GetXConstraints()
Gets the motion constraints for the X-axis controller.
static frc::Pose2d OffsetGetter(frc::Pose2d, frc::Transform2d)
Calculates a new pose by applying a transformation to a reference pose. This is a static utility func...
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 ...
frc::ChassisSpeeds Calculate(frc::Pose2d pose, frc::ChassisSpeeds currentSpeeds, StateVector state)
Calculates the required chassis speeds to move towards the goal state.
void SetYConstraints(frc::TrapezoidProfile< units::meter >::Constraints)
Sets the motion constraints for the Y-axis controller.
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.
void SetXConstraints(frc::TrapezoidProfile< units::meter >::Constraints)
Sets the motion constraints for the X-axis controller.
void SetConstraints(frc::TrapezoidProfile< units::meter >::Constraints x, frc::TrapezoidProfile< units::meter >::Constraints y, frc::TrapezoidProfile< units::radian >::Constraints rot)
Sets the motion profile constraints for all three controllers.
void ResetYController(units::meter_t, units::meters_per_second_t)
Resets the Y-axis controller with a new position and velocity.
void SetGoal(frc::Pose2d goal, StateVector state, bool rotate)
Sets the desired goal state for the alignment controllers.
void ResetXController(units::meter_t, units::meters_per_second_t)
Resets the X-axis controller with a new position and velocity.
void SetRotationalPID(RotationalPIDF_t)
Sets the PID gains for the rotation controller.
Container to hold PID and feed forward values for the motor controller.
Definition PIDF.h:26
Definition WorldAlign.h:75
Definition WorldAlign.h:81