* Rename 'isIRDetect*' functions to 'isLightBumper*'
* Documentation / code cleanup * Add function 'driveRadius' * Add function 'isVirtualWall'
This commit is contained in:
parent
cdc6927e76
commit
75dd293bfd
5 changed files with 157 additions and 84 deletions
|
@ -188,16 +188,16 @@ namespace create {
|
|||
return serial->send(cmd, 4);
|
||||
}
|
||||
|
||||
/*void Create::driveRadius(const float& vel, const float& radius) const {
|
||||
bool Create::driveRadius(const float& vel, const float& radius) const {
|
||||
// Expects each parameter as two bytes each and in millimeters
|
||||
int16_t vel_mm = roundf(vel * 1000);
|
||||
int16_t radius_mm = roundf(radius * 1000);
|
||||
BOUND(vel_mm, -500, 500);
|
||||
BOUND(vel_mm, -util::CREATE_2_MAX_VEL * 1000, util::CREATE_2_MAX_VEL * 1000);
|
||||
|
||||
// Consider special cases for radius
|
||||
// Bound radius if not a special case
|
||||
if (radius_mm != 32768 && radius_mm != 32767 &&
|
||||
radius_mm != -1 && radius_mm != 1) {
|
||||
BOUND(radius_mm, -2000, 2000);
|
||||
BOUND(radius_mm, -util::CREATE_2_MAX_RADIUS, util::CREATE_2_MAX_RADIUS);
|
||||
}
|
||||
|
||||
uint8_t cmd[5] = { OC_DRIVE,
|
||||
|
@ -207,9 +207,8 @@ namespace create {
|
|||
radius_mm & 0xff
|
||||
};
|
||||
|
||||
serial->send(cmd, 5);
|
||||
return serial->send(cmd, 5);
|
||||
}
|
||||
*/
|
||||
|
||||
bool Create::driveWheels(const float& leftVel, const float& rightVel) const {
|
||||
int16_t leftCmd = roundf(leftVel * 1000);
|
||||
|
@ -226,17 +225,6 @@ namespace create {
|
|||
return serial->send(cmd, 5);
|
||||
}
|
||||
|
||||
/*void Create::drivePWM(const int16_t& leftPWM, const int16_t& rightPWM) const {
|
||||
uint8_t cmd[5] = { OC_DRIVE_PWM,
|
||||
rightPWM >> 8,
|
||||
rightPWM & 0xff,
|
||||
leftPWM >> 8,
|
||||
leftPWM & 0xff
|
||||
};
|
||||
serial->send(cmd, 5);
|
||||
}
|
||||
*/
|
||||
|
||||
bool Create::drive(const float& xVel, const float& angularVel) const {
|
||||
// Compute left and right wheel velocities
|
||||
float leftVel = xVel - ((util::CREATE_2_AXLE_LENGTH / 2.0) * angularVel);
|
||||
|
@ -432,6 +420,16 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isVirtualWall() const {
|
||||
if (data->isValidPacketID(ID_VIRTUAL_WALL)) {
|
||||
return GET_DATA(ID_VIRTUAL_WALL);
|
||||
}
|
||||
else {
|
||||
CERR("[create::Create] ", "Virtual Wall sensor not supported!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Create::getDirtDetect() const {
|
||||
if (data->isValidPacketID(ID_DIRT_DETECT)) {
|
||||
return GET_DATA(ID_DIRT_DETECT);
|
||||
|
@ -495,8 +493,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
// Not working
|
||||
// Not supported by any 600 series firmware
|
||||
bool Create::isClockButtonPressed() const {
|
||||
CERR("[create::Create] ", "Clock button is not supported!");
|
||||
if (data->isValidPacketID(ID_BUTTONS)) {
|
||||
return (GET_DATA(ID_BUTTONS) & 0x80) != 0;
|
||||
}
|
||||
|
@ -506,8 +505,9 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
// Not working
|
||||
// Not supported by any 600 series firmware
|
||||
bool Create::isScheduleButtonPressed() const {
|
||||
CERR("[create::Create] ", "Schedule button is not supported!");
|
||||
if (data->isValidPacketID(ID_BUTTONS)) {
|
||||
return (GET_DATA(ID_BUTTONS) & 0x40) != 0;
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectLeft() const {
|
||||
bool Create::isLightBumperLeft() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x01) != 0;
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectFrontLeft() const {
|
||||
bool Create::isLightBumperFrontLeft() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x02) != 0;
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectCenterLeft() const {
|
||||
bool Create::isLightBumperCenterLeft() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x04) != 0;
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectCenterRight() const {
|
||||
bool Create::isLightBumperCenterRight() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x08) != 0;
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectFrontRight() const {
|
||||
bool Create::isLightBumperFrontRight() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x10) != 0;
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ namespace create {
|
|||
}
|
||||
}
|
||||
|
||||
bool Create::isIRDetectRight() const {
|
||||
bool Create::isLightBumperRight() const {
|
||||
if (data->isValidPacketID(ID_LIGHT)) {
|
||||
return (GET_DATA(ID_LIGHT) & 0x20) != 0;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@ namespace create {
|
|||
ADD_PACKET(ID_TEMP, 1, "temperature");
|
||||
ADD_PACKET(ID_CHARGE , 2, "battery_charge");
|
||||
ADD_PACKET(ID_CAPACITY, 2, "battery_capacity");
|
||||
ADD_PACKET(ID_VIRTUAL_WALL, 1, "virtual_wall");
|
||||
|
||||
if (model == CREATE_1) {
|
||||
ADD_PACKET(ID_DISTANCE, 2, "distance");
|
||||
ADD_PACKET(ID_ANGLE, 2, "angle");
|
||||
}
|
||||
else if (model == CREATE_2) {
|
||||
//ADD_PACKET(ID_VIRTUAL_WALL, 1, "virtual_wall");
|
||||
//ADD_PACKET(ID_OVERCURRENTS, 1, "overcurrents");
|
||||
ADD_PACKET(ID_DIRT_DETECT, 1, "dirt_detect");
|
||||
//ADD_PACKET(ID_UNUSED_1, 1, "unused 1");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue