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/AntennaTracker/Log.cpp
Views: 1798
#include "Tracker.h"12#if HAL_LOGGING_ENABLED34// Code to Write and Read packets from AP_Logger log memory56// Write an attitude packet7void Tracker::Log_Write_Attitude()8{9const Vector3f targets{0.0f, nav_status.pitch, nav_status.bearing};10ahrs.Write_Attitude(targets);11AP::ahrs().Log_Write();12}1314struct PACKED log_Vehicle_Baro {15LOG_PACKET_HEADER;16uint64_t time_us;17float press;18float alt_diff;19};2021// Write a vehicle baro packet22void Tracker::Log_Write_Vehicle_Baro(float pressure, float altitude)23{24struct log_Vehicle_Baro pkt = {25LOG_PACKET_HEADER_INIT(LOG_V_BAR_MSG),26time_us : AP_HAL::micros64(),27press : pressure,28alt_diff : altitude29};30logger.WriteBlock(&pkt, sizeof(pkt));31}3233struct PACKED log_Vehicle_Pos {34LOG_PACKET_HEADER;35uint64_t time_us;36int32_t vehicle_lat;37int32_t vehicle_lng;38int32_t vehicle_alt;39float vehicle_vel_x;40float vehicle_vel_y;41float vehicle_vel_z;42};4344// Write a vehicle pos packet45void Tracker::Log_Write_Vehicle_Pos(int32_t lat, int32_t lng, int32_t alt, const Vector3f& vel)46{47struct log_Vehicle_Pos pkt = {48LOG_PACKET_HEADER_INIT(LOG_V_POS_MSG),49time_us : AP_HAL::micros64(),50vehicle_lat : lat,51vehicle_lng : lng,52vehicle_alt : alt,53vehicle_vel_x : vel.x,54vehicle_vel_y : vel.y,55vehicle_vel_z : vel.z,56};57logger.WriteBlock(&pkt, sizeof(pkt));58}5960// @LoggerMessage: VBAR61// @Description: Information received from tracked vehicle; barometer data62// @Field: TimeUS: Time since system startup63// @Field: Press: vehicle barometric pressure64// @Field: AltDiff: altitude difference based on difference on barometric pressure6566// @LoggerMessage: VPOS67// @Description: Information received from tracked vehicle; barometer position data68// @Field: TimeUS: Time since system startup69// @Field: Lat: tracked vehicle latitude70// @Field: Lng: tracked vehicle longitude71// @Field: Alt: tracked vehicle altitude72// @Field: VelX: tracked vehicle velocity, latitude component73// @Field: VelY: tracked vehicle velocity, longitude component74// @Field: VelZ: tracked vehicle velocity, vertical component, down7576// type and unit information can be found in77// libraries/AP_Logger/Logstructure.h; search for "log_Units" for78// units and "Format characters" for field type information79const struct LogStructure Tracker::log_structure[] = {80LOG_COMMON_STRUCTURES,81{LOG_V_BAR_MSG, sizeof(log_Vehicle_Baro),82"VBAR", "Qff", "TimeUS,Press,AltDiff", "sPm", "F00" , true },83{LOG_V_POS_MSG, sizeof(log_Vehicle_Pos),84"VPOS", "QLLefff", "TimeUS,Lat,Lng,Alt,VelX,VelY,VelZ", "sddmnnn", "FGGB000", true }85};8687uint8_t Tracker::get_num_log_structures() const88{89return ARRAY_SIZE(log_structure);90}9192void Tracker::Log_Write_Vehicle_Startup_Messages()93{94logger.Write_Mode((uint8_t)mode->number(), ModeReason::INITIALISED);95gps.Write_AP_Logger_Log_Startup_messages();96}9798#endif // HAL_LOGGING_ENABLED99100101