WPILibC++ 2024.3.2
DifferentialDriveAccelerationLimiter.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <Eigen/Core>
8#include <wpi/SymbolExports.h>
9
12#include "units/acceleration.h"
14#include "units/length.h"
15#include "units/velocity.h"
16#include "units/voltage.h"
17
18namespace frc {
19
20/**
21 * Filters the provided voltages to limit a differential drive's linear and
22 * angular acceleration.
23 *
24 * The differential drive model can be created via the functions in
25 * LinearSystemId.
26 */
28 public:
29 /**
30 * Constructs a DifferentialDriveAccelerationLimiter.
31 *
32 * @param system The differential drive dynamics.
33 * @param trackwidth The distance between the differential drive's left and
34 * right wheels.
35 * @param maxLinearAccel The maximum linear acceleration.
36 * @param maxAngularAccel The maximum angular acceleration.
37 */
39 LinearSystem<2, 2, 2> system, units::meter_t trackwidth,
40 units::meters_per_second_squared_t maxLinearAccel,
41 units::radians_per_second_squared_t maxAngularAccel);
42
43 /**
44 * Constructs a DifferentialDriveAccelerationLimiter.
45 *
46 * @param system The differential drive dynamics.
47 * @param trackwidth The distance between the differential drive's left and
48 * right wheels.
49 * @param minLinearAccel The minimum (most negative) linear acceleration.
50 * @param maxLinearAccel The maximum (most positive) linear acceleration.
51 * @param maxAngularAccel The maximum angular acceleration.
52 * @throws std::invalid_argument if minimum linear acceleration is greater
53 * than maximum linear acceleration
54 */
56 LinearSystem<2, 2, 2> system, units::meter_t trackwidth,
57 units::meters_per_second_squared_t minLinearAccel,
58 units::meters_per_second_squared_t maxLinearAccel,
59 units::radians_per_second_squared_t maxAngularAccel);
60
61 /**
62 * Returns the next voltage pair subject to acceleraiton constraints.
63 *
64 * @param leftVelocity The left wheel velocity.
65 * @param rightVelocity The right wheel velocity.
66 * @param leftVoltage The unconstrained left motor voltage.
67 * @param rightVoltage The unconstrained right motor voltage.
68 * @return The constrained wheel voltages.
69 */
71 units::meters_per_second_t leftVelocity,
72 units::meters_per_second_t rightVelocity, units::volt_t leftVoltage,
73 units::volt_t rightVoltage);
74
75 private:
76 LinearSystem<2, 2, 2> m_system;
77 units::meter_t m_trackwidth;
78 units::meters_per_second_squared_t m_minLinearAccel;
79 units::meters_per_second_squared_t m_maxLinearAccel;
80 units::radians_per_second_squared_t m_maxAngularAccel;
81};
82
83} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Filters the provided voltages to limit a differential drive's linear and angular acceleration.
Definition: DifferentialDriveAccelerationLimiter.h:27
DifferentialDriveAccelerationLimiter(LinearSystem< 2, 2, 2 > system, units::meter_t trackwidth, units::meters_per_second_squared_t minLinearAccel, units::meters_per_second_squared_t maxLinearAccel, units::radians_per_second_squared_t maxAngularAccel)
Constructs a DifferentialDriveAccelerationLimiter.
DifferentialDriveWheelVoltages Calculate(units::meters_per_second_t leftVelocity, units::meters_per_second_t rightVelocity, units::volt_t leftVoltage, units::volt_t rightVoltage)
Returns the next voltage pair subject to acceleraiton constraints.
DifferentialDriveAccelerationLimiter(LinearSystem< 2, 2, 2 > system, units::meter_t trackwidth, units::meters_per_second_squared_t maxLinearAccel, units::radians_per_second_squared_t maxAngularAccel)
Constructs a DifferentialDriveAccelerationLimiter.
Definition: AprilTagPoseEstimator.h:15
Motor voltages for a differential drive.
Definition: DifferentialDriveWheelVoltages.h:14