[wpilibc] Add unit-aware Joystick.GetDirection() (#5319)

This commit is contained in:
Ryan Blue
2023-05-26 00:43:52 -04:00
committed by GitHub
parent 073d19cb69
commit 282c032b60
3 changed files with 65 additions and 0 deletions

View File

@@ -6,6 +6,9 @@
#include <array>
#include <units/angle.h>
#include <wpi/deprecated.h>
#include "frc/GenericHID.h"
namespace frc {
@@ -226,7 +229,9 @@ class Joystick : public GenericHID {
* in radians.
*
* @return The direction of the vector in radians
* @deprecated Use GetDirection() instead.
*/
WPI_DEPRECATED("Use GetDirection() instead.")
double GetDirectionRadians() const;
/**
@@ -234,9 +239,18 @@ class Joystick : public GenericHID {
* in degrees.
*
* @return The direction of the vector in degrees
* @deprecated Use GetDirection() instead.
*/
WPI_DEPRECATED("Use GetDirection() instead.")
double GetDirectionDegrees() const;
/**
* Get the direction of the vector formed by the joystick and its origin.
*
* @return The direction of the vector.
*/
units::radian_t GetDirection() const;
private:
enum Axis { kX, kY, kZ, kTwist, kThrottle, kNumAxes };
enum Button { kTrigger = 1, kTop = 2 };