Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
|
A class that represents limit switches from a specific motor. More...
#include <data.h>
Public Member Functions | |
LimitSwitchData (unsigned long long data) | |
Construct a new LimitSwitchData object, from the given bits. | |
bool | isOpen (size_t idx) |
Check if the given index is open. | |
bool | isClosed (size_t idx) |
Check if the given index is closed. | |
bool | isAnyOpen () |
Check if any index is open. | |
bool | isAnyClosed () |
Check if any index is closed. | |
std::bitset< N_LIMIT_SWITCH > | diff (const LimitSwitchData &other) |
Check which indices differ between this data and other. | |
A class that represents limit switches from a specific motor.
robot::types::LimitSwitchData::LimitSwitchData | ( | unsigned long long | data | ) |
Construct a new LimitSwitchData object, from the given bits.
A 1 bit means closed, and 0 means open. Only the rightmost N_LIMIT_SWITCH bits are used.
data | The limit switch data. |
std::bitset< N_LIMIT_SWITCH > robot::types::LimitSwitchData::diff | ( | const LimitSwitchData & | other | ) |
Check which indices differ between this data and other.
This is useful to see which indices have recently changed.
other | The data to check against. |
bool robot::types::LimitSwitchData::isAnyClosed | ( | ) |
Check if any index is closed.
bool robot::types::LimitSwitchData::isAnyOpen | ( | ) |
Check if any index is open.
bool robot::types::LimitSwitchData::isClosed | ( | size_t | idx | ) |
Check if the given index is closed.
This method is the opposite of LimitSwitchData::isOpen().
idx | The index to check. 0 <= idx < N_LIMIT_SWITCH. |
bool robot::types::LimitSwitchData::isOpen | ( | size_t | idx | ) |
Check if the given index is open.
This method is the opposite of LimitSwitchData::isClosed().
idx | The index to check. 0 <= idx < N_LIMIT_SWITCH. |