Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: High-rate IMU sampling #8731

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/configs/nuttx_px4fmu-v2_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(config_module_list
drivers/led
drivers/lsm303d
drivers/magnetometer/hmc5883
drivers/magnetometer/lis3mdl
#drivers/magnetometer/lis3mdl
#drivers/mb12xx
#drivers/mkblctrl
drivers/mpu6000
Expand Down
4 changes: 2 additions & 2 deletions cmake/configs/nuttx_px4fmu-v3_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ set(config_module_list
drivers/distance_sensor
drivers/magnetometer

drivers/adis16448
#drivers/adis16448
drivers/airspeed
drivers/blinkm
drivers/bmi160
#drivers/bmi160
drivers/boards
drivers/bst
drivers/camera_trigger
Expand Down
3 changes: 3 additions & 0 deletions msg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ set(msg_files
safety.msg
satellite_info.msg
sensor_accel.msg
sensor_accel_unfiltered.msg
sensor_baro.msg
sensor_bias.msg
sensor_combined.msg
sensor_correction.msg
sensor_gyro.msg
sensor_gyro_control.msg
sensor_gyro_unfiltered.msg
sensor_mag.msg
sensor_preflight.msg
sensor_selection.msg
Expand Down
9 changes: 4 additions & 5 deletions msg/sensor_accel.msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
uint64 integral_dt # integration time
uint64 error_count
int16 x_raw
int16 y_raw
int16 z_raw
int16 temperature_raw
float32 x # acceleration in the NED X board axis in m/s^2
float32 y # acceleration in the NED Y board axis in m/s^2
float32 z # acceleration in the NED Z board axis in m/s^2
Expand All @@ -10,9 +14,4 @@ float32 temperature # temperature in degrees celsius
float32 range_m_s2 # range in m/s^2 (+- this value)
float32 scaling

int16 x_raw
int16 y_raw
int16 z_raw
int16 temperature_raw

uint32 device_id # unique device ID for the sensor that does not change between power cycles
5 changes: 5 additions & 0 deletions msg/sensor_accel_unfiltered.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# unfiltered accel data used for logging, published at the highest rate possible if enabled

float32 x
float32 y
float32 z
11 changes: 6 additions & 5 deletions msg/sensor_gyro.msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# low-rate gyro message used for estimation and corrections

uint64 integral_dt # integration time
uint64 error_count
int16 x_raw
int16 y_raw
int16 z_raw
int16 temperature_raw
float32 x # angular velocity in the NED X board axis in rad/s
float32 y # angular velocity in the NED Y board axis in rad/s
float32 z # angular velocity in the NED Z board axis in rad/s
Expand All @@ -10,9 +16,4 @@ float32 temperature # temperature in degrees celcius
float32 range_rad_s
float32 scaling

int16 x_raw
int16 y_raw
int16 z_raw
int16 temperature_raw

uint32 device_id # unique device ID for the sensor that does not change between power cycles
7 changes: 7 additions & 0 deletions msg/sensor_gyro_control.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# high-rate gyro message used for rate control

float32 x # angular velocity in the NED X board axis in rad/s
float32 y # angular velocity in the NED Y board axis in rad/s
float32 z # angular velocity in the NED Z board axis in rad/s

uint32 device_id # unique device ID for the sensor that does not change between power cycles
5 changes: 5 additions & 0 deletions msg/sensor_gyro_unfiltered.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# unfiltered gyro data used for logging, published at the highest rate possible if enabled

float32 x
float32 y
float32 z
2 changes: 2 additions & 0 deletions src/drivers/drv_accel.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
#define ACCEL2_DEVICE_PATH "/dev/accel2"

#include <uORB/topics/sensor_accel.h>
#include <uORB/topics/sensor_accel_unfiltered.h>
#define accel_report sensor_accel_s
#define accel_unfiltered_report sensor_accel_unfiltered_s
Copy link
Member

Choose a reason for hiding this comment

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

I think we can stop doing this now.


/** accel scaling factors; Vout = Vscale * (Vin + Voffset) */
struct accel_calibration_s {
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/drv_gyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
#define GYRO2_DEVICE_PATH "/dev/gyro2"

#include <uORB/topics/sensor_gyro.h>
#include <uORB/topics/sensor_gyro_control.h>
#include <uORB/topics/sensor_gyro_unfiltered.h>
#define gyro_report sensor_gyro_s
#define gyro_control_report sensor_gyro_control_s
#define gyro_unfiltered_report sensor_gyro_unfiltered_s

/** gyro scaling factors; Vout = (Vin * Vscale) + Voffset */
struct gyro_calibration_s {
Expand Down
28 changes: 12 additions & 16 deletions src/drivers/l3gd20/l3gd20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,41 +986,37 @@ L3GD20::measure()
report.timestamp = hrt_absolute_time();
report.error_count = perf_event_count(_bad_registers);

float xraw_f = raw_report.x;
float yraw_f = raw_report.y;
float zraw_f = raw_report.z;

switch (_orientation) {

case SENSOR_BOARD_ROTATION_000_DEG:
/* keep axes in place */
report.x_raw = raw_report.x;
report.y_raw = raw_report.y;
break;

case SENSOR_BOARD_ROTATION_090_DEG:
/* swap x and y */
report.x_raw = raw_report.y;
report.y_raw = raw_report.x;
xraw_f = raw_report.y;
yraw_f = raw_report.x;
break;

case SENSOR_BOARD_ROTATION_180_DEG:
/* swap x and y and negate both */
report.x_raw = ((raw_report.x == -32768) ? 32767 : -raw_report.x);
report.y_raw = ((raw_report.y == -32768) ? 32767 : -raw_report.y);
xraw_f = ((raw_report.x == -32768) ? 32767 : -raw_report.x);
yraw_f = ((raw_report.y == -32768) ? 32767 : -raw_report.y);
break;

case SENSOR_BOARD_ROTATION_270_DEG:
/* swap x and y and negate y */
report.x_raw = raw_report.y;
report.y_raw = ((raw_report.x == -32768) ? 32767 : -raw_report.x);
xraw_f = raw_report.y;
yraw_f = ((raw_report.x == -32768) ? 32767 : -raw_report.x);
break;
}

report.z_raw = raw_report.z;

report.temperature_raw = raw_report.temp;

float xraw_f = report.x_raw;
float yraw_f = report.y_raw;
float zraw_f = report.z_raw;

// apply user specified rotation
rotate_3f(_rotation, xraw_f, yraw_f, zraw_f);

Expand Down Expand Up @@ -1255,10 +1251,10 @@ test()
warnx("gyro y: \t% 9.5f\trad/s", (double)g_report.y);
warnx("gyro z: \t% 9.5f\trad/s", (double)g_report.z);
warnx("temp: \t%d\tC", (int)g_report.temperature);
warnx("gyro x: \t%d\traw", (int)g_report.x_raw);
/*warnx("gyro x: \t%d\traw", (int)g_report.x_raw);
warnx("gyro y: \t%d\traw", (int)g_report.y_raw);
warnx("gyro z: \t%d\traw", (int)g_report.z_raw);
warnx("temp: \t%d\traw", (int)g_report.temperature_raw);
warnx("temp: \t%d\traw", (int)g_report.temperature_raw);*/
warnx("gyro range: %8.4f rad/s (%d deg/s)", (double)g_report.range_rad_s,
(int)((g_report.range_rad_s / M_PI_F) * 180.0f + 0.5f));

Expand Down
Loading