WPILibC++ 2023.4.3-108-ge5452e3
DifferentialDriveWheelPositions.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 <wpi/MathExtras.h>
8#include <wpi/SymbolExports.h>
9
10#include "units/length.h"
11
12namespace frc {
13/**
14 * Represents the wheel positions for a differential drive drivetrain.
15 */
17 /**
18 * Distance driven by the left side.
19 */
20 units::meter_t left = 0_m;
21
22 /**
23 * Distance driven by the right side.
24 */
25 units::meter_t right = 0_m;
26
27 /**
28 * Checks equality between this DifferentialDriveWheelPositions and another
29 * object.
30 *
31 * @param other The other object.
32 * @return Whether the two objects are equal.
33 */
34 bool operator==(const DifferentialDriveWheelPositions& other) const = default;
35
36 /**
37 * Checks inequality between this DifferentialDriveWheelPositions and another
38 * object.
39 *
40 * @param other The other object.
41 * @return Whether the two objects are not equal.
42 */
43 bool operator!=(const DifferentialDriveWheelPositions& other) const = default;
44
46 const DifferentialDriveWheelPositions& other) const {
47 return {left - other.left, right - other.right};
48 }
49
51 const DifferentialDriveWheelPositions& endValue, double t) const {
52 return {wpi::Lerp(left, endValue.left, t),
53 wpi::Lerp(right, endValue.right, t)};
54 }
55};
56} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Definition: AprilTagPoseEstimator.h:15
constexpr T Lerp(const T &startValue, const T &endValue, double t)
Linearly interpolates between two values.
Definition: MathExtras.h:950
Represents the wheel positions for a differential drive drivetrain.
Definition: DifferentialDriveWheelPositions.h:16
bool operator==(const DifferentialDriveWheelPositions &other) const =default
Checks equality between this DifferentialDriveWheelPositions and another object.
bool operator!=(const DifferentialDriveWheelPositions &other) const =default
Checks inequality between this DifferentialDriveWheelPositions and another object.
units::meter_t left
Distance driven by the left side.
Definition: DifferentialDriveWheelPositions.h:20
units::meter_t right
Distance driven by the right side.
Definition: DifferentialDriveWheelPositions.h:25
DifferentialDriveWheelPositions Interpolate(const DifferentialDriveWheelPositions &endValue, double t) const
Definition: DifferentialDriveWheelPositions.h:50
DifferentialDriveWheelPositions operator-(const DifferentialDriveWheelPositions &other) const
Definition: DifferentialDriveWheelPositions.h:45