Skip to content

Commit

Permalink
Fix IMU merge conflicts in NUsenseIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Dex K committed Mar 29, 2024
1 parent e89efc4 commit 84236e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
15 changes: 8 additions & 7 deletions NUsenseCpp/Core/Src/platform/NUsense/NUsenseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ namespace platform::NUsense {
/// to serialise and sent to the NUC
message_platform_NUSense nusense_msg;

/// TODO: DMA implementation of IMU conversion in one function
/// @brief The container for decoded IMU values (float)
NU_IMU_converted_data converted_data;
// @brief The IMU instance
// @note The namespacing is gross af and needs to be fixed
::NUsense::IMU imu;

/// @brief The container for raw IMU values (int16_t's)
NU_IMU_raw_data raw_data;
/// @brief The container for decoded IMU values (float)
::NUsense::IMU::ConvertedData converted_data;

/// @brief Container for the raw data received IMU ReadBurst calls
uint8_t IMU_rx[14];
Expand Down Expand Up @@ -116,13 +116,14 @@ namespace platform::NUsense {
dynamixel::PacketHandler(ports[3]),
dynamixel::PacketHandler(ports[4]),
dynamixel::PacketHandler(ports[5])})
, nuc() {
, nuc()
, imu() {
// Begin at the beginning of the chains.
chain_indices.fill(0);
// Initialise our nanopb struct to init_zero
nusense_msg = message_platform_NUSense_init_zero;
// Begin IMU for polling
NU_IMU_Init();
imu.init();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@

namespace platform::NUsense {
bool NUsenseIO::nusense_to_nuc() {
NU_IMU_ReadBurst(ACCEL_XOUT_H, IMU_rx, 14);

raw_data.accelerometer.x = ((uint16_t) IMU_rx[0] << 8) | IMU_rx[1];
raw_data.accelerometer.y = ((uint16_t) IMU_rx[2] << 8) | IMU_rx[3];
raw_data.accelerometer.z = ((uint16_t) IMU_rx[4] << 8) | IMU_rx[5];
raw_data.temperature = ((uint16_t) IMU_rx[6] << 8) | IMU_rx[7];
raw_data.gyroscope.x = ((uint16_t) IMU_rx[8] << 8) | IMU_rx[9];
raw_data.gyroscope.y = ((uint16_t) IMU_rx[10] << 8) | IMU_rx[11];
raw_data.gyroscope.z = ((uint16_t) IMU_rx[12] << 8) | IMU_rx[13];

NU_IMU_ConvertRawData(&raw_data, &converted_data);
// Get a new lot of IMU data
converted_data = imu.getNewConvertedData();

// TODO: (JohanneMontano) Handle IMU read and conversions if it fails
// Fill the struct with the values we converted from the IMU output
Expand Down

0 comments on commit 84236e9

Please sign in to comment.