diff --git a/examples/bumpers.cpp b/examples/bumpers.cpp index bb9b432..80a62be 100644 --- a/examples/bumpers.cpp +++ b/examples/bumpers.cpp @@ -60,9 +60,9 @@ int main(int argc, char** argv) { // Switch to Full mode robot.setMode(create::MODE_FULL); - uint16_t light_signals[6]; - bool light_bumpers[6]; - bool contact_bumpers[2]; + uint16_t light_signals[6] = {0, 0, 0, 0, 0, 0}; + bool light_bumpers[6] = {false, false, false, false, false, false}; + bool contact_bumpers[2] = {false, false}; while (true) { // Get light sensor data (only available for Create 2 or later robots) diff --git a/src/create.cpp b/src/create.cpp index 270e687..6718d2e 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -101,10 +101,16 @@ namespace create { // Get current time auto curTime = std::chrono::steady_clock::now(); float dt = static_cast>(curTime - prevOnDataTime).count(); - float deltaDist, deltaX, deltaY, deltaYaw, leftWheelDist, rightWheelDist, wheelDistDiff; + float deltaDist = 0.0f; + float deltaX = 0.0f; + float deltaY = 0.0f; + float deltaYaw = 0.0f; + float leftWheelDist = 0.0f; + float rightWheelDist = 0.0f; + float wheelDistDiff = 0.0f; // Protocol versions 1 and 2 use distance and angle fields for odometry - int16_t angleField; + int16_t angleField = 0; if (model.getVersion() <= V_2) { // This is a standards compliant way of doing unsigned to signed conversion uint16_t distanceRaw = GET_DATA(ID_DISTANCE); @@ -318,7 +324,7 @@ namespace create { // Switch to safe mode (required for compatibility with V_1) if (!(serial->sendOpcode(OC_START) && serial->sendOpcode(OC_CONTROL))) return false; } - bool ret; + bool ret = false; switch (mode) { case MODE_OFF: if (model.getVersion() == V_2) {