Move curvature_t to units namespace (#2444)

Note: this is a breaking change.
This commit is contained in:
Prateek Machiraju
2020-03-23 01:57:52 -04:00
committed by GitHub
parent 303194b08b
commit 1c28b729ad
18 changed files with 52 additions and 58 deletions

View File

@@ -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. */
@@ -149,5 +149,5 @@ void frc::from_json(const wpi::json& json, Trajectory::State& state) {
units::meters_per_second_t{json.at("velocity").get<double>()};
state.acceleration =
units::meters_per_second_squared_t{json.at("acceleration").get<double>()};
state.curvature = frc::curvature_t{json.at("curvature").get<double>()};
state.curvature = units::curvature_t{json.at("curvature").get<double>()};
}

View File

@@ -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. */
@@ -14,7 +14,7 @@ CentripetalAccelerationConstraint::CentripetalAccelerationConstraint(
: m_maxCentripetalAcceleration(maxCentripetalAcceleration) {}
units::meters_per_second_t CentripetalAccelerationConstraint::MaxVelocity(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t velocity) {
// ac = v^2 / r
// k (curvature) = 1 / r
@@ -32,7 +32,7 @@ units::meters_per_second_t CentripetalAccelerationConstraint::MaxVelocity(
TrajectoryConstraint::MinMax
CentripetalAccelerationConstraint::MinMaxAcceleration(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) {
// The acceleration of the robot has no impact on the centripetal acceleration
// of the robot.

View File

@@ -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. */
@@ -14,7 +14,7 @@ DifferentialDriveKinematicsConstraint::DifferentialDriveKinematicsConstraint(
: m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
units::meters_per_second_t DifferentialDriveKinematicsConstraint::MaxVelocity(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t velocity) {
auto wheelSpeeds =
m_kinematics.ToWheelSpeeds({velocity, 0_mps, velocity * curvature});
@@ -25,7 +25,7 @@ units::meters_per_second_t DifferentialDriveKinematicsConstraint::MaxVelocity(
TrajectoryConstraint::MinMax
DifferentialDriveKinematicsConstraint::MinMaxAcceleration(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) {
return {};
}

View File

@@ -22,14 +22,14 @@ DifferentialDriveVoltageConstraint::DifferentialDriveVoltageConstraint(
m_maxVoltage(maxVoltage) {}
units::meters_per_second_t DifferentialDriveVoltageConstraint::MaxVelocity(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t velocity) {
return units::meters_per_second_t(std::numeric_limits<double>::max());
}
TrajectoryConstraint::MinMax
DifferentialDriveVoltageConstraint::MinMaxAcceleration(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) {
auto wheelSpeeds =
m_kinematics.ToWheelSpeeds({speed, 0_mps, speed * curvature});

View File

@@ -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. */
@@ -14,7 +14,7 @@ MecanumDriveKinematicsConstraint::MecanumDriveKinematicsConstraint(
: m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
units::meters_per_second_t MecanumDriveKinematicsConstraint::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();
@@ -29,7 +29,7 @@ units::meters_per_second_t MecanumDriveKinematicsConstraint::MaxVelocity(
TrajectoryConstraint::MinMax
MecanumDriveKinematicsConstraint::MinMaxAcceleration(
const Pose2d& pose, curvature_t curvature,
const Pose2d& pose, units::curvature_t curvature,
units::meters_per_second_t speed) {
return {};
}