mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Move curvature_t to units namespace (#2444)
Note: this is a breaking change.
This commit is contained in:
committed by
GitHub
parent
303194b08b
commit
1c28b729ad
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -12,17 +12,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include <Eigen/Core>
|
||||
#include <units/units.h>
|
||||
|
||||
#include "frc/geometry/Pose2d.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Define a unit for curvature.
|
||||
*/
|
||||
using curvature_t = units::unit_t<
|
||||
units::compound_unit<units::radian, units::inverse<units::meter>>>;
|
||||
|
||||
/**
|
||||
* Represents a two-dimensional parametric spline that interpolates between two
|
||||
* points.
|
||||
@@ -32,7 +26,7 @@ using curvature_t = units::unit_t<
|
||||
template <int Degree>
|
||||
class Spline {
|
||||
public:
|
||||
using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
|
||||
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;
|
||||
|
||||
Spline() = default;
|
||||
|
||||
@@ -99,7 +93,7 @@ class Spline {
|
||||
|
||||
return {
|
||||
{FromVector(combined.template block<2, 1>(0, 0)), Rotation2d(dx, dy)},
|
||||
curvature_t(curvature)};
|
||||
units::curvature_t(curvature)};
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace frc {
|
||||
*/
|
||||
class SplineParameterizer {
|
||||
public:
|
||||
using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
|
||||
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;
|
||||
|
||||
struct MalformedSplineException : public std::runtime_error {
|
||||
explicit MalformedSplineException(const char* what_arg)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -19,13 +19,6 @@ class json;
|
||||
} // namespace wpi
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Define a unit for curvature.
|
||||
*/
|
||||
using curvature_t = units::unit_t<
|
||||
units::compound_unit<units::radian, units::inverse<units::meter>>>;
|
||||
|
||||
/**
|
||||
* Represents a time-parameterized trajectory. The trajectory contains of
|
||||
* various States that represent the pose, curvature, time elapsed, velocity,
|
||||
@@ -50,7 +43,7 @@ class Trajectory {
|
||||
Pose2d pose;
|
||||
|
||||
// The curvature at that point of the trajectory.
|
||||
curvature_t curvature{0.0};
|
||||
units::curvature_t curvature{0.0};
|
||||
|
||||
/**
|
||||
* Checks equality between this State and another object.
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace frc {
|
||||
*/
|
||||
class TrajectoryGenerator {
|
||||
public:
|
||||
using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
|
||||
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;
|
||||
|
||||
/**
|
||||
* Generates a trajectory from the given control vectors and config. This
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -44,7 +44,7 @@ namespace frc {
|
||||
*/
|
||||
class TrajectoryParameterizer {
|
||||
public:
|
||||
using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
|
||||
using PoseWithCurvature = std::pair<Pose2d, units::curvature_t>;
|
||||
|
||||
/**
|
||||
* Parameterize the trajectory by time. This is where the velocity profile is
|
||||
@@ -82,7 +82,7 @@ class TrajectoryParameterizer {
|
||||
* the trajectory, max velocity, min acceleration and max acceleration.
|
||||
*/
|
||||
struct ConstrainedState {
|
||||
PoseWithCurvature pose = {Pose2d(), curvature_t(0.0)};
|
||||
PoseWithCurvature pose = {Pose2d(), units::curvature_t(0.0)};
|
||||
units::meter_t distance = 0_m;
|
||||
units::meters_per_second_t maxVelocity = 0_mps;
|
||||
units::meters_per_second_squared_t minAcceleration = 0_mps_sq;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -28,10 +28,10 @@ class CentripetalAccelerationConstraint : public TrajectoryConstraint {
|
||||
units::meters_per_second_squared_t maxCentripetalAcceleration);
|
||||
|
||||
units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) override;
|
||||
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -25,10 +25,10 @@ class DifferentialDriveKinematicsConstraint : public TrajectoryConstraint {
|
||||
units::meters_per_second_t maxSpeed);
|
||||
|
||||
units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) override;
|
||||
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -37,10 +37,10 @@ class DifferentialDriveVoltageConstraint : public TrajectoryConstraint {
|
||||
DifferentialDriveKinematics kinematics, units::volt_t maxVoltage);
|
||||
|
||||
units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) override;
|
||||
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -27,10 +27,10 @@ class MecanumDriveKinematicsConstraint : public TrajectoryConstraint {
|
||||
units::meters_per_second_t maxSpeed);
|
||||
|
||||
units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) override;
|
||||
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -30,10 +30,10 @@ class SwerveDriveKinematicsConstraint : public TrajectoryConstraint {
|
||||
units::meters_per_second_t maxSpeed);
|
||||
|
||||
units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) override;
|
||||
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
MinMax MinMaxAcceleration(const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -25,7 +25,7 @@ SwerveDriveKinematicsConstraint<NumModules>::SwerveDriveKinematicsConstraint(
|
||||
template <size_t NumModules>
|
||||
units::meters_per_second_t
|
||||
SwerveDriveKinematicsConstraint<NumModules>::MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) {
|
||||
auto xVelocity = velocity * pose.Rotation().Cos();
|
||||
auto yVelocity = velocity * pose.Rotation().Sin();
|
||||
@@ -41,7 +41,7 @@ SwerveDriveKinematicsConstraint<NumModules>::MaxVelocity(
|
||||
template <size_t NumModules>
|
||||
TrajectoryConstraint::MinMax
|
||||
SwerveDriveKinematicsConstraint<NumModules>::MinMaxAcceleration(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -59,7 +59,7 @@ class TrajectoryConstraint {
|
||||
* @return The absolute maximum velocity.
|
||||
*/
|
||||
virtual units::meters_per_second_t MaxVelocity(
|
||||
const Pose2d& pose, curvature_t curvature,
|
||||
const Pose2d& pose, units::curvature_t curvature,
|
||||
units::meters_per_second_t velocity) = 0;
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,8 @@ class TrajectoryConstraint {
|
||||
*
|
||||
* @return The min and max acceleration bounds.
|
||||
*/
|
||||
virtual MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
|
||||
virtual MinMax MinMaxAcceleration(const Pose2d& pose,
|
||||
units::curvature_t curvature,
|
||||
units::meters_per_second_t speed) = 0;
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user