diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-18 12:08:39 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-18 12:11:05 +0100 |
commit | 16618f1adac7f33817fb968b285288beb360b012 (patch) | |
tree | b6181cbd01cb923023810b735c4bc6cb40c58b8e /src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp | |
parent | 4402d7106bc63b2a02a1e4c22f54e072b3c48fc7 (diff) | |
parent | 6e874bed50d6d8a13a3b7f9b883697cb2718d27b (diff) | |
download | px4-firmware-16618f1adac7f33817fb968b285288beb360b012.tar.gz px4-firmware-16618f1adac7f33817fb968b285288beb360b012.tar.bz2 px4-firmware-16618f1adac7f33817fb968b285288beb360b012.zip |
Merge remote-tracking branch 'upstream/master' into dev_ros
Conflicts:
src/examples/subscriber/subscriber_params.c
src/modules/mc_att_control/mc_att_control_main.cpp
src/modules/uORB/topics/vehicle_attitude.h
src/modules/uORB/topics/vehicle_attitude_setpoint.h
src/platforms/px4_middleware.h
Diffstat (limited to 'src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp')
-rwxr-xr-x | src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp index 9784ea1a1..4c64c88ae 100755 --- a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp +++ b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp @@ -571,6 +571,44 @@ const unsigned int loop_interval_alarm = 6500; // loop interval in microseconds memcpy(&att.R[0], &R.data[0][0], sizeof(att.R)); att.R_valid = true; + // compute secondary attitude + math::Matrix<3, 3> R_adapted; //modified rotation matrix + R_adapted = R; + + //move z to x + R_adapted(0, 0) = R(0, 2); + R_adapted(1, 0) = R(1, 2); + R_adapted(2, 0) = R(2, 2); + //move x to z + R_adapted(0, 2) = R(0, 0); + R_adapted(1, 2) = R(1, 0); + R_adapted(2, 2) = R(2, 0); + + //change direction of pitch (convert to right handed system) + R_adapted(0, 0) = -R_adapted(0, 0); + R_adapted(1, 0) = -R_adapted(1, 0); + R_adapted(2, 0) = -R_adapted(2, 0); + math::Vector<3> euler_angles_sec; //adapted euler angles for fixed wing operation + euler_angles_sec = R_adapted.to_euler(); + + att.roll_sec = euler_angles_sec(0); + att.pitch_sec = euler_angles_sec(1); + att.yaw_sec = euler_angles_sec(2); + + memcpy(&att.R_sec[0], &R_adapted.data[0], sizeof(att.R_sec)); + + att.rollspeed_sec = -x_aposteriori[2]; + att.pitchspeed_sec = x_aposteriori[1]; + att.yawspeed_sec = x_aposteriori[0]; + att.rollacc_sec = -x_aposteriori[5]; + att.pitchacc_sec = x_aposteriori[4]; + att.yawacc_sec = x_aposteriori[3]; + + att.g_comp_sec[0] = -raw.accelerometer_m_s2[2] - (-acc(2)); + att.g_comp_sec[1] = raw.accelerometer_m_s2[1] - acc(1); + att.g_comp_sec[2] = raw.accelerometer_m_s2[0] - acc(0); + + if (isfinite(att.roll) && isfinite(att.pitch) && isfinite(att.yaw)) { // Broadcast orb_publish(ORB_ID(vehicle_attitude), pub_att, &att); |