Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::control::RemoteMapState Class Reference

#include <remote_map_state.hpp>

Public Types

enum class  MouseButton { LEFT , RIGHT }
 

Public Member Functions

 RemoteMapState ()=default
 
 RemoteMapState (tap::communication::serial::Remote::SwitchState leftss, tap::communication::serial::Remote::SwitchState rightss, const std::list< tap::communication::serial::Remote::Key > &keySet, const std::list< tap::communication::serial::Remote::Key > &negKeySet, bool mouseButtonLeftPressed, bool mouseButtonRightPressed)
 
 RemoteMapState (tap::communication::serial::Remote::Switch swh, tap::communication::serial::Remote::SwitchState switchState)
 
 RemoteMapState (tap::communication::serial::Remote::SwitchState leftss, tap::communication::serial::Remote::SwitchState rightss)
 
 RemoteMapState (const std::list< tap::communication::serial::Remote::Key > &keySet, const std::list< tap::communication::serial::Remote::Key > &negKeySet={})
 
 RemoteMapState (RemoteMapState::MouseButton button, const std::list< tap::communication::serial::Remote::Key > &keySet, const std::list< tap::communication::serial::Remote::Key > &negKeySet={})
 
 RemoteMapState (MouseButton button)
 
void initLSwitch (tap::communication::serial::Remote::SwitchState ss)
 
void initRSwitch (tap::communication::serial::Remote::SwitchState ss)
 
void initKeys (uint16_t keys)
 
void initNegKeys (uint16_t negKeys)
 
void initKeys (const std::list< tap::communication::serial::Remote::Key > &keySet)
 
void initNegKeys (const std::list< tap::communication::serial::Remote::Key > &negKeySet)
 
void initLMouseButton ()
 
void initRMouseButton ()
 
bool stateSubsetOf (const RemoteMapState &other) const
 
bool friend operator== (const RemoteMapState &rms1, const RemoteMapState &rms2)
 
bool friend operator!= (const RemoteMapState &rms1, const RemoteMapState &rms2)
 
uint16_t getNegKeys () const
 
bool getNegKeysUsed () const
 
uint16_t getKeys () const
 
bool getLMouseButton () const
 
bool getRMouseButton () const
 
tap::communication::serial::Remote::SwitchState getLSwitch () const
 
tap::communication::serial::Remote::SwitchState getRSwitch () const
 

Detailed Description

A class to be used in conjunction with a CommandMapping to be placed in the CommandMapper. A particular RemoteMapState is used to capture a sequence of user inputs that must be triggered for a Command to be scheduled.

To use this class, when possible use one of the constructors provided below to create a mapping. We have the ability to map any combination of remote switches, keyboard keys, or mouse buttons to a particular set of Commands. To cover every possible combination, additional initialize functions have been provided to be used in conjunction with class constructors.

See also
CommandMapper for information about adding a RemoteMapState to the CommandMapper.
Note
What is a "neg key"? I frequently will refer to a negKeySet. This can be thought of a key mapping that when matched, no matter what the state of the RemoteMapState is, the RemoteMapState is no longer satisfied.

Member Enumeration Documentation

◆ MouseButton

Use to distinguish between the left and mouse button when initializing a RemoteMapState that uses the mouse as input.

Enumerator
LEFT 

The left mouse button.

RIGHT 

The right mouse button.

Constructor & Destructor Documentation

◆ RemoteMapState() [1/7]

tap::control::RemoteMapState::RemoteMapState ( )
default

◆ RemoteMapState() [2/7]

tap::control::RemoteMapState::RemoteMapState ( tap::communication::serial::Remote::SwitchState  leftss,
tap::communication::serial::Remote::SwitchState  rightss,
const std::list< tap::communication::serial::Remote::Key > &  keySet,
const std::list< tap::communication::serial::Remote::Key > &  negKeySet,
bool  mouseButtonLeftPressed,
bool  mouseButtonRightPressed 
)

Generic constructor that takes all possible remote map state configurations for maximum configurability, initializes the RemoteMapState with all given information.

Parameters
[in]leftssThe switch state for the left switch. If UNKNOWN, the switch state will not be initialized.
[in]rightssThe switch state for the right switch. If UNKNOWN, the switch state will not be initialized.
[in]keySetThe set of keys to use for initialization.
[in]negKeySetThe set of keys to be used as negations in the RemoteMapState.
[in]mouseButtonLeftPressedInitialize the RemoteMapState to match a remote map state when the left mouse button is pressed.
[in]mouseButtonRightPressedInitialize the RemoteMapState to match a remote map state when the right mouse button is pressed.
Note
keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

◆ RemoteMapState() [3/7]

tap::control::RemoteMapState::RemoteMapState ( tap::communication::serial::Remote::Switch  swh,
tap::communication::serial::Remote::SwitchState  switchState 
)

Initializes a RemoteMapState with a single switch to the given switch state.

Parameters
[in]swhThe switch to use in the map state.
[in]switchStateThe switch state of the given switch.

◆ RemoteMapState() [4/7]

tap::control::RemoteMapState::RemoteMapState ( tap::communication::serial::Remote::SwitchState  leftss,
tap::communication::serial::Remote::SwitchState  rightss 
)

Initializes a RemoteMapState with particular switch states for both remote switches.

Parameters
[in]leftssThe switch state for the left switch.
[in]rightssThe switch state for the right switch.

◆ RemoteMapState() [5/7]

