Skip to content

Commit

Permalink
Add gyro/accel bias for imu pub.
Browse files Browse the repository at this point in the history
Co-authored-by: James Goppert <[email protected]>
Signed-off-by: Benjamin Perseghetti <[email protected]>
  • Loading branch information
bperseghetti and jgoppert committed Oct 23, 2024
1 parent 38d0da2 commit f3ecaa2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/sense/imu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,15 @@ void imu_publish(context_t *ctx)
{
// update message
stamp_msg(&ctx->imu.stamp, k_uptime_ticks());
ctx->imu.angular_velocity.x = ctx->gyro_raw[0];
ctx->imu.angular_velocity.y = ctx->gyro_raw[1];
ctx->imu.angular_velocity.z = ctx->gyro_raw[2];
ctx->imu.linear_acceleration.x = ctx->accel_raw[0] / ctx->accel_scale;
ctx->imu.linear_acceleration.y = ctx->accel_raw[1] / ctx->accel_scale;
ctx->imu.linear_acceleration.z = ctx->accel_raw[2] / ctx->accel_scale;
ctx->imu.angular_velocity.x = ctx->gyro_raw[0] - ctx->gyro_bias[0];
ctx->imu.angular_velocity.y = ctx->gyro_raw[1] - ctx->gyro_bias[1];
ctx->imu.angular_velocity.z = ctx->gyro_raw[2] - ctx->gyro_bias[2];
ctx->imu.linear_acceleration.x =
(ctx->accel_raw[0] - ctx->accel_bias[0]) / ctx->accel_scale;
ctx->imu.linear_acceleration.y =
(ctx->accel_raw[1] - ctx->accel_bias[1]) / ctx->accel_scale;
ctx->imu.linear_acceleration.z =
(ctx->accel_raw[2] - ctx->accel_bias[2]) / ctx->accel_scale;

// publish message
zros_pub_update(&ctx->pub_imu);
Expand Down

0 comments on commit f3ecaa2

Please sign in to comment.