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_PosControl_Logging.cpp
Views: 1798
#include <AP_Logger/AP_Logger_config.h>12#if HAL_LOGGING_ENABLED34#include "AC_PosControl.h"56#include <AP_Logger/AP_Logger.h>7#include "LogStructure.h"89// a convenience function for writing out the position controller PIDs10void AC_PosControl::Write_PSCx(LogMessages id, float pos_desired, float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel)11{12const struct log_PSCx pkt{13LOG_PACKET_HEADER_INIT(id),14time_us : AP_HAL::micros64(),15pos_desired : pos_desired * 0.01f,16pos_target : pos_target * 0.01f,17pos : pos * 0.01f,18vel_desired : vel_desired * 0.01f,19vel_target : vel_target * 0.01f,20vel : vel * 0.01f,21accel_desired : accel_desired * 0.01f,22accel_target : accel_target * 0.01f,23accel : accel * 0.01f24};25AP::logger().WriteBlock(&pkt, sizeof(pkt));26}2728void AC_PosControl::Write_PSCN(float pos_desired, float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel)29{30Write_PSCx(LOG_PSCN_MSG, pos_desired, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel);31}3233void AC_PosControl::Write_PSCE(float pos_desired, float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel)34{35Write_PSCx(LOG_PSCE_MSG, pos_desired, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel);36}3738void AC_PosControl::Write_PSCD(float pos_desired, float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel)39{40Write_PSCx(LOG_PSCD_MSG, pos_desired, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel);41}4243// a convenience function for writing out the position controller offsets44void AC_PosControl::Write_PSOx(LogMessages id, float pos_target_offset_cm, float pos_offset_cm,45float vel_target_offset_cms, float vel_offset_cms,46float accel_target_offset_cmss, float accel_offset_cmss)47{48const struct log_PSOx pkt{49LOG_PACKET_HEADER_INIT(id),50time_us : AP_HAL::micros64(),51pos_target_offset : pos_target_offset_cm * 0.01f,52pos_offset : pos_offset_cm * 0.01f,53vel_target_offset : vel_target_offset_cms * 0.01f,54vel_offset : vel_offset_cms * 0.01f,55accel_target_offset : accel_target_offset_cmss * 0.01f,56accel_offset : accel_offset_cmss * 0.01f,57};58AP::logger().WriteBlock(&pkt, sizeof(pkt));59}6061void AC_PosControl::Write_PSON(float pos_target_offset_cm, float pos_offset_cm,62float vel_target_offset_cms, float vel_offset_cms,63float accel_target_offset_cmss, float accel_offset_cmss)64{65Write_PSOx(LOG_PSON_MSG, pos_target_offset_cm, pos_offset_cm, vel_target_offset_cms, vel_offset_cms, accel_target_offset_cmss, accel_offset_cmss);66}6768void AC_PosControl::Write_PSOE(float pos_target_offset_cm, float pos_offset_cm,69float vel_target_offset_cms, float vel_offset_cms,70float accel_target_offset_cmss, float accel_offset_cmss)71{72Write_PSOx(LOG_PSOE_MSG, pos_target_offset_cm, pos_offset_cm, vel_target_offset_cms, vel_offset_cms, accel_target_offset_cmss, accel_offset_cmss);73}7475void AC_PosControl::Write_PSOD(float pos_target_offset_cm, float pos_offset_cm,76float vel_target_offset_cms, float vel_offset_cms,77float accel_target_offset_cmss, float accel_offset_cmss)78{79Write_PSOx(LOG_PSOD_MSG, pos_target_offset_cm, pos_offset_cm, vel_target_offset_cms, vel_offset_cms, accel_target_offset_cmss, accel_offset_cmss);80}8182void AC_PosControl::Write_PSOT(float pos_target_offset_cm, float pos_offset_cm,83float vel_target_offset_cms, float vel_offset_cms,84float accel_target_offset_cmss, float accel_offset_cmss)85{86Write_PSOx(LOG_PSOT_MSG, pos_target_offset_cm, pos_offset_cm, vel_target_offset_cms, vel_offset_cms, accel_target_offset_cmss, accel_offset_cmss);87}8889#endif // HAL_LOGGING_ENABLED909192