mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 06:23:34 +08:00
Fixed to mag measurement and filter
This commit is contained in:
@@ -612,8 +612,8 @@ HMC5883::collect()
|
|||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct { /* status register and data as read back from the device */
|
struct { /* status register and data as read back from the device */
|
||||||
uint8_t x[2];
|
uint8_t x[2];
|
||||||
uint8_t y[2];
|
|
||||||
uint8_t z[2];
|
uint8_t z[2];
|
||||||
|
uint8_t y[2];
|
||||||
} hmc_report;
|
} hmc_report;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
struct {
|
struct {
|
||||||
@@ -833,7 +833,7 @@ test()
|
|||||||
err(1, "immediate read failed");
|
err(1, "immediate read failed");
|
||||||
|
|
||||||
warnx("single read");
|
warnx("single read");
|
||||||
warnx("measurement: %.6f %.6f %.6f", report.x, report.y, report.z);
|
warnx("measurement: %.6f %.6f %.6f", (double)report.x, (double)report.y, (double)report.z);
|
||||||
warnx("time: %lld", report.timestamp);
|
warnx("time: %lld", report.timestamp);
|
||||||
|
|
||||||
/* set the queue depth to 10 */
|
/* set the queue depth to 10 */
|
||||||
@@ -863,7 +863,7 @@ test()
|
|||||||
err(1, "periodic read failed");
|
err(1, "periodic read failed");
|
||||||
|
|
||||||
warnx("periodic read %u", i);
|
warnx("periodic read %u", i);
|
||||||
warnx("measurement: %.6f %.6f %.6f", report.x, report.y, report.z);
|
warnx("measurement: %.6f %.6f %.6f", (double)report.x, (double)report.y, (double)report.z);
|
||||||
warnx("time: %lld", report.timestamp);
|
warnx("time: %lld", report.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-19
@@ -943,32 +943,15 @@ static void *uorb_receiveloop(void *arg)
|
|||||||
/* Only send in HIL mode */
|
/* Only send in HIL mode */
|
||||||
if (mavlink_hil_enabled) {
|
if (mavlink_hil_enabled) {
|
||||||
|
|
||||||
/* hacked HIL implementation in order for the APM Planner to work
|
|
||||||
* (correct cmd: mavlink_msg_hil_controls_send())
|
|
||||||
*/
|
|
||||||
|
|
||||||
mavlink_msg_rc_channels_scaled_send(chan,
|
|
||||||
hrt_absolute_time(),
|
|
||||||
0, // port 0
|
|
||||||
buf.att_sp.roll_body,
|
|
||||||
buf.att_sp.pitch_body,
|
|
||||||
buf.att_sp.thrust,
|
|
||||||
buf.att_sp.yaw_body,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1 /*rssi=1*/);
|
|
||||||
|
|
||||||
/* translate the current syste state to mavlink state and mode */
|
/* translate the current syste state to mavlink state and mode */
|
||||||
uint8_t mavlink_state = 0;
|
uint8_t mavlink_state = 0;
|
||||||
uint8_t mavlink_mode = 0;
|
uint8_t mavlink_mode = 0;
|
||||||
get_mavlink_mode_and_state(&v_status, &armed, &mavlink_state, &mavlink_mode);
|
get_mavlink_mode_and_state(&v_status, &armed, &mavlink_state, &mavlink_mode);
|
||||||
|
|
||||||
/* correct HIL message as per MAVLink spec */
|
/* HIL message as per MAVLink spec */
|
||||||
mavlink_msg_hil_controls_send(chan,
|
mavlink_msg_hil_controls_send(chan,
|
||||||
hrt_absolute_time(),
|
hrt_absolute_time(),
|
||||||
buf.att_sp.roll_body,
|
buf.att_sp.roll_body, /* this may be replaced by ctrl0 later */
|
||||||
buf.att_sp.pitch_body,
|
buf.att_sp.pitch_body,
|
||||||
buf.att_sp.yaw_body,
|
buf.att_sp.yaw_body,
|
||||||
buf.att_sp.thrust,
|
buf.att_sp.thrust,
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ int attitude_estimator_bm_main(int argc, char *argv[])
|
|||||||
att.timestamp = sensor_combined_s_local.timestamp;
|
att.timestamp = sensor_combined_s_local.timestamp;
|
||||||
att.roll = euler.x;
|
att.roll = euler.x;
|
||||||
att.pitch = euler.y;
|
att.pitch = euler.y;
|
||||||
att.yaw = euler.z - M_PI_F;
|
att.yaw = euler.z;
|
||||||
|
|
||||||
if (att.yaw > M_PI_F) {
|
if (att.yaw > M_PI_F) {
|
||||||
att.yaw -= 2.0f * M_PI_F;
|
att.yaw -= 2.0f * M_PI_F;
|
||||||
|
|||||||
Reference in New Issue
Block a user