[wpimath] Make feedforward classes throw exceptions for negative Kv or Ka (#6084)

This commit is contained in:
ncorrea210
2023-12-23 11:12:46 -05:00
committed by GitHub
parent d1793f077d
commit 4e4a468d4d
8 changed files with 92 additions and 20 deletions

View File

@@ -6,7 +6,12 @@
#include <utility>
#include <units/velocity.h>
#include <units/voltage.h>
using namespace frc2;
using kv_unit = units::compound_unit<units::volts,
units::inverse<units::meters_per_second>>;
MecanumControllerCommand::MecanumControllerCommand(
frc::Trajectory trajectory, std::function<frc::Pose2d()> pose,
@@ -95,6 +100,7 @@ MecanumControllerCommand::MecanumControllerCommand(
Requirements requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_feedforward(0_V, units::unit_t<kv_unit>{0}),
m_kinematics(kinematics),
m_controller(xController, yController, thetaController),
m_desiredRotation(std::move(desiredRotation)),
@@ -116,6 +122,7 @@ MecanumControllerCommand::MecanumControllerCommand(
Requirements requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_feedforward(0_V, units::unit_t<kv_unit>{0}),
m_kinematics(kinematics),
m_controller(xController, yController, thetaController),
m_maxWheelVelocity(maxWheelVelocity),

View File

@@ -6,9 +6,13 @@
#include <utility>
#include <units/velocity.h>
#include <units/voltage.h>
#include <wpi/sendable/SendableBuilder.h>
using namespace frc2;
using kv_unit = units::compound_unit<units::volts,
units::inverse<units::meters_per_second>>;
RamseteCommand::RamseteCommand(
frc::Trajectory trajectory, std::function<frc::Pose2d()> pose,
@@ -42,6 +46,7 @@ RamseteCommand::RamseteCommand(
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_controller(controller),
m_feedforward(0_V, units::unit_t<kv_unit>{0}),
m_kinematics(std::move(kinematics)),
m_outputVel(std::move(output)),
m_usePID(false) {