diff --git a/lib/APPRemoteControl/src/App.cpp b/lib/APPRemoteControl/src/App.cpp index 628193a..4b198a7 100644 --- a/lib/APPRemoteControl/src/App.cpp +++ b/lib/APPRemoteControl/src/App.cpp @@ -284,9 +284,9 @@ bool App::setupSerialMuxProt() /* Channel subscription. */ m_smpServer.subscribeToChannel(COMMAND_CHANNEL_NAME, App_cmdChannelCallback); - m_smpServer.subscribeToChannel(SPEED_SETPOINT_CHANNEL_NAME, App_motorSpeedSetpointsChannelCallback); + m_smpServer.subscribeToChannel(MOTOR_SPEED_SETPOINT_CHANNEL_NAME, App_motorSpeedSetpointsChannelCallback); m_smpServer.subscribeToChannel(STATUS_CHANNEL_NAME, App_statusChannelCallback); - m_smpServer.subscribeToChannel(TURTLE_CHANNEL_NAME, App_turtleChannelCallback); + m_smpServer.subscribeToChannel(ROBOT_SPEED_SETPOINT_CHANNEL_NAME, App_turtleChannelCallback); /* Channel creation. */ m_serialMuxProtChannelIdRemoteCtrlRsp = @@ -361,9 +361,9 @@ static void App_cmdChannelCallback(const uint8_t* payload, const uint8_t payload void App_motorSpeedSetpointsChannelCallback(const uint8_t* payload, const uint8_t payloadSize, void* userData) { (void)userData; - if ((nullptr != payload) && (SPEED_SETPOINT_CHANNEL_DLC == payloadSize)) + if ((nullptr != payload) && (MOTOR_SPEED_SETPOINT_CHANNEL_DLC == payloadSize)) { - const SpeedData* motorSpeedData = reinterpret_cast(payload); + const MotorSpeed* motorSpeedData = reinterpret_cast(payload); DrivingState::getInstance().setTargetSpeeds(motorSpeedData->left, motorSpeedData->right); } } @@ -388,16 +388,16 @@ void App_statusChannelCallback(const uint8_t* payload, const uint8_t payloadSize /** * Receives Turtle speed setpoints over SerialMuxProt channel. * - * @param[in] payload Linear and angular speed setpoints in a TurtleSpeed structure. - * @param[in] payloadSize Size of the TurtleSpeed structure. + * @param[in] payload Linear and angular speed setpoints in a RobotSpeed structure. + * @param[in] payloadSize Size of the RobotSpeed structure. * @param[in] userData Instance of App class. */ void App_turtleChannelCallback(const uint8_t* payload, const uint8_t payloadSize, void* userData) { (void)userData; - if ((nullptr != payload) && (TURTLE_CHANNEL_DLC == payloadSize)) + if ((nullptr != payload) && (ROBOT_SPEED_SETPOINT_CHANNEL_DLC == payloadSize)) { - const TurtleSpeed* turtleSpeedData = reinterpret_cast(payload); + const RobotSpeed* turtleSpeedData = reinterpret_cast(payload); DifferentialDrive& diffDrive = DifferentialDrive::getInstance(); int16_t angularSpeed = static_cast(turtleSpeedData->angular); diff --git a/lib/APPRemoteControl/src/SerialMuxChannels.h b/lib/APPRemoteControl/src/SerialMuxChannels.h index 6e49cac..b08f2f6 100644 --- a/lib/APPRemoteControl/src/SerialMuxChannels.h +++ b/lib/APPRemoteControl/src/SerialMuxChannels.h @@ -59,10 +59,16 @@ #define COMMAND_RESPONSE_CHANNEL_DLC (sizeof(CommandResponse)) /** Name of Channel to send Motor Speed Setpoints to. */ -#define SPEED_SETPOINT_CHANNEL_NAME "SPEED_SET" +#define MOTOR_SPEED_SETPOINT_CHANNEL_NAME "MOTOR_SET" -/** DLC of Speedometer Channel */ -#define SPEED_SETPOINT_CHANNEL_DLC (sizeof(SpeedData)) +/** DLC of Motor Speed Setpoint Channel */ +#define MOTOR_SPEED_SETPOINT_CHANNEL_DLC (sizeof(MotorSpeed)) + +/** Name of the Channel to send Robot Speed Setpoints to. */ +#define ROBOT_SPEED_SETPOINT_CHANNEL_NAME "ROBOT_SET" + +/** DLC of Robot Speed Setpoint Channel */ +#define ROBOT_SPEED_SETPOINT_CHANNEL_DLC (sizeof(RobotSpeed)) /** Name of Channel to send Current Vehicle Data to. */ #define CURRENT_VEHICLE_DATA_CHANNEL_NAME "CURR_DATA" @@ -82,12 +88,6 @@ /** DLC of Line Sensor Channel */ #define LINE_SENSOR_CHANNEL_DLC (sizeof(LineSensorData)) -/** Name of the Channel to send Turtle Speeds. */ -#define TURTLE_CHANNEL_NAME "TURTLE" - -/** DLC of Turtle Channel */ -#define TURTLE_CHANNEL_DLC (sizeof(TurtleSpeed)) - /****************************************************************************** * Types and Classes *****************************************************************************/ @@ -179,13 +179,19 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; -/** Struct of the "Speed" channel payload. */ -typedef struct _SpeedData +/** Struct of the "Motor Speed Setpoints" channel payload. */ +typedef struct _MotorSpeed +{ + int32_t left; /**< Left motor speed [mm/s] */ + int32_t right; /**< Right motor speed [mm/s] */ +} __attribute__((packed)) MotorSpeed; + +/** Struct of the "Robot Speed Setpoints" channel payload. */ +typedef struct _RobotSpeed { - int32_t left; /**< Left motor speed [mm/s] */ - int32_t right; /**< Right motor speed [mm/s] */ - int32_t center; /**< Center motor speed [mm/s] */ -} __attribute__((packed)) SpeedData; + int32_t linearCenter; /**< Linear speed of the vehicle center. [mm/s] */ + int32_t angular; /**< Angular speed. [mrad/s] */ +} __attribute__((packed)) RobotSpeed; /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData @@ -211,13 +217,6 @@ typedef struct _LineSensorData uint16_t lineSensorData[5U]; /**< Line sensor data [digits] normalized to max 1000 digits. */ } __attribute__((packed)) LineSensorData; -/** Struct of the "Turtle" channel payload. */ -typedef struct _TurtleSpeed -{ - int32_t linearCenter; /**< Linear speed of the vehicle center. [mm/s] */ - int32_t angular; /**< Angular speed. [mrad/s] */ -} __attribute__((packed)) TurtleSpeed; - /****************************************************************************** * Functions *****************************************************************************/