Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AC_AttitudeControl/AC_AttitudeControl_Logging.cpp
Views: 1798
#include <AP_Logger/AP_Logger_config.h>12#if HAL_LOGGING_ENABLED34#include "AC_AttitudeControl.h"5#include "AC_PosControl.h"6#include <AP_Logger/AP_Logger.h>7#include <AP_Scheduler/AP_Scheduler.h>8#include "LogStructure.h"910// Write an ANG packet11void AC_AttitudeControl::Write_ANG() const12{13Vector3f targets = get_att_target_euler_rad() * RAD_TO_DEG;1415const struct log_ANG pkt{16LOG_PACKET_HEADER_INIT(LOG_ANG_MSG),17time_us : AP::scheduler().get_loop_start_time_us(),18control_roll : targets.x,19roll : degrees(_ahrs.roll),20control_pitch : targets.y,21pitch : degrees(_ahrs.pitch),22control_yaw : wrap_360(targets.z),23yaw : wrap_360(degrees(_ahrs.yaw)),24sensor_dt : AP::scheduler().get_last_loop_time_s()25};26AP::logger().WriteBlock(&pkt, sizeof(pkt));27}2829// Write a rate packet30void AC_AttitudeControl::Write_Rate(const AC_PosControl &pos_control) const31{32const Vector3f rate_targets = rate_bf_targets() * RAD_TO_DEG;33const Vector3f &accel_target = pos_control.get_accel_target_cmss();34const Vector3f gyro_rate = _rate_gyro * RAD_TO_DEG;35const struct log_Rate pkt_rate{36LOG_PACKET_HEADER_INIT(LOG_RATE_MSG),37time_us : _rate_gyro_time_us,38control_roll : rate_targets.x,39roll : gyro_rate.x,40roll_out : _motors.get_roll()+_motors.get_roll_ff(),41control_pitch : rate_targets.y,42pitch : gyro_rate.y,43pitch_out : _motors.get_pitch()+_motors.get_pitch_ff(),44control_yaw : rate_targets.z,45yaw : gyro_rate.z,46yaw_out : _motors.get_yaw()+_motors.get_yaw_ff(),47control_accel : (float)accel_target.z,48accel : (float)(-(_ahrs.get_accel_ef().z + GRAVITY_MSS) * 100.0f),49accel_out : _motors.get_throttle(),50throttle_slew : _motors.get_throttle_slew_rate()51};52AP::logger().WriteBlock(&pkt_rate, sizeof(pkt_rate));5354/*55log P/PD gain scale if not == 1.056*/57const Vector3f &scale = get_last_angle_P_scale();58const Vector3f &pd_scale = _pd_scale_used;59if (scale != AC_AttitudeControl::VECTORF_111 || pd_scale != AC_AttitudeControl::VECTORF_111) {60const struct log_ATSC pkt_ATSC {61LOG_PACKET_HEADER_INIT(LOG_ATSC_MSG),62time_us : _rate_gyro_time_us,63scaleP_x : scale.x,64scaleP_y : scale.y,65scaleP_z : scale.z,66scalePD_x : pd_scale.x,67scalePD_y : pd_scale.y,68scalePD_z : pd_scale.z,69};70AP::logger().WriteBlock(&pkt_ATSC, sizeof(pkt_ATSC));71}72}7374#endif // HAL_LOGGING_ENABLED757677