WPILibC++ 2024.3.2
SwerveModuleState.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/SymbolExports.h>
8
10#include "units/angle.h"
11#include "units/math.h"
12#include "units/velocity.h"
13
14namespace frc {
15/**
16 * Represents the state of one swerve module.
17 */
19 /**
20 * Speed of the wheel of the module.
21 */
22 units::meters_per_second_t speed = 0_mps;
23
24 /**
25 * Angle of the module.
26 */
28
29 /**
30 * Checks equality between this SwerveModuleState and another object.
31 *
32 * @param other The other object.
33 * @return Whether the two objects are equal.
34 */
35 bool operator==(const SwerveModuleState& other) const;
36
37 /**
38 * Minimize the change in heading the desired swerve module state would
39 * require by potentially reversing the direction the wheel spins. If this is
40 * used with the PIDController class's continuous input functionality, the
41 * furthest a wheel will ever rotate is 90 degrees.
42 *
43 * @param desiredState The desired state.
44 * @param currentAngle The current module angle.
45 */
46 static SwerveModuleState Optimize(const SwerveModuleState& desiredState,
47 const Rotation2d& currentAngle);
48};
49} // namespace frc
50
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Definition: Rotation2d.h:23
Definition: AprilTagPoseEstimator.h:15
Represents the state of one swerve module.
Definition: SwerveModuleState.h:18
static SwerveModuleState Optimize(const SwerveModuleState &desiredState, const Rotation2d &currentAngle)
Minimize the change in heading the desired swerve module state would require by potentially reversing...
Rotation2d angle
Angle of the module.
Definition: SwerveModuleState.h:27
bool operator==(const SwerveModuleState &other) const
Checks equality between this SwerveModuleState and another object.