mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -163,8 +163,8 @@ class ct_matrix {
|
||||
if (std::is_constant_evaluated()) {
|
||||
ct_matrix<Scalar, Rows, Cols> result;
|
||||
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int col = 0; col < 3; ++col) {
|
||||
for (int row = 0; row < rhs.rows(); ++row) {
|
||||
for (int col = 0; col < rhs.cols(); ++col) {
|
||||
result(row, col) = lhs(row, col) + rhs(row, col);
|
||||
}
|
||||
}
|
||||
@@ -188,8 +188,8 @@ class ct_matrix {
|
||||
if (std::is_constant_evaluated()) {
|
||||
ct_matrix<Scalar, Rows, Cols> result;
|
||||
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int col = 0; col < 3; ++col) {
|
||||
for (int row = 0; row < rhs.rows(); ++row) {
|
||||
for (int col = 0; col < rhs.cols(); ++col) {
|
||||
result(row, col) = lhs(row, col) - rhs(row, col);
|
||||
}
|
||||
}
|
||||
@@ -282,8 +282,8 @@ class ct_matrix {
|
||||
if (std::is_constant_evaluated()) {
|
||||
Scalar sum = 0.0;
|
||||
|
||||
for (int row = 0; row < Rows; ++row) {
|
||||
for (int col = 0; col < Cols; ++col) {
|
||||
for (int row = 0; row < rows(); ++row) {
|
||||
for (int col = 0; col < cols(); ++col) {
|
||||
sum += (*this)(row, col) * (*this)(row, col);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,19 @@ class WPILIB_DLLEXPORT Pose2d {
|
||||
*/
|
||||
constexpr Pose2d RelativeTo(const Pose2d& other) const;
|
||||
|
||||
/**
|
||||
* Rotates the current pose around a point in 2D space.
|
||||
*
|
||||
* @param point The point in 2D space to rotate around.
|
||||
* @param rot The rotation to rotate the pose by.
|
||||
*
|
||||
* @return The new rotated pose.
|
||||
*/
|
||||
constexpr Pose2d RotateAround(const Translation2d& point,
|
||||
const Rotation2d& rot) const {
|
||||
return {m_translation.RotateAround(point, rot), m_rotation.RotateBy(rot)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a new Pose2d from a (constant curvature) velocity.
|
||||
*
|
||||
|
||||
@@ -207,6 +207,19 @@ class WPILIB_DLLEXPORT Pose3d {
|
||||
*/
|
||||
constexpr Pose3d RelativeTo(const Pose3d& other) const;
|
||||
|
||||
/**
|
||||
* Rotates the current pose around a point in 3D space.
|
||||
*
|
||||
* @param point The point in 3D space to rotate around.
|
||||
* @param rot The rotation to rotate the pose by.
|
||||
*
|
||||
* @return The new rotated pose.
|
||||
*/
|
||||
constexpr Pose3d RotateAround(const Translation3d& point,
|
||||
const Rotation3d& rot) const {
|
||||
return {m_translation.RotateAround(point, rot), m_rotation.RotateBy(rot)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a new Pose3d from a (constant curvature) velocity.
|
||||
*
|
||||
|
||||
@@ -49,11 +49,11 @@ class WPILIB_DLLEXPORT Rotation2d {
|
||||
constexpr Rotation2d(double x, double y) {
|
||||
double magnitude = gcem::hypot(x, y);
|
||||
if (magnitude > 1e-6) {
|
||||
m_sin = y / magnitude;
|
||||
m_cos = x / magnitude;
|
||||
m_sin = y / magnitude;
|
||||
} else {
|
||||
m_sin = 0.0;
|
||||
m_cos = 1.0;
|
||||
m_sin = 0.0;
|
||||
if (!std::is_constant_evaluated()) {
|
||||
wpi::math::MathSharedStore::ReportError(
|
||||
"x and y components of Rotation2d are zero\n{}",
|
||||
|
||||
@@ -148,6 +148,18 @@ class WPILIB_DLLEXPORT Translation3d {
|
||||
units::meter_t{qprime.Z()}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates this translation around another translation in 3D space.
|
||||
*
|
||||
* @param other The other translation to rotate around.
|
||||
* @param rot The rotation to rotate the translation by.
|
||||
* @return The new rotated translation.
|
||||
*/
|
||||
constexpr Translation3d RotateAround(const Translation3d& other,
|
||||
const Rotation3d& rot) const {
|
||||
return (*this - other).RotateBy(rot) + other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Translation2d representing this Translation3d projected into the
|
||||
* X-Y plane.
|
||||
|
||||
@@ -37,7 +37,8 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
|
||||
/**
|
||||
* Create a state-space model of the elevator system. The states of the system
|
||||
* are [position, velocity], inputs are [voltage], and outputs are [position].
|
||||
* are [position, velocity]ᵀ, inputs are [voltage], and outputs are [position,
|
||||
* velocity]ᵀ.
|
||||
*
|
||||
* @param motor The motor (or gearbox) attached to the carriage.
|
||||
* @param mass The mass of the elevator carriage, in kilograms.
|
||||
@@ -74,8 +75,8 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
|
||||
/**
|
||||
* Create a state-space model of a single-jointed arm system.The states of the
|
||||
* system are [angle, angular velocity], inputs are [voltage], and outputs are
|
||||
* [angle].
|
||||
* system are [angle, angular velocity]ᵀ, inputs are [voltage], and outputs
|
||||
* are [angle, angular velocity]ᵀ.
|
||||
*
|
||||
* @param motor The motor (or gearbox) attached to the arm.
|
||||
* @param J The moment of inertia J of the arm.
|
||||
@@ -147,8 +148,8 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
/**
|
||||
* Create a state-space model for a 1 DOF position system from its kV
|
||||
* (volts/(unit/sec)) and kA (volts/(unit/sec²)). These constants can be
|
||||
* found using SysId. the states of the system are [position, velocity],
|
||||
* inputs are [voltage], and outputs are [position].
|
||||
* found using SysId. the states of the system are [position, velocity]ᵀ,
|
||||
* inputs are [voltage], and outputs are [position, velocity]ᵀ.
|
||||
*
|
||||
* You MUST use an SI unit (i.e. meters or radians) for the Distance template
|
||||
* argument. You may still use non-SI units (such as feet or inches) for the
|
||||
@@ -169,7 +170,7 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
template <typename Distance>
|
||||
requires std::same_as<units::meter, Distance> ||
|
||||
std::same_as<units::radian, Distance>
|
||||
static constexpr LinearSystem<2, 1, 1> IdentifyPositionSystem(
|
||||
static constexpr LinearSystem<2, 1, 2> IdentifyPositionSystem(
|
||||
decltype(1_V / Velocity_t<Distance>(1)) kV,
|
||||
decltype(1_V / Acceleration_t<Distance>(1)) kA) {
|
||||
if (kV < decltype(kV){0}) {
|
||||
@@ -180,11 +181,11 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
}
|
||||
|
||||
Matrixd<2, 2> A{{0.0, 1.0}, {0.0, -kV.value() / kA.value()}};
|
||||
Matrixd<2, 1> B{0.0, 1.0 / kA.value()};
|
||||
Matrixd<1, 2> C{1.0, 0.0};
|
||||
Matrixd<1, 1> D{0.0};
|
||||
Matrixd<2, 1> B{{0.0}, {1.0 / kA.value()}};
|
||||
Matrixd<2, 2> C{{1.0, 0.0}, {0.0, 1.0}};
|
||||
Matrixd<2, 1> D{{0.0}, {0.0}};
|
||||
|
||||
return LinearSystem<2, 1, 1>(A, B, C, D);
|
||||
return LinearSystem<2, 1, 2>(A, B, C, D);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +338,8 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
|
||||
/**
|
||||
* Create a state-space model of a DC motor system. The states of the system
|
||||
* are [angular position, angular velocity], inputs are [voltage], and outputs
|
||||
* are [angular position, angular velocity].
|
||||
* are [angular position, angular velocity]ᵀ, inputs are [voltage], and
|
||||
* outputs are [angular position, angular velocity]ᵀ.
|
||||
*
|
||||
* @param motor The motor (or gearbox) attached to the system.
|
||||
* @param J the moment of inertia J of the DC motor.
|
||||
@@ -370,8 +371,9 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
/**
|
||||
* Create a state-space model of a DC motor system from its kV
|
||||
* (volts/(unit/sec)) and kA (volts/(unit/sec²)). These constants can be
|
||||
* found using SysId. the states of the system are [position, velocity],
|
||||
* inputs are [voltage], and outputs are [position].
|
||||
* found using SysId. the states of the system are [angular position, angular
|
||||
* velocity]ᵀ, inputs are [voltage], and outputs are [angular position,
|
||||
* angular velocity]ᵀ.
|
||||
*
|
||||
* You MUST use an SI unit (i.e. meters or radians) for the Distance template
|
||||
* argument. You may still use non-SI units (such as feet or inches) for the
|
||||
@@ -410,9 +412,9 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
|
||||
/**
|
||||
* Create a state-space model of differential drive drivetrain. In this model,
|
||||
* the states are [left velocity, right velocity], the inputs are [left
|
||||
* the states are [left velocity, right velocity]ᵀ, the inputs are [left
|
||||
* voltage, right voltage], and the outputs are [left velocity, right
|
||||
* velocity]
|
||||
* velocity]ᵀ.
|
||||
*
|
||||
* @param motor The motor (or gearbox) driving the drivetrain.
|
||||
* @param mass The mass of the robot in kilograms.
|
||||
|
||||
Reference in New Issue
Block a user