Skip to content

IMU Integration#3739

Merged
StarrryNight merged 35 commits into
UBC-Thunderbots:masterfrom
StarrryNight:imu_integration
May 27, 2026
Merged

IMU Integration#3739
StarrryNight merged 35 commits into
UBC-Thunderbots:masterfrom
StarrryNight:imu_integration

Conversation

@StarrryNight
Copy link
Copy Markdown
Contributor

@StarrryNight StarrryNight commented May 23, 2026

Description

Port iintegration of IMU from #3716 , and added linear acceleration polling for future uses. Follow up PR will implement angular acceleration calculations and IMU calibration scripts. Also renamed some variables for clarity.

Testing Done

Resolved Issues

#3703

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Copy link
Copy Markdown
Member

@nycrat nycrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright so far, left some comments

Comment thread src/software/embedded/services/imu.h Outdated
Comment on lines +82 to +94
static const uint8_t WHOAMI_REG = 0xf;
static const uint8_t ACCEL_CONTROL_REG = 0x10;
static const uint8_t GYRO_CONTROL_REG = 0x11;
static const uint8_t CTRL4_C = 0x13;
static const uint8_t CTRL6_C = 0x15;
static const uint8_t CTRL8_XL = 0x17;

// Device path for the IMU
inline static const std::string IMU_DEVICE = "/dev/i2c-1";

// Gyroscope Z-axis (Yaw) Output Data Registers
static constexpr uint8_t GYRO_LEAST_SIG_REG = 0x26; // OUTZ_L_G
static constexpr uint8_t GYRO_MOST_SIG_REG = 0x27; // OUTZ_H_G
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be consistent, we should just use static constexpr for all the constants

Comment thread src/software/embedded/services/imu.h Outdated
*/
ImuService();

std::optional<ImuData> poll();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add doc comment

Comment thread src/software/embedded/services/imu.h Outdated
Comment on lines +40 to +44
/*
* Polls the latest IMU reading of the angular velocity of the robot on the z axis
* @return the current angular velocty of the robot on the z axis
*/
std::optional<AngularVelocity> pollAngularVelocity();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc comment should start with /**

Comment thread src/software/embedded/services/imu.cpp
Comment thread src/software/embedded/services/imu.cpp
Comment thread src/software/embedded/services/imu.cpp Outdated
Comment thread src/software/embedded/services/imu.cpp Outdated
Comment thread src/software/embedded/services/imu.cpp Outdated
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid, left some minor comments

Comment thread src/center_of_mass Outdated
Comment thread src/software/embedded/thunderloop.h Outdated
Comment thread src/software/embedded/thunderloop.cpp Outdated
@StarrryNight StarrryNight requested review from Andrewyx and nycrat May 27, 2026 02:19
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 💯

Copy link
Copy Markdown
Member

@nycrat nycrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good !

@StarrryNight StarrryNight merged commit d6347c4 into UBC-Thunderbots:master May 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants