Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
robot::types::LimitSwitchData Class Reference

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_SWITCHdiff (const LimitSwitchData &other)
 Check which indices differ between this data and other.
 

Detailed Description

A class that represents limit switches from a specific motor.

Constructor & Destructor Documentation

◆ LimitSwitchData()

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.

Parameters
dataThe limit switch data.

Member Function Documentation

◆ diff()

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.

Parameters
otherThe data to check against.
Returns
std::bitset<N_LIMIT_SWITCH> A bitset where an index is 1 if that this and other differ at that index, and 0 otherwise.

◆ isAnyClosed()

bool robot::types::LimitSwitchData::isAnyClosed ( )

Check if any index is closed.

Returns
bool True iff any index is closed.

◆ isAnyOpen()

bool robot::types::LimitSwitchData::isAnyOpen ( )

Check if any index is open.

Returns
bool True iff any index is open.

◆ isClosed()

bool robot::types::LimitSwitchData::isClosed ( size_t idx)

Check if the given index is closed.

This method is the opposite of LimitSwitchData::isOpen().

Parameters
idxThe index to check. 0 <= idx < N_LIMIT_SWITCH.
Returns
bool True iff the switch at the given index is closed.

◆ isOpen()

bool robot::types::LimitSwitchData::isOpen ( size_t idx)

Check if the given index is open.

This method is the opposite of LimitSwitchData::isClosed().

Parameters
idxThe index to check. 0 <= idx < N_LIMIT_SWITCH.
Returns
bool True iff the switch at the given index is open.

The documentation for this class was generated from the following files: