ReduxLib C++ 2026.1.2
Loading...
Searching...
No Matches
Canandgyro.h
1// Copyright (c) Bagholders of Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the Mozilla Public License v2.0.
3
4#pragma once
5#include <cinttypes>
6#include <unordered_map>
7#include <mutex>
8#include <condition_variable>
9#include <optional>
10#include <units/angle.h>
11#include <units/angular_velocity.h>
12#include <units/force.h>
13#include <units/time.h>
14#include <units/temperature.h>
15#include <frc/geometry/Quaternion.h>
16#include <frc/geometry/Rotation3d.h>
17
18#include "redux/canand/CanandDevice.h"
19#include "redux/canand/CanandEventLoop.h"
20#include "redux/canand/CanandSettingsManager.h"
21#include "redux/canand/CooldownWarning.h"
22#include "redux/frames/Frame.h"
23#include "redux/sensors/canandgyro/CanandgyroDetails.h"
24#include "redux/sensors/canandgyro/CanandgyroData.h"
25#include "redux/sensors/canandgyro/CanandgyroFaults.h"
26#include "redux/sensors/canandgyro/CanandgyroStatus.h"
27#include "redux/sensors/canandgyro/CanandgyroSettings.h"
28
29/**
30 * Namespace for all classes relating to the Canandgyro
31*/
33
34/**
35 * Class for the CAN interface of the <a href="https://docs.reduxrobotics.com/canandgyro/index.html">canandgyro.</a>
36 *
37 * <p>
38 * The C++ vendordep uses the <a href="https://docs.wpilib.org/en/stable/docs/software/basic-programming/cpp-units.html">units library</a>
39 * for all dimensioned values, including settings.
40 * </p>
41 *
42 * <p>
43 * Operations that receive data from the device (position, velocity, faults, temperature) generally do not block.
44 * The object receives data asynchronously from the CAN packet receive thread and reads thus return the last data received.
45 * </p>
46 * <p>
47 * Operations that set settings or change offsets will generally wait for up to 20ms by default as they will usually
48 * wait for a confirmation packet to be received in response -- unless the blocking timeout is set to zero, in which case
49 * the operation swill not block.
50 * </p>
51 *
52 * Example code:
53 * ```cpp
54 * Canandgyro canandgyro{0}; // instantiates with device id 0
55 *
56 * // Reading angular position
57 * canandgyro.GetYaw(); // gets the yaw (Z-axis) value in units::turn_t [-180 deg inclusive..180 deg exclusive)
58 * // This is probably what you want to use for robot heading.
59 * canandgyro.GetMultiturnYaw(); // also gets yaw, except without a wraparound
60 * canandgyro.GetPitch(); // pitch (Y-axis) value
61 * canandgyro.GetRoll(); // roll (X-axis) value
62 * canandgyro.GetRotation2d(); // Z-axis Rotation2d object
63 * canandgyro.GetRotation3d(); // Full 3d rotation object
64 * canandgyro.GetQuaternion(); // Raw rotation quaternion object
65 *
66 * // Reading angular velocity (all in rotations per second)
67 * canandgyro.GetAngularVelocityYaw();
68 * canandgyro.GetAngularVelocityPitch();
69 * canandgyro.GetAngularVelocityRoll();
70 *
71 * // Linear acceleration (gravitational units)
72 * canandgyro.GetAccelerationX();
73 * canandgyro.GetAccelerationY();
74 * canandgyro.GetAccelerationZ();
75 *
76 * // Updating pose:
77 * canandgyro.SetYaw(0.25_tr); // set yaw to 0.25 rotations positive
78 *
79 * // set roll, pitch, yaw as 0.0, 0.1, and 0.25 rotations with 20 ms timeout
80 * canandgyro.SetPoseRPY(0.0_tr, 0.1_tr, 0.25_tr, 20_ms);
81 * // SetPose
82 *
83 * // Manually calibrating:
84 * // The Canandgyro automatically calibrates on boot, but you may want to force a calibration.
85 * // Calibration takes several seconds!!!
86 *
87 * canandgyro.StartCalibration(); // begin calibration
88 * canandgyro.IsCalibrating(); // check if the gyro is still calibrating
89 * canandgyro.WaitForCalibrationToFinish(5_s); // wait up to 5 seconds for calibration to finish.
90 *
91 * // Faults
92 * canandgyro.ClearStickyFaults(); // clears all sticky faults (including the power cycle flag).
93 * // This call does not block.
94 *
95 *
96 * // this flag will always be true on boot until the sticky faults have been cleared,
97 * // so if this prints true the encoder has rebooted sometime between ClearStickyFaults and now.
98 * CanandgyroFaults faults = canandgyro.GetStickyFaults(); // fetches faults
99 * fmt::print("Device rebooted: {}\n", faults.powerCycle);
100 *
101 * // Timestamped data
102 * // gets current angular position + timestamp together
103 * auto& quatFrameData = canandgyro.GetAngularPositionFrame();
104 * quatFrameData.GetValue(); // fetched quaternion object
105 * quatFrameData.GetValue().W(); // fetched quaternion W component
106 * quatFrameData.GetTimestamp(); // timestamp of the quaternion data
107 * ```
108 *
109 */
111 protected:
112 /** internal Frame variable used to track if the device is calibrating */
114
115 /** internal Frame variable holding current yaw position state */
117
118 /** internal Frame variable holding current yaw position state */
120
121 /** internal Frame variable holding current angular position state */
123
124 /** internal Frame variable holding current angular velocity state */
126
127 /** internal Frame variable holding current acceleration state */
129
130 /** internal Frame variable holding current status value state */
132
133 /** internal settings manager */
135 private:
136
137 bool dataRecvOnce{false};
138 bool useYawAngleFrame{true};
139 units::second_t lastMessageTime{0_s};
140 //redux::canand::CooldownWarning setAbsPositionWarning{1_s, 5};
142
143 public:
144 /**
145 * Constructor with the device's id. This object will be constant with respect to whatever CAN id assigned to it,
146 * so if a device changes id it may change which device this object reads from.
147 * @param canID the device id to use
148 * @param bus the message bus to use. Defaults to "halcan".
149 */
150 Canandgyro(int canID, std::string bus = "halcan");
152
153 /**
154 * Gets a quaternion object of the gyro's 3d rotation from the zero point
155 * @return a Quaternion of the current Canandgyro pose
156 */
157 inline frc::Quaternion GetQuaternion() { return quat.GetValue(); }
158
159 /**
160 * Gets an frc::Rotation3d object of the gyro's 3d rotation from the zero point
161 * If you just want Z-axis rotation use GetYaw().
162 *
163 * @return a Rotation3d of the current Canandgyro pose
164 */
165 inline frc::Rotation3d GetRotation3d() { return frc::Rotation3d{quat.GetValue()}; }
166
167 /**
168 * Gets an frc::Rotation2d object representing the rotation around the yaw axis from the zero point
169 * If you just want Z-axis rotation use GetYaw().
170 * @return a Rotation2d of the current Canandgyro yaw
171 */
172 inline frc::Rotation2d GetRotation2d() { return frc::Rotation2d(this->GetYaw()); }
173
174 /**
175 * Sets whether this object should use the dedicated yaw message for yaw angle instead of
176 * deriving it from the pose quaternion frame.
177 *
178 * By default this is true, as the yaw angle frame is more precise and by default more frequent.
179 *
180 * @param use use the yaw angle
181 */
182 inline void UseDedicatedYawAngleFrame(bool use) { this->useYawAngleFrame = use; }
183
184 /**
185 * Gets the yaw (Z-axis) rotation from [-0.5 rotations inclusive..0.5 exclusive).
186 *
187 * This is probably the function you want to use for applications like field-centric control.
188 *
189 * @return yaw in rotational units.
190 */
191 inline units::turn_t GetYaw() {
192 if (this->useYawAngleFrame) {
193 return this->singleYaw.GetValue();
194 } else {
195 return this->GetRotation3d().Z();
196 }
197 }
198
199 /**
200 * Gets a multi-turn yaw (Z-axis) rotation that tracks to multiple continuous rotations.
201 *
202 * Note that this relies on the dedicated multi-turn yaw packet so if it is disabled via
203 * setYawFramePeriod it will not return fresh data.
204 *
205 * @return multi-turn yaw in rotational units.
206 */
207 inline units::turn_t GetMultiturnYaw() {
208 return this->multiYaw.GetValue();
209 }
210
211 /**
212 * Gets the pitch (Y-axis) rotation from [-0.5 rotations inclusive..0.5 exclusive).
213 *
214 * @return pitch in rotational units.
215 */
216 inline units::turn_t GetPitch() { return this->GetRotation3d().Y(); }
217
218 /**
219 * Gets the roll (X-axis) rotation from [-0.5 rotations inclusive..0.5 exclusive).
220 *
221 * @return roll in rotational units.
222 */
223 inline units::turn_t GetRoll() { return this->GetRotation3d().X(); }
224
225
226 /**
227 * Gets the angular velocity along the roll (X) axis.
228 * @return angular velocity
229 */
230 inline units::turns_per_second_t GetAngularVelocityRoll() { return vel.GetValue().Roll(); }
231
232 /**
233 * Gets the angular velocity along the pitch (Y) axis.
234 * @return angular velocity
235 */
236 inline units::turns_per_second_t GetAngularVelocityPitch() { return vel.GetValue().Pitch(); }
237
238 /**
239 * Gets the angular velocity along the yaw (Z) axis.
240 * @return angular velocity
241 */
242 inline units::turns_per_second_t GetAngularVelocityYaw() { return vel.GetValue().Yaw(); }
243
244 /**
245 * Gets the linear acceleration along the X axis.
246 * @return linear acceleration
247 */
248 inline units::standard_gravity_t GetAccelerationX() { return accel.GetValue().X(); }
249
250 /**
251 * Gets the linear acceleration along the Y axis.
252 * @return linear acceleration in Gs
253 */
254 inline units::standard_gravity_t GetAccelerationY() { return accel.GetValue().Y(); }
255
256 /**
257 * Gets the linear acceleration along the Z axis.
258 * @return linear acceleration
259 */
260 inline units::standard_gravity_t GetAccelerationZ() { return accel.GetValue().Z(); }
261
262 /**
263 * Begins calibration on the Canandgyro.
264 *
265 * This takes several seconds. To check the state of calibration, use IsCalibrating or
266 * WaitForCalibrationToFinish.
267 */
269
270 /**
271 * Returns if the Canandgyro is known to be currently calibrating.
272 * @return if the Canandgyro is calibrating
273 */
274 inline bool IsCalibrating() {
275 return calibrating.GetValue();
276 }
277
278 /**
279 * Blocks the current thread until the Canandgyro has finished calibrating or until a timeout is reached.
280 *
281 * @param timeout the timeout in seconds to wait for a calibration confirmation.
282 * @return true if the calibration has finished within the timeout, false if not.
283 */
284 bool WaitForCalibrationToFinish(units::second_t timeout);
285
286 /**
287 * Sets a new angular position pose without recalibrating with a given roll/pitch/yaw.
288 * If you just want to set yaw, use SetYaw.
289 *
290 * @param newRoll new roll (x) pose
291 * @param newPitch new pitch (y) pose
292 * @param newYaw new yaw (z) pose
293 * @param timeout the timeout in seconds to wait for a pose set confirmation.
294 * Set to 0 to not check (always return true.)
295 * @param retries the number of retries for the set pose operation.
296 * @return true if a pose set confirmation was received (or if timeout is zero)
297 */
298 inline bool SetPoseRPY(units::turn_t newRoll, units::turn_t newPitch, units::turn_t newYaw, units::second_t timeout = 20_ms, uint32_t retries = 5) {
299 return SetPose(frc::Rotation3d(newRoll, newPitch, newYaw).GetQuaternion(), timeout, retries);
300 }
301
302 /**
303 * Sets a new angular position without recalibrating with an frc::Rotation3d.
304 *
305 * @param newPose new rotation3d pose
306 * @param timeout the timeout in seconds to wait for a pose set confirmation.
307 * Set to 0 to not check (always return true.)
308 * @param retries the number of retries for the set pose operation.
309 * @return true if a pose set confirmation was received (or if timeout is zero)
310 */
311 inline bool SetPoseR3D(frc::Rotation3d newPose, units::second_t timeout = 20_ms, uint32_t retries = 5) {
312 return SetPose(newPose.GetQuaternion(), timeout);
313 }
314
315 /**
316 * Sets a new pose without recalibrating with an frc::Quaternion.
317 *
318 * @param newPose new quaternion pose
319 * @param timeout the timeout in seconds to wait for a pose set confirmation.
320 * Set to 0 to not check (always return true.)
321 * @param retries the number of retries for the set pose operation.
322 * @return true if a pose set confirmation was received (or if timeout is zero)
323 */
324 bool SetPose(frc::Quaternion newPose, units::second_t timeout = 20_ms, uint32_t retries = 5);
325
326 /**
327 * Sets a new yaw without recalibrating the Canandgyro.
328 * Blocks for up to 50 milliseconds by default to confirm the transaction.
329 * @param yaw new yaw angle in rotations
330 * @param timeout the timeout in seconds to block to confirm the transaction (set 0 to not block)
331 * @param retries the number of retries for the set pose operation.
332 * @return true if a confirmation was received or the timeout is zero
333 */
334 bool SetYaw(units::turn_t yaw, units::second_t timeout = 20_ms, uint32_t retries = 5);
335
336
337 // functions related to diagonstic data
338
339 /**
340 * Fetches sticky faults.
341 * Sticky faults are the active faults, except once set they do not become unset until ClearStickyFaults() is called.
342 *
343 * @return canandgyroFaults of the sticky faults
344 */
345 inline CanandgyroFaults GetStickyFaults() { return status.GetValue().stickyFaults; }
346
347 /**
348 * Fetches active faults.
349 * Active faults are only active for as long as the error state exists.
350 *
351 * @return canandgyroFaults of the active faults
352 */
353 CanandgyroFaults GetActiveFaults() { return status.GetValue().activeFaults; }
354
355 /**
356 * Get onboard encoder temperature readings in degrees Celsius.
357 * @return temperature in degrees Celsius
358 */
359 units::celsius_t GetTemperature() { return status.GetValue().temperature; }
360
361 /**
362 * Get the contents of the previous status packet, which includes active faults, sticky faults, and temperature.
363 * @return device status as a status struct
364 */
365 inline CanandgyroStatus GetStatus() { return status.GetValue(); }
366
367 /**
368 * Clears sticky faults.
369 *
370 * <p>It is recommended to clear this during initialization, so one can check if the encoder loses power during operation later. </p>
371 * <p>This call does not block, so it may take up to the next status frame (default every 1000 ms) for the sticky faults to be updated.</p>
372 */
374
375 /**
376 * Controls "party mode" -- an encoder identification tool that blinks the onboard LED
377 * various colors if level != 0.
378 *
379 * This function does not block.
380 *
381 * @param level the party level value to set.
382 */
383 void SetPartyMode(uint8_t level);
384
385 // functions relating to settings
386
387 /**
388 * Fetches the device's current configuration in a blocking manner.
389 * <p>This method works by requesting the device first send back all settings, and then waiting
390 * for up to a specified timeout for all settings to be received by the robot controller.
391 * If the timeout is zero, this step is skipped.
392 *
393 * <p>If there are settings that were not received by the timeout, then this function will
394 * attempt to individually fetched each setting for up to a specified number of attempts.
395 * If the fresh argument is true and the timeout argument is 0, then only this latter step runs,
396 * which can be used to only fetch settings that are missing from the known settings cache
397 * returned by GetSettingsAsync.
398 *
399 * <p>The resulting set of known (received) settings is then returned, complete or not.
400 *
401 * <p>This function blocks, so it is best to put this in init routines rather than a main loop.
402 *
403 * ```cpp
404 * // device declaration
405 * Canandgyro canandgyro{0};
406 *
407 * // in your init/other sequence
408 * CanandgyroSettings stg = canandgyro.GetSettings();
409 * if (stg.AllSettingsReceived()) {
410 * // do your thing here
411 * } else {
412 * // handle missing settings
413 * }
414 * ```
415 *
416 * <p>Advanced users can use this function to retry settings missed from StartFetchSettings: </p>
417 * ```cpp
418 * // device declaration
419 * Canandgyro canandgyro{0};
420 * enc.StartFetchSettings(); // send a "fetch settings command"
421 *
422 * // wait some amount of time
423 * CanandgyroSettings stg = enc.GetSettingsAsync();
424 * stg.AllSettingsReceived(); // may or may not be true
425 *
426 * stg = enc.GetSettings(0_ms, 20_ms, 3); // Retry getitng the missing settings.
427 * stg.AllSettingsReceived(); // far more likely to be true
428 * ```
429 *
430 * @param timeout maximum number of seconds to wait for a settings operation before timing out (default 350_ms)
431 * @param missingTimeout maximum number of seconds to wait for each settings retry before giving up
432 * @param attempts number of attempts to try and fetch values missing from the first pass
433 * @return Received set of CanandgyroSettings of device configuration.
434 */
435 inline CanandgyroSettings GetSettings(units::second_t timeout = 350_ms, units::second_t missingTimeout = 20_ms, uint32_t attempts = 3) {
436 return stg.GetSettings(timeout, missingTimeout, attempts);
437 }
438
439 /**
440 * Tells the Canandgyro to begin transmitting its settings; once they are all transmitted (after ~200-300ms),
441 * the values can be retrieved through the Canandgyro::GetSettingsAsync() function call
442 */
443 inline void StartFetchSettings() { stg.StartFetchSettings(); }
444
445 /**
446 * Non-blockingly returns a CanandgyroSettings object of the most recent known settings values received from the encoder.
447 *
448 * <p> <b>Most users will probably want to use canandgyro::GetSettings() instead. </b> </p>
449 *
450 * One can call this after a Canandgyro::StartFetchSettings() call, and use CanandgyroSettings::AllSettingsReceived()
451 * to check if/when all values have been seen. As an example:
452 *
453 * ```cpp
454 *
455 * // device declaration
456 * canandgyro enc{0};
457 *
458 * // somewhere in an init function
459 * enc.StartFetchSettings();
460 *
461 * // ...
462 * // somewhere in a loop function
463 *
464 * CanandgyroSettings stg = enc.GetSettingsAsync();
465 * if (stg.AllSettingsReceived()) {
466 * // do something with the returned settings
467 * fmt::print("Device status frame period: {}\n", *stg.GetStatusFramePeriod());
468 * }
469 * ```
470 *
471 *
472 * If this is called after Canandgyro::SetSettings(), this method will return a settings object where only
473 * the fields where the device has echoed the new values back will be populated. To illustrate this, consider the following:
474 * ```cpp
475 * // device declaration
476 * Canandgyro enc{0};
477 *
478 * // somewhere in a loop
479 * CanandgyroSettings stg_set;
480 * stg_set.SetStatusFramePeriod(100_ms);
481 * enc.SetSettings(stg_set);
482 * CanandgyroSettings stg_get = enc.GetSettingsAsync();
483 *
484 * // will likely return std::nullopt, as the device likely hasn't already responded to the settings set request
485 * stg_get.GetStatusFramePeriod();
486 *
487 * // after up to 100 ms...
488 * stg_get = enc.GetSettingsAsync();
489 *
490 * // will likely be a value equivalent to 100_ms, may still be std::nullopt if the device is disconnected, so be careful of blind dereferences
491 * stg_get.GetStatusFramePeriod();
492 * ```
493 *
494 * @return CanandgyroSettings of currently known settings
495 */
496 inline CanandgyroSettings GetSettingsAsync() { return stg.GetKnownSettings(); }
497
498 /**
499 * Applies the settings from a CanandgyroSettings object to the Canandgyro.
500 * For more information, see the CanandgyroSettings class documentation.
501 *
502 * Example:
503 * ```cpp
504 * CanandgyroSettings stg;
505 * Canandgyro enc{0};
506 * // After configuring the settings object...
507 *
508 * CanandgyroSettings failed = enc.SetSettings(stg);
509 * if (failed.IsEmpty()) {
510 * // success
511 * } else {
512 * // handle failed settings
513 * }
514 * ```
515 *
516 * @param settings the CanandgyroSettings to update the encoder with
517 * @param timeout maximum time in seconds to wait for each setting to be confirmed. (default 0.020s, set to 0 to not check and not block).
518 * @param attempts the maxinum number of attempts to write each individual settings
519 * @return CanandgyroSettings object of unsuccessfully set settings.
520 */
521 inline CanandgyroSettings SetSettings(CanandgyroSettings& settings, units::second_t timeout = 20_ms, uint32_t attempts = 3) {
522 return stg.SetSettings(settings, timeout, attempts);
523 }
524
525 /**
526 * Resets the encoder to factory defaults, and then wait for all settings to be broadcasted
527 * back.
528 * @param timeout how long to wait for the new settings to be confirmed by the encoder in
529 * seconds (suggested at least 0.35 seconds)
530 * @return CanandgyroSettings object of received settings.
531 * Use CanandgyroSettings.AllSettingsReceived() to verify success.
532 */
533 inline CanandgyroSettings ResetFactoryDefaults(units::second_t timeout = 350_ms) {
534 return stg.SendReceiveSettingCommand(details::types::SettingCommand::kResetFactoryDefault, timeout, true);
535 }
536
537 /**
538 * Returns the CanandSettingsManager associated with this device.
539 *
540 * The CanandSettingsManager is an internal helper object.
541 * Teams are typically not expected to use it except for advanced cases (e.g. custom settings
542 * wrappers)
543 * @return internal settings manager handle
544 */
548
549 /**
550 * Returns the current single-turn yaw frame, which includes CAN timestamp data.
551 * redux::canand::FrameData objects are immutable.
552 * @return the current yaw frame
553 */
555
556 /**
557 * Returns the current multi-turn yaw frame, which includes CAN timestamp data.
558 * redux::canand::FrameData objects are immutable.
559 * @return the current yaw frame
560 */
562
563 /**
564 * Returns the current angular position frame, which includes CAN timestamp data.
565 * @return the current angular position frame
566 */
568
569 /**
570 * Returns the current angular velocity frame, which includes CAN timestamp data.
571 * @return the current angular velocity frame
572 */
574
575 /**
576 * Returns the current acceleration frame, which includes CAN timestamp data.
577 * @return the current acceleration frame
578 */
580
581 /**
582 * Returns a handle to the current status frame, which includes CAN timestamp data.
583 * @return the current status frame, as a CanandgyroStatus record.
584 */
586
587
588 // functions that directly modify settings
591 inline std::string GetDeviceClassName() override { return "Canandgyro"; };
595
596};
597
598
599}
Definition CanandAddress.h:62
Definition CanandDevice.h:35
Definition CanandMessage.h:26
Definition CanandSettingsManager.h:82
Definition Frame.h:52
T GetValue()
Definition Frame.h:127
Definition CanandgyroData.h:74
Definition CanandgyroData.h:17
Definition CanandgyroFaults.h:13
Definition CanandgyroSettings.h:54
Definition Canandgyro.h:110
CanandgyroFaults GetStickyFaults()
Definition Canandgyro.h:345
redux::frames::Frame< CanandgyroStatus > & GetStatusFrame()
Definition Canandgyro.h:585
frc::Rotation3d GetRotation3d()
Definition Canandgyro.h:165
bool SetPose(frc::Quaternion newPose, units::second_t timeout=20_ms, uint32_t retries=5)
redux::frames::Frame< CanandgyroStatus > status
Definition Canandgyro.h:131
redux::canand::CanandSettingsManager< CanandgyroSettings > & GetInternalSettingsManager()
Definition Canandgyro.h:545
bool SetYaw(units::turn_t yaw, units::second_t timeout=20_ms, uint32_t retries=5)
CanandgyroStatus GetStatus()
Definition Canandgyro.h:365
units::turn_t GetRoll()
Definition Canandgyro.h:223
CanandgyroSettings ResetFactoryDefaults(units::second_t timeout=350_ms)
Definition Canandgyro.h:533
units::turns_per_second_t GetAngularVelocityPitch()
Definition Canandgyro.h:236
redux::frames::Frame< units::turn_t > & GetYawFrame()
Definition Canandgyro.h:554
units::standard_gravity_t GetAccelerationY()
Definition Canandgyro.h:254
void HandleMessage(redux::canand::CanandMessage &msg) override
CanandgyroFaults GetActiveFaults()
Definition Canandgyro.h:353
units::turn_t GetYaw()
Definition Canandgyro.h:191
bool WaitForCalibrationToFinish(units::second_t timeout)
redux::canand::CanandSettingsManager< CanandgyroSettings > stg
Definition Canandgyro.h:134
units::turns_per_second_t GetAngularVelocityRoll()
Definition Canandgyro.h:230
redux::frames::Frame< frc::Quaternion > & GetAngularPositionFrame()
Definition Canandgyro.h:567
units::celsius_t GetTemperature()
Definition Canandgyro.h:359
units::standard_gravity_t GetAccelerationX()
Definition Canandgyro.h:248
redux::frames::Frame< bool > calibrating
Definition Canandgyro.h:113
redux::frames::Frame< Acceleration > & GetAccelerationFrame()
Definition Canandgyro.h:579
units::turn_t GetPitch()
Definition Canandgyro.h:216
redux::frames::Frame< units::turn_t > singleYaw
Definition Canandgyro.h:116
redux::frames::Frame< units::turn_t > multiYaw
Definition Canandgyro.h:119
void UseDedicatedYawAngleFrame(bool use)
Definition Canandgyro.h:182
redux::frames::Frame< frc::Quaternion > quat
Definition Canandgyro.h:122
units::turns_per_second_t GetAngularVelocityYaw()
Definition Canandgyro.h:242
CanandgyroSettings SetSettings(CanandgyroSettings &settings, units::second_t timeout=20_ms, uint32_t attempts=3)
Definition Canandgyro.h:521
redux::canand::CanandFirmwareVersion GetMinimumFirmwareVersion() override
Definition Canandgyro.h:592
redux::frames::Frame< units::turn_t > & GetMultiturnYawFrame()
Definition Canandgyro.h:561
redux::frames::Frame< Acceleration > accel
Definition Canandgyro.h:128
CanandgyroSettings GetSettingsAsync()
Definition Canandgyro.h:496
redux::canand::CanandAddress & GetAddress() override
bool IsCalibrating()
Definition Canandgyro.h:274
redux::frames::Frame< AngularVelocity > vel
Definition Canandgyro.h:125
std::string GetDeviceClassName() override
Definition Canandgyro.h:591
frc::Quaternion GetQuaternion()
Definition Canandgyro.h:157
Canandgyro(int canID, std::string bus="halcan")
void StartFetchSettings()
Definition Canandgyro.h:443
CanandgyroSettings GetSettings(units::second_t timeout=350_ms, units::second_t missingTimeout=20_ms, uint32_t attempts=3)
Definition Canandgyro.h:435
units::turn_t GetMultiturnYaw()
Definition Canandgyro.h:207
units::standard_gravity_t GetAccelerationZ()
Definition Canandgyro.h:260
frc::Rotation2d GetRotation2d()
Definition Canandgyro.h:172
bool SetPoseRPY(units::turn_t newRoll, units::turn_t newPitch, units::turn_t newYaw, units::second_t timeout=20_ms, uint32_t retries=5)
Definition Canandgyro.h:298
bool SetPoseR3D(frc::Rotation3d newPose, units::second_t timeout=20_ms, uint32_t retries=5)
Definition Canandgyro.h:311
redux::frames::Frame< AngularVelocity > & GetVelocityFrame()
Definition Canandgyro.h:573
@ kResetFactoryDefault
Definition CanandgyroDetails.h:107
void RemoveCANListener(CanandDevice *device)
Definition Canandgyro.h:32
Definition CanandFirmwareVersion.h:17
Definition CanandgyroStatus.h:13