Skip to content

Commit

Permalink
Fixed review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Sep 3, 2024
1 parent 96c2f8f commit ad602c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/APPRemoteControl/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ void App_motorSpeedSetpointsChannelCallback(const uint8_t* payload, const uint8_
(void)userData;
if ((nullptr != payload) && (MOTOR_SPEED_SETPOINT_CHANNEL_DLC == payloadSize))
{
const MotorSpeed* motorSpeedData = reinterpret_cast<const MotorSpeed*>(payload);
DrivingState::getInstance().setMotorSpeeds(motorSpeedData->left, motorSpeedData->right);
const MotorSpeed* motorSpeedData = reinterpret_cast<const MotorSpeed*>(payload);
int16_t leftMotorSpeed = Util::millimetersPerSecondToStepsPerSecond(motorSpeedData->left);
int16_t rightMotorSpeed = Util::millimetersPerSecondToStepsPerSecond(motorSpeedData->right);
DrivingState::getInstance().setMotorSpeeds(leftMotorSpeed, rightMotorSpeed);
}
}

Expand Down
20 changes: 18 additions & 2 deletions lib/MainNative/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct
bool isZumoComSystemEnabled; /**< Is the ZumoComSystem enabled? */
const char* serialRxChannel; /**< Serial Rx channel */
const char* serialTxChannel; /**< Serial Tx channel */
const char* cwd; /**< Current working directory */

} PrgArguments;

Expand All @@ -78,7 +79,7 @@ static void systemDelay(unsigned long ms);
static const struct option LONG_OPTIONS[] = {{"help", no_argument, nullptr, 0},
{"serialRxCh", required_argument, nullptr, 0},
{"serialTxCh", required_argument, nullptr, 0},
{"cwd", required_argument, nullptr, 0},
{"cwd", required_argument, nullptr, 0},
{nullptr, no_argument, nullptr, 0}}; /* Marks the end. */

/** Program argument default value of the robot name. */
Expand All @@ -96,6 +97,9 @@ static const char PRG_ARG_SERIAL_RX_CH_DEFAULT[] = "1";
/** Program argument default value of the serial tx channel. */
static const char PRG_ARG_SERIAL_TX_CH_DEFAULT[] = "2";

/** Program argument default value of the current working directory. */
static const char* PRG_ARG_CWD_DEFAULT = ".";

/**
* The maximum duration a simulated time step can have.
* Everything above would cause missbehaviour in the application.
Expand Down Expand Up @@ -144,6 +148,16 @@ extern int main(int argc, char** argv)
showPrgArguments(prgArguments);
}

/* Set the current working directory. */
if (0 != strcmp(PRG_ARG_CWD_DEFAULT, prgArguments.cwd))
{
if (0 != chdir(prgArguments.cwd))
{
printf("Failed to set current working directory: %s\n", prgArguments.cwd);
status = -1;
}
}

/* It might happen that the user enables the ZumoComSystem, but the
* choosen application doesn't support it.
*/
Expand Down Expand Up @@ -246,6 +260,7 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
prgArguments.isZumoComSystemEnabled = PRG_ARG_IS_ZUMO_COM_SYSTEM_ENABLED_DEFAULT;
prgArguments.serialRxChannel = PRG_ARG_SERIAL_RX_CH_DEFAULT;
prgArguments.serialTxChannel = PRG_ARG_SERIAL_TX_CH_DEFAULT;
prgArguments.cwd = PRG_ARG_CWD_DEFAULT;

while ((-1 != option) && (0 == status))
{
Expand All @@ -267,7 +282,7 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
}
else if (0 == strcmp(LONG_OPTIONS[optionIndex].name, "cwd"))
{
chdir(optarg);
prgArguments.cwd = optarg;
}
else
{
Expand Down Expand Up @@ -330,6 +345,7 @@ static void showPrgArguments(const PrgArguments& prgArgs)
printf("ZumoComSystem : %s\n", (false == prgArgs.isZumoComSystemEnabled) ? "disabled" : "enabled");
printf("Serial rx channel: %s\n", prgArgs.serialRxChannel);
printf("Serial tx channel: %s\n", prgArgs.serialTxChannel);
printf("Current working directory: %s\n", prgArgs.cwd);
/* Skip verbose flag. */
}

Expand Down

0 comments on commit ad602c4

Please sign in to comment.