diff --git a/include/create/create.h b/include/create/create.h index 40196c4..4e03b61 100644 --- a/include/create/create.h +++ b/include/create/create.h @@ -366,6 +366,26 @@ namespace create { */ bool isCliff() const; + /** + * \return true if the left sensor detects a cliff, false otherwise. + */ + bool isCliffLeft() const; + + /** + * \return true if the front left sensor detects a cliff, false otherwise. + */ + bool isCliffFrontLeft() const; + + /** + * \return true if the right sensor detects a cliff, false otherwise. + */ + bool isCliffRight() const; + + /** + * \return true if the front right sensor detects a cliff, false otherwise. + */ + bool isCliffFrontRight() const; + /** * \return true if there is a virtual wall signal is being received. */ diff --git a/src/create.cpp b/src/create.cpp index 8279e2a..e71a556 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -663,6 +663,46 @@ namespace create { } } + bool Create::isCliffLeft() const { + if (data->isValidPacketID(ID_CLIFF_LEFT)) { + return GET_DATA(ID_CLIFF_LEFT) == 1; + } + else { + CERR("[create::Create] ", "Left cliff sensors not supported!"); + return false; + } + } + + bool Create::isCliffFrontLeft() const { + if (data->isValidPacketID(ID_CLIFF_FRONT_LEFT)) { + return GET_DATA(ID_CLIFF_FRONT_LEFT) == 1; + } + else { + CERR("[create::Create] ", "Front left cliff sensors not supported!"); + return false; + } + } + + bool Create::isCliffRight() const { + if (data->isValidPacketID(ID_CLIFF_RIGHT)) { + return GET_DATA(ID_CLIFF_RIGHT) == 1; + } + else { + CERR("[create::Create] ", "Rightt cliff sensors not supported!"); + return false; + } + } + + bool Create::isCliffFrontRight() const { + if (data->isValidPacketID(ID_CLIFF_FRONT_RIGHT)) { + return GET_DATA(ID_CLIFF_FRONT_RIGHT) == 1; + } + else { + CERR("[create::Create] ", "Front right cliff sensors not supported!"); + return false; + } + } + bool Create::isVirtualWall() const { if (data->isValidPacketID(ID_VIRTUAL_WALL)) { return GET_DATA(ID_VIRTUAL_WALL);