Ardupilot2/libraries/AP_AHRS/AP_AHRS_View.cpp
Andrew Tridgell 1345bf8737 AC_AttitudeControl: added support for AP_AHRS_View
this allows for tailsitters with a different attitude view
2017-02-18 17:26:43 +11:00

46 lines
1.3 KiB
C++

/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* AHRS View class - for creating a 2nd view of the vehicle attitude
*
*/
#include "AP_AHRS_View.h"
AP_AHRS_View::AP_AHRS_View(AP_AHRS &_ahrs, enum Rotation _rotation) :
rotation(_rotation),
ahrs(_ahrs)
{
}
// update state
void AP_AHRS_View::update(void)
{
rot_body_to_ned = ahrs.get_rotation_body_to_ned();
gyro = ahrs.get_gyro();
rot_body_to_ned.to_euler(&roll, &pitch, &yaw);
roll_sensor = degrees(roll) * 100;
pitch_sensor = degrees(pitch) * 100;
yaw_sensor = degrees(yaw) * 100;
ahrs.calc_trig(rot_body_to_ned,
trig.cos_roll, trig.cos_pitch, trig.cos_yaw,
trig.sin_roll, trig.sin_pitch, trig.sin_yaw);
}