WPILibC++ 2023.4.3-108-ge5452e3
SwerveDriveWheelPositions.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#include <wpi/array.h>
10
12
13namespace frc {
14/**
15 * Represents the wheel positions for a swerve drive drivetrain.
16 */
17template <size_t NumModules>
19 /**
20 * The distances driven by the wheels.
21 */
23
24 /**
25 * Checks equality between this SwerveDriveWheelPositions and another object.
26 *
27 * @param other The other object.
28 * @return Whether the two objects are equal.
29 */
30 bool operator==(const SwerveDriveWheelPositions& other) const = default;
31
32 /**
33 * Checks inequality between this SwerveDriveWheelPositions and another
34 * object.
35 *
36 * @param other The other object.
37 * @return Whether the two objects are not equal.
38 */
39 bool operator!=(const SwerveDriveWheelPositions& other) const = default;
40
42 const SwerveDriveWheelPositions<NumModules>& other) const {
43 auto result =
45 for (size_t i = 0; i < NumModules; i++) {
46 result[i] = positions[i] - other.positions[i];
47 }
48 return {result};
49 }
50
52 const SwerveDriveWheelPositions<NumModules>& endValue, double t) const {
53 auto result =
55 for (size_t i = 0; i < NumModules; i++) {
56 result[i] = positions[i].Interpolate(endValue.positions[i], t);
57 }
58 return {result};
59 }
60};
61} // namespace frc
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
This class is a wrapper around std::array that does compile time size checking.
Definition: array.h:26
result
Definition: format.h:2564
Definition: AprilTagPoseEstimator.h:15
constexpr empty_array_t empty_array
Definition: array.h:16
Represents the wheel positions for a swerve drive drivetrain.
Definition: SwerveDriveWheelPositions.h:18
SwerveDriveWheelPositions< NumModules > Interpolate(const SwerveDriveWheelPositions< NumModules > &endValue, double t) const
Definition: SwerveDriveWheelPositions.h:51
bool operator==(const SwerveDriveWheelPositions &other) const =default
Checks equality between this SwerveDriveWheelPositions and another object.
SwerveDriveWheelPositions< NumModules > operator-(const SwerveDriveWheelPositions< NumModules > &other) const
Definition: SwerveDriveWheelPositions.h:41
wpi::array< SwerveModulePosition, NumModules > positions
The distances driven by the wheels.
Definition: SwerveDriveWheelPositions.h:22
bool operator!=(const SwerveDriveWheelPositions &other) const =default
Checks inequality between this SwerveDriveWheelPositions and another object.