WPILibC++ 2024.3.2
AnalogGyro.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 <stdint.h>
8
9#include "hal/Types.h"
10
11/**
12 * @defgroup hal_analoggyro Analog Gyro Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**
22 * Initializes an analog gyro.
23 *
24 * @param[in] handle handle to the analog input port
25 * @param[in] allocationLocation the location where the allocation is occurring
26 * (can be null)
27 * @param[out] status the error code, or 0 for success
28 * @return the initialized gyro handle
29 */
31 const char* allocationLocation,
32 int32_t* status);
33
34/**
35 * Sets up an analog gyro with the proper offsets and settings for the KOP
36 * analog gyro.
37 *
38 * @param[in] handle the gyro handle
39 * @param[out] status the error code, or 0 for success
40 */
41void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status);
42
43/**
44 * Frees an analog gyro.
45 *
46 * @param[in,out] handle the gyro handle
47 */
49
50/**
51 * Sets the analog gyro parameters to the specified values.
52 *
53 * This is meant to be used if you want to reuse the values from a previous
54 * calibration.
55 *
56 * @param[in] handle the gyro handle
57 * @param[in] voltsPerDegreePerSecond the gyro volts scaling
58 * @param[in] offset the gyro offset
59 * @param[in] center the gyro center
60 * @param[out] status the error code, or 0 for success
61 */
63 double voltsPerDegreePerSecond, double offset,
64 int32_t center, int32_t* status);
65
66/**
67 * Sets the analog gyro volts per degrees per second scaling.
68 *
69 * @param[in] handle the gyro handle
70 * @param[in] voltsPerDegreePerSecond the gyro volts scaling
71 * @param[out] status the error code, or 0 for success
72 */
74 double voltsPerDegreePerSecond,
75 int32_t* status);
76
77/**
78 * Resets the analog gyro value to 0.
79 *
80 * @param[in] handle the gyro handle
81 * @param[out] status the error code, or 0 for success
82 */
83void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status);
84
85/**
86 * Calibrates the analog gyro.
87 *
88 * This happens by calculating the average value of the gyro over 5 seconds, and
89 * setting that as the center. Note that this call blocks for 5 seconds to
90 * perform this.
91 *
92 * @param[in] handle the gyro handle
93 * @param[out] status Error status variable. 0 on success.
94 */
95void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status);
96
97/**
98 * Sets the deadband of the analog gyro.
99 *
100 * @param[in] handle the gyro handle
101 * @param[in] volts the voltage deadband
102 * @param[out] status Error status variable. 0 on success.
103 */
105 int32_t* status);
106
107/**
108 * Gets the gyro angle in degrees.
109 *
110 * @param[in] handle the gyro handle
111 * @param[out] status Error status variable. 0 on success.
112 * @return the gyro angle in degrees
113 */
114double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status);
115
116/**
117 * Gets the gyro rate in degrees/second.
118 *
119 * @param[in] handle the gyro handle
120 * @param[out] status Error status variable. 0 on success.
121 * @return the gyro rate in degrees/second
122 */
123double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status);
124
125/**
126 * Gets the calibrated gyro offset.
127 *
128 * Can be used to not repeat a calibration but reconstruct the gyro object.
129 *
130 * @param[in] handle the gyro handle
131 * @param[out] status Error status variable. 0 on success.
132 * @return the gryo offset
133 */
134double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status);
135
136/**
137 * Gets the calibrated gyro center.
138 *
139 * Can be used to not repeat a calibration but reconstruct the gyro object.
140 *
141 * @param[in] handle the gyro handle
142 * @param[out] status Error status variable. 0 on success.
143 * @return the gyro center
144 */
145int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status);
146#ifdef __cplusplus
147} // extern "C"
148#endif
149/** @} */
double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t *status)
Gets the gyro angle in degrees.
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t *status)
Gets the gyro rate in degrees/second.
void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t *status)
Calibrates the analog gyro.
void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle, double voltsPerDegreePerSecond, int32_t *status)
Sets the analog gyro volts per degrees per second scaling.
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t *status)
Gets the calibrated gyro offset.
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t *status)
Gets the calibrated gyro center.
void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t *status)
Resets the analog gyro value to 0.
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t *status)
Sets up an analog gyro with the proper offsets and settings for the KOP analog gyro.
void HAL_FreeAnalogGyro(HAL_GyroHandle handle)
Frees an analog gyro.
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle, const char *allocationLocation, int32_t *status)
Initializes an analog gyro.
void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts, int32_t *status)
Sets the deadband of the analog gyro.
void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle, double voltsPerDegreePerSecond, double offset, int32_t center, int32_t *status)
Sets the analog gyro parameters to the specified values.
HAL_Handle HAL_GyroHandle
Definition: Types.h:39
HAL_Handle HAL_AnalogInputHandle
Definition: Types.h:21