added cliff sensor signals

This commit is contained in:
DuSack1220 2023-02-04 17:03:31 +01:00
parent d75d41c638
commit 379799864a
3 changed files with 64 additions and 0 deletions

View file

@ -406,6 +406,26 @@ namespace create {
*/
bool isCliffFrontRight() const;
/**
* \return true if the left sensor detects a cliff, false otherwise.
*/
uint16_t getCliffSignalLeft() const;
/**
* \return true if the front left sensor detects a cliff, false otherwise.
*/
uint16_t getCliffSignalFrontLeft() const;
/**
* \return true if the right sensor detects a cliff, false otherwise.
*/
uint16_t getCliffSignalRight() const;
/**
* \return true if the front right sensor detects a cliff, false otherwise.
*/
uint16_t getCliffSignalFrontRight() const;
/**
* \return true if there is a virtual wall signal is being received.
*/

View file

@ -738,6 +738,46 @@ namespace create {
}
}
uint16_t Create::getCliffSignalLeft() const {
if (data->isValidPacketID(ID_CLIFF_LEFT)) {
return GET_DATA(ID_CLIFF_LEFT_SIGNAL);
}
else {
CERR("[create::Create] ", "Left cliff sensor signals not supported!");
return false;
}
}
uint16_t Create::getCliffSignalFrontLeft() const {
if (data->isValidPacketID(ID_CLIFF_FRONT_LEFT)) {
return GET_DATA(ID_CLIFF_FRONT_LEFT_SIGNAL);
}
else {
CERR("[create::Create] ", "Front left cliff sensor signals not supported!");
return false;
}
}
uint16_t Create::getCliffSignalRight() const {
if (data->isValidPacketID(ID_CLIFF_RIGHT)) {
return GET_DATA(ID_CLIFF_RIGHT_SIGNAL);
}
else {
CERR("[create::Create] ", "Rightt cliff sensor signals not supported!");
return false;
}
}
uint16_t Create::getCliffSignalFrontRight() const {
if (data->isValidPacketID(ID_CLIFF_FRONT_RIGHT)) {
return GET_DATA(ID_CLIFF_FRONT_RIGHT_SIGNAL);
}
else {
CERR("[create::Create] ", "Front right cliff sensor signals not supported!");
return false;
}
}
bool Create::isVirtualWall() const {
if (data->isValidPacketID(ID_VIRTUAL_WALL)) {
return GET_DATA(ID_VIRTUAL_WALL);

View file

@ -16,6 +16,10 @@ namespace create {
ADD_PACKET(ID_CLIFF_FRONT_LEFT, 1, "cliff_front_left", V_ALL);
ADD_PACKET(ID_CLIFF_FRONT_RIGHT, 1, "cliff_front_right", V_ALL);
ADD_PACKET(ID_CLIFF_RIGHT, 1, "cliff_right", V_ALL);
ADD_PACKET(ID_CLIFF_LEFT_SIGNAL, 2, "cliff_left_signal", V_3);
ADD_PACKET(ID_CLIFF_FRONT_LEFT_SIGNAL, 2, "cliff_front_left_signal", V_3);
ADD_PACKET(ID_CLIFF_FRONT_RIGHT_SIGNAL, 2, "cliff_front_right_signal", V_3);
ADD_PACKET(ID_CLIFF_RIGHT_SIGNAL, 2, "cliff_right_signal", V_3);
ADD_PACKET(ID_VIRTUAL_WALL, 1, "virtual_wall", V_ALL);
ADD_PACKET(ID_OVERCURRENTS, 1, "overcurrents", V_ALL);
ADD_PACKET(ID_DIRT_DETECT_LEFT, 1, "dirt_detect_left", V_ALL);