tap::control::RemoteMapState::RemoteMapState ( const std::list< tap::communication::serial::Remote::Key > &  keySet,
const std::list< tap::communication::serial::Remote::Key > &  negKeySet = {} 
)

Initializes a RemoteMapState with a particular set of keys and optionally a particular set of negation keys.

Parameters
[in]keySetThe set of keys to use for initialization.
[in]negKeySetThe set of keys to be used as negations in the RemoteMapState.
Note
keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

◆ RemoteMapState() [6/7]

tap::control::RemoteMapState::RemoteMapState ( RemoteMapState::MouseButton  button,
const std::list< tap::communication::serial::Remote::Key > &  keySet,
const std::list< tap::communication::serial::Remote::Key > &  negKeySet = {} 
)

Initializes a RemoteMapState with a particular mouse button and set of keys and optionally a particular set of negation keys.

Parameters
[in]buttonThe mouse button The button to use for initialization.
[in]keySetThe set of keys to use for initialization.
[in]negKeySetThe set of keys to be used as negations in the RemoteMapState.
Note
keySet and negKeySet must be mutally exclusive sets, otherwise the negKeySet will not be properly initialized.

◆ RemoteMapState() [7/7]

tap::control::RemoteMapState::RemoteMapState ( MouseButton  button)

Initializes a RemoteMapState that will use the given mouse button (either left or right) in the mapping.

Parameters
[in]buttonThe MouseButton to use.

Member Function Documentation

◆ getKeys()

uint16_t tap::control::RemoteMapState::getKeys ( ) const
inline
Returns
the current keys initialized in the RemoteMapState.

◆ getLMouseButton()

bool tap::control::RemoteMapState::getLMouseButton ( ) const
inline

◆ getLSwitch()

tap::communication::serial::Remote::SwitchState tap::control::RemoteMapState::getLSwitch ( ) const
inline

◆ getNegKeys()

uint16_t tap::control::RemoteMapState::getNegKeys ( ) const
inline
Returns
The negKeys currently being used.

◆ getNegKeysUsed()

bool tap::control::RemoteMapState::getNegKeysUsed ( ) const
inline
Returns
true if the neg key set has been initialized, false otherwise.

◆ getRMouseButton()

bool tap::control::RemoteMapState::getRMouseButton ( ) const
inline

◆ getRSwitch()

tap::communication::serial::Remote::SwitchState tap::control::RemoteMapState::getRSwitch ( ) const
inline

◆ initKeys() [1/2]

void tap::control::RemoteMapState::initKeys ( const std::list< tap::communication::serial::Remote::Key > &  keySet)
See also
initKeys. Interprets the list and passes that on as a bit mapped set of keys.

◆ initKeys() [2/2]

void tap::control::RemoteMapState::initKeys ( uint16_t  keys)

Initializes the keys to the bit mapped set of keys provided.

Note
keys must be mutally exclusive with any set of negKeys already provided.

◆ initLMouseButton()

void tap::control::RemoteMapState::initLMouseButton ( )

Initializes the left mouse button to be mapped when clicked.

◆ initLSwitch()

void tap::control::RemoteMapState::initLSwitch ( tap::communication::serial::Remote::SwitchState  ss)

Initializes the left switch with the particular Remote::SwitchState provided.

◆ initNegKeys() [1/2]

void tap::control::RemoteMapState::initNegKeys ( const std::list< tap::communication::serial::Remote::Key > &  negKeySet)
See also
initNegKeys. Interprets the list and passes that on as a bit mapped set of keys.

◆ initNegKeys() [2/2]

void tap::control::RemoteMapState::initNegKeys ( uint16_t  negKeys)

Initializes the neg keys to the bit mapped set of neg keys provided.

Note
negKeys must be mutally exclusive with any set of keys already provided.

◆ initRMouseButton()

void tap::control::RemoteMapState::initRMouseButton ( )

Initializes the right mouse button to be mapped when clicked.

◆ initRSwitch()

void tap::control::RemoteMapState::initRSwitch ( tap::communication::serial::Remote::SwitchState  ss)

Initializes the right switch with the particular Remote::SwitchState provided.

◆ operator!=()

bool friend tap::control::RemoteMapState::operator!= ( const RemoteMapState rms1,
const RemoteMapState rms2 
)

Opposite of operator==.

◆ operator==()

bool friend tap::control::RemoteMapState::operator== ( const RemoteMapState rms1,
const RemoteMapState rms2 
)

Straight equality.

Parameters
[in]rms1The first RemoteMapState to check equality for.
[in]rms1The second RemoteMapState to check equality for.

◆ stateSubsetOf()

bool tap::control::RemoteMapState::stateSubsetOf ( const RemoteMapState other) const

Checks if this is a subset of other. this is a subset of other under the following conditions:

  • Either this's left switch state is UNKNOWN or this's left switch state is equal to other's left switch state.
  • Either this's right switch state is UNKNOWN or this's right switch state is equal to other's left switch state.
  • Either this's left mouse button is not initialized or both this and other's left mouse buttons are both initialized.
  • Either this's right mouse button is not initialized or both this and other's right mouse buttons are both initialized.
  • this's key set is a subset of other's key set, i.e. (this.keySet & other.keySet) == this.keySet.
Attention
This function does not use neg keys to determine if the map state is a subset.
Parameters
[other]The RemoteMapState to check if this is a subset of.
Returns
true if this RemoteMapState is a subset of the other RemoteMapState. See above for description of what it means for a RemoteMapState to be a subset of another.

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