15#include "units/angular_velocity.h"
16#include "units/math.h"
17#include "units/time.h"
18#include "units/velocity.h"
76 const auto& eTranslate = m_poseError.Translation();
77 const auto& eRotate = m_poseError.Rotation();
78 const auto& tolTranslate = m_poseTolerance.Translation();
79 const auto& tolRotate = m_poseTolerance.Rotation();
80 return units::math::abs(eTranslate.X()) < tolTranslate.X() &&
81 units::math::abs(eTranslate.Y()) < tolTranslate.Y() &&
82 units::math::abs(eRotate.Radians()) < tolRotate.Radians();
92 m_poseTolerance = poseTolerance;
107 units::meters_per_second_t linearVelocityRef,
108 units::radians_per_second_t angularVelocityRef);
122 return Calculate(currentPose, desiredState.
pose, desiredState.
velocity,
135 Eigen::Matrix<double, 3, 3> m_Q;
136 Eigen::Matrix<double, 2, 2> m_R;
138 units::second_t m_dt;
142 bool m_enabled =
true;
#define WPILIB_DLLEXPORT
Definition SymbolExports.h:36
The linear time-varying unicycle controller has a similar form to the LQR, but the model used to comp...
Definition LTVUnicycleController.h:30
LTVUnicycleController(units::second_t dt)
Constructs a linear time-varying unicycle controller with default maximum desired error tolerances of...
Definition LTVUnicycleController.h:40
void SetTolerance(const Pose2d &poseTolerance)
Sets the pose error which is considered tolerable for use with AtReference().
Definition LTVUnicycleController.h:91
LTVUnicycleController & operator=(LTVUnicycleController &&)=default
Move assignment operator.
ChassisSpeeds Calculate(const Pose2d ¤tPose, const Pose2d &poseRef, units::meters_per_second_t linearVelocityRef, units::radians_per_second_t angularVelocityRef)
Returns the linear and angular velocity outputs of the LTV controller.
bool AtReference() const
Returns true if the pose error is within tolerance of the reference.
Definition LTVUnicycleController.h:75
void SetEnabled(bool enabled)
Enables and disables the controller for troubleshooting purposes.
Definition LTVUnicycleController.h:131
LTVUnicycleController(LTVUnicycleController &&)=default
Move constructor.
LTVUnicycleController(const wpi::array< double, 3 > &Qelems, const wpi::array< double, 2 > &Relems, units::second_t dt)
Constructs a linear time-varying unicycle controller.
Definition LTVUnicycleController.h:56
ChassisSpeeds Calculate(const Pose2d ¤tPose, const Trajectory::State &desiredState)
Returns the linear and angular velocity outputs of the LTV controller.
Definition LTVUnicycleController.h:120
Represents a 2D pose containing translational and rotational elements.
Definition Pose2d.h:27
This class is a wrapper around std::array that does compile time size checking.
Definition array.h:26
Definition SystemServer.h:9
constexpr Matrixd< sizeof...(Ts), sizeof...(Ts)> MakeCostMatrix(Ts... tolerances)
Creates a cost matrix from the given vector for use with LQR.
Definition StateSpaceUtil.h:37
Represents the speed of a robot chassis.
Definition ChassisSpeeds.h:25
Represents one point on the trajectory.
Definition Trajectory.h:34
Pose2d pose
The pose at that point of the trajectory.
Definition Trajectory.h:45
units::meters_per_second_t velocity
The speed at that point of the trajectory.
Definition Trajectory.h:39
units::curvature_t curvature
The curvature at that point of the trajectory.
Definition Trajectory.h:48