Fix 'maybe-uninitialized' warnings

Signed-off-by: Jacob Perron <jacobmperron@gmail.com>
This commit is contained in:
Jacob Perron 2021-05-05 21:18:04 -07:00 committed by Jacob Perron
parent 68ee257f1d
commit 98660f6c21
2 changed files with 12 additions and 6 deletions

View file

@ -60,9 +60,9 @@ int main(int argc, char** argv) {
// Switch to Full mode // Switch to Full mode
robot.setMode(create::MODE_FULL); robot.setMode(create::MODE_FULL);
uint16_t light_signals[6]; uint16_t light_signals[6] = {0, 0, 0, 0, 0, 0};
bool light_bumpers[6]; bool light_bumpers[6] = {false, false, false, false, false, false};
bool contact_bumpers[2]; bool contact_bumpers[2] = {false, false};
while (true) { while (true) {
// Get light sensor data (only available for Create 2 or later robots) // Get light sensor data (only available for Create 2 or later robots)

View file

@ -101,10 +101,16 @@ namespace create {
// Get current time // Get current time
auto curTime = std::chrono::steady_clock::now(); auto curTime = std::chrono::steady_clock::now();
float dt = static_cast<std::chrono::duration<float>>(curTime - prevOnDataTime).count(); float dt = static_cast<std::chrono::duration<float>>(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 // Protocol versions 1 and 2 use distance and angle fields for odometry
int16_t angleField; int16_t angleField = 0;
if (model.getVersion() <= V_2) { if (model.getVersion() <= V_2) {
// This is a standards compliant way of doing unsigned to signed conversion // This is a standards compliant way of doing unsigned to signed conversion
uint16_t distanceRaw = GET_DATA(ID_DISTANCE); uint16_t distanceRaw = GET_DATA(ID_DISTANCE);
@ -318,7 +324,7 @@ namespace create {
// Switch to safe mode (required for compatibility with V_1) // Switch to safe mode (required for compatibility with V_1)
if (!(serial->sendOpcode(OC_START) && serial->sendOpcode(OC_CONTROL))) return false; if (!(serial->sendOpcode(OC_START) && serial->sendOpcode(OC_CONTROL))) return false;
} }
bool ret; bool ret = false;
switch (mode) { switch (mode) {
case MODE_OFF: case MODE_OFF:
if (model.getVersion() == V_2) { if (model.getVersion() == V_2) {