ReduxLib C++ 2024.3.2
Loading...
Searching...
No Matches
CanandgyroFaults.h
1// Copyright (c) Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the 3-clause BSD license.
3
4#pragma once
5#include <cinttypes>
6#include "redux/sensors/canandgyro/CanandgyroDetails.h"
7
9
10/**
11 * A class to hold device faults for the Canandmag, as returned by Canandmag::GetActiveFaults and Canandmag::GetStickyFaults
12 */
14 public:
15 /**
16 * Constructs from a fault field.
17 * @param field the fault bitfield
18 * @param valid whether data is valid or not
19 */
20 constexpr CanandgyroFaults(uint8_t field, bool valid) :
21 powerCycle(field & details::types::Faults::kPowerCycle),
22 canIdConflict(field & details::types::Faults::kCanIdConflict),
23 canGeneralError(field & details::types::Faults::kCanGeneralError),
24 outOfTemperatureRange(field & details::types::Faults::kOutOfTemperatureRange),
25 hardwareFault(field & details::types::Faults::kHardwareFault),
26 calibrating(field & details::types::Faults::kCalibrating),
27 angularVelocitySaturation(field & details::types::Faults::kAngularVelocitySaturation),
28 accelerationSaturation(field & details::types::Faults::kAccelerationSaturation),
29 faultsValid(valid) {};
30
31 /**
32 * The power cycle fault flag, which is set to true when the encoder first boots.
33 * Clearing sticky faults and then checking this flag can be used to determine if the encoder rebooted.
34 */
36
37 /**
38 * The CAN ID conflict flag, which is set to true if there is a CAN id conflict.
39 * In practice, you should physically inspect the encoder to ensure it's not flashing blue.
40 */
42
43 /**
44 * Returns the CAN general error flag, which will raise if the device has encountered a bus fault.
45 * This typically indicates a physical wiring issue on the robot, such as loose connections or
46 * an intermittently shorting CAN bus
47 */
49
50 /**
51 * The temperature range flag, which will raise if the device is not between 0-95 degrees Celsius.
52 * This may be of concern if the encoder is near very active motors.
53 */
55
56 /**
57 * The hardware fault flag, which will raise if a hardware issue is detected.
58 * Generally will raise if the device's controller cannot read the physical sensor itself.
59 */
61
62 /**
63 * Returns the calibrating flag, which will raise if the device is currently calibrating.
64 */
66
67 /**
68 * The angular velocity saturation flag, which triggers on saturation of angular velocity.
69 */
71
72 /**
73 * The acceleration saturation flag, which triggers on saturation of acceleration.
74 */
76
77 /**
78 * Flag if any faults data has been received at all from the encoder. This will be false until the first status frame arrives
79 * after either the start of robot code or after ClearStickyFaults is called.
80 */
82};
83}
Definition: CanandgyroFaults.h:13
bool canGeneralError
Definition: CanandgyroFaults.h:48
bool accelerationSaturation
Definition: CanandgyroFaults.h:75
bool faultsValid
Definition: CanandgyroFaults.h:81
bool canIdConflict
Definition: CanandgyroFaults.h:41
bool calibrating
Definition: CanandgyroFaults.h:65
bool outOfTemperatureRange
Definition: CanandgyroFaults.h:54
bool powerCycle
Definition: CanandgyroFaults.h:35
bool hardwareFault
Definition: CanandgyroFaults.h:60
constexpr CanandgyroFaults(uint8_t field, bool valid)
Definition: CanandgyroFaults.h:20
bool angularVelocitySaturation
Definition: CanandgyroFaults.h:70
Definition: Canandgyro.h:32