Skip to content

Commit

Permalink
SITL: add logging for x8 inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bnsgeyer committed Jun 7, 2024
1 parent 0e095fe commit a7a96f7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion libraries/SITL/SIM_Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <AP_Filesystem/AP_Filesystem.h>
#include "SIM_Aircraft.h"
#include <GCS_MAVLink/GCS.h>
#include <AP_Logger/AP_Logger.h>

#include <stdio.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -719,7 +720,11 @@ void Frame::calculate_forces_x8(const Aircraft &aircraft,
static float Dcollag;
static float Dpedlag;


float dlat_in = (servos_raw[0] / 500.0f) - 3.0f; // roll
float dlong_in = (servos_raw[1] / 500.0f) - 3.0f; //pitch
float dthr_in = (servos_raw[2] / 1000.0f) - 1.0f; // throttle
float dped_in = (servos_raw[3] / 500.0f) - 3.0f; // yaw
Log_Write_SimData(dlong_in, dlat_in, dthr_in, dped_in);

float _roll_in = (_servos_delayed[0] / 500.0f) - 3.0f; // roll
float _pitch_in = (_servos_delayed[1] / 500.0f) - 3.0f; //pitch
Expand Down Expand Up @@ -836,3 +841,25 @@ void Frame::pull_from_buffer_ped(uint16_t &servo_delayed)
servo_delayed = sample.servo;
}

void Frame::Log_Write_SimData(float dlong, float dlat, float dthr, float dped)
{
// @LoggerMessage: SIMD
// @Description: Sim data packet
// @Vehicles: Copter
// @Field: TimeUS: Time since system startup
// @Field: dlng: longitudinal input
// @Field: dlat: lateral input
// @Field: dthr: throttle input
// @Field: dped: pedal input
AP::logger().WriteStreaming(
"SIMD",
"TimeUS,dlng,dlat,dthr,dped",
"s----",
"F0000",
"Qffff",
AP_HAL::micros64(),
dlong,
dlat,
dthr,
dped);
}
1 change: 1 addition & 0 deletions libraries/SITL/SIM_Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,6 @@ class Frame {
void push_to_buffer_col(const uint16_t servos_input[16]);
void pull_from_buffer_col(uint16_t &servo_delayed);

void Log_Write_SimData(float dlong, float dlat, float dthr, float dped);
};
}

0 comments on commit a7a96f7

Please sign in to comment.