Skip to content

Commit

Permalink
commander : warn if more than 3 mags are connected and start only 3 o…
Browse files Browse the repository at this point in the history
…n Pixhawk 2
  • Loading branch information
mhkabir committed Apr 19, 2017
1 parent 349a468 commit dee14e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions ROMFS/px4fmu_common/init.d/rc.sensors
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ then
then
fi

# We don't start this mag on the Pixhawk 2, because we do not realistically
# need more than 3 mags online (2 internal + 1 external in the GPS unit)

# external LSM303D is rotated 270 degrees yaw
if lsm303d -X -R 6 start
then
fi
# if lsm303d -X -R 6 start
# then
# fi

# internal MPU6000 is rotated 180 deg roll, 270 deg yaw
if mpu6000 -R 14 start
Expand Down
7 changes: 6 additions & 1 deletion src/modules/commander/mag_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,12 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
// We should not try to subscribe if the topic doesn't actually exist and can be counted.
const unsigned mag_count = orb_group_count(ORB_ID(sensor_mag));

for (unsigned cur_mag = 0; cur_mag < mag_count; cur_mag++) {
// Warn that we will not calibrate more than max_mags magnetometers
if (mag_count > max_mags) {
calibration_log_critical(mavlink_log_pub, "[cal] Detected %u mags, but will calibrate only %u", mag_count, max_mags);
}

for (unsigned cur_mag = 0; cur_mag < mag_count && cur_mag < max_mags; cur_mag++) {
// Mag in this slot is available
worker_data.sub_mag[cur_mag] = orb_subscribe_multi(ORB_ID(sensor_mag), cur_mag);

Expand Down

0 comments on commit dee14e2

Please sign in to comment.