2019-09-28 18:40:56 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2020-03-23 01:57:52 -04:00
|
|
|
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
2019-09-28 18:40:56 -04:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
|
|
|
|
DifferentialDriveKinematicsConstraint::DifferentialDriveKinematicsConstraint(
|
2020-08-19 22:36:58 -04:00
|
|
|
const DifferentialDriveKinematics& kinematics,
|
|
|
|
|
units::meters_per_second_t maxSpeed)
|
2019-09-28 18:40:56 -04:00
|
|
|
: m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
|
|
|
|
|
|
|
|
|
|
units::meters_per_second_t DifferentialDriveKinematicsConstraint::MaxVelocity(
|
2020-03-23 01:57:52 -04:00
|
|
|
const Pose2d& pose, units::curvature_t curvature,
|
2020-04-14 01:32:25 -04:00
|
|
|
units::meters_per_second_t velocity) const {
|
2019-09-28 18:40:56 -04:00
|
|
|
auto wheelSpeeds =
|
|
|
|
|
m_kinematics.ToWheelSpeeds({velocity, 0_mps, velocity * curvature});
|
|
|
|
|
wheelSpeeds.Normalize(m_maxSpeed);
|
|
|
|
|
|
|
|
|
|
return m_kinematics.ToChassisSpeeds(wheelSpeeds).vx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TrajectoryConstraint::MinMax
|
|
|
|
|
DifferentialDriveKinematicsConstraint::MinMaxAcceleration(
|
2020-03-23 01:57:52 -04:00
|
|
|
const Pose2d& pose, units::curvature_t curvature,
|
2020-04-14 01:32:25 -04:00
|
|
|
units::meters_per_second_t speed) const {
|
2019-09-28 18:40:56 -04:00
|
|
|
return {};
|
|
|
|
|
}
|