Skip to content

Commit 02dcc40

Browse files
authored
feat(RemoteControl): add IMU data (#230)
1 parent 9d7a19c commit 02dcc40

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

lib/APPRemoteControl/src/App.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,11 @@ void App_lineSensorChannelCallback(const uint8_t* payload, const uint8_t payload
458458
}
459459

460460
/**
461-
* Receives current position and heading of the robot over SerialMuxProt channel.
461+
* Receives current position, heading and IMU of the robot over SerialMuxProt channel.
462462
*
463-
* @param[in] payload Current vehicle data. Two coordinates, one orientation and two motor speeds.
464-
* @param[in] payloadSize Size of two coordinates, one orientation and two motor speeds.
463+
* @param[in] payload Current vehicle data: Timestamp, two coordinates, one orientation,
464+
* three motor speeds and raw IMU data (X acceleration, Z axis turn rate).
465+
* @param[in] payloadSize The size of the received payload data.
465466
* @param[in] userData Instance of App class.
466467
*/
467468
void App_currentVehicleChannelCallback(const uint8_t* payload, const uint8_t payloadSize, void* userData)
@@ -472,9 +473,10 @@ void App_currentVehicleChannelCallback(const uint8_t* payload, const uint8_t pay
472473
{
473474
const VehicleData* currentVehicleData = reinterpret_cast<const VehicleData*>(payload);
474475

475-
LOG_DEBUG("X: %d Y: %d Heading: %d Left: %d Right: %d Center: %d", currentVehicleData->xPos,
476-
currentVehicleData->yPos, currentVehicleData->orientation, currentVehicleData->left,
477-
currentVehicleData->right, currentVehicleData->center);
476+
LOG_DEBUG("Timestamp: %d X: %d Y: %d Heading: %d Left: %d Right: %d Center: %d AccX: %d TurnZ: %d ",
477+
currentVehicleData->timestamp, currentVehicleData->xPos, currentVehicleData->yPos,
478+
currentVehicleData->orientation, currentVehicleData->left, currentVehicleData->right,
479+
currentVehicleData->center, currentVehicleData->accelerationX, currentVehicleData->turnRateZ);
478480
}
479481
else
480482
{

lib/APPRemoteControl/src/SerialMuxChannels.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ typedef struct _CommandResponse
186186
};
187187
} __attribute__((packed)) CommandResponse;
188188

189-
static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN,
190-
"CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame.");
189+
static_assert(
190+
sizeof(CommandResponse) <= MAX_DATA_LEN,
191+
"CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame.");
191192

192193
/** Struct of the "Motor Speed Setpoints" channel payload. */
193194
typedef struct _MotorSpeed
@@ -212,13 +213,16 @@ static_assert(sizeof(RobotSpeed) <= MAX_DATA_LEN,
212213
/** Struct of the "Current Vehicle Data" channel payload. */
213214
typedef struct _VehicleData
214215
{
215-
int32_t xPos; /**< X position [mm]. */
216-
int32_t yPos; /**< Y position [mm]. */
217-
int32_t orientation; /**< Orientation [mrad]. */
218-
int32_t left; /**< Left motor speed [mm/s]. */
219-
int32_t right; /**< Right motor speed [mm/s]. */
220-
int32_t center; /**< Center speed [mm/s]. */
221-
SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */
216+
uint32_t timestamp; /**< Timestamp [ms]. */
217+
int32_t xPos; /**< X position [mm]. */
218+
int32_t yPos; /**< Y position [mm]. */
219+
int32_t orientation; /**< Orientation [mrad]. */
220+
int32_t left; /**< Left motor speed [mm/s]. */
221+
int32_t right; /**< Right motor speed [mm/s]. */
222+
int32_t center; /**< Center speed [mm/s]. */
223+
SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */
224+
int16_t accelerationX; /**< Raw acceleration in X [digit]. */
225+
int16_t turnRateZ; /**< Raw turn rate around Z [digit]. */
222226
} __attribute__((packed)) VehicleData;
223227

224228
static_assert(sizeof(VehicleData) <= MAX_DATA_LEN,
@@ -239,8 +243,9 @@ typedef struct _LineSensorData
239243
uint16_t lineSensorData[5U]; /**< Line sensor data [digits] normalized to max 1000 digits. */
240244
} __attribute__((packed)) LineSensorData;
241245

242-
static_assert(sizeof(LineSensorData) <= MAX_DATA_LEN,
243-
"LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame.");
246+
static_assert(
247+
sizeof(LineSensorData) <= MAX_DATA_LEN,
248+
"LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame.");
244249

245250
/******************************************************************************
246251
* Functions

0 commit comments

Comments
 (0)