diff --git a/include/create/create.h b/include/create/create.h index 619205f..80beee3 100644 --- a/include/create/create.h +++ b/include/create/create.h @@ -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. */ diff --git a/src/create.cpp b/src/create.cpp index 0517b4a..72dbd26 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -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); diff --git a/src/data.cpp b/src/data.cpp index 5e8acce..be20717 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -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);