diff --git a/APMrover2/APMrover2.cpp b/APMrover2/APMrover2.cpp index 1cf2ffe874..65b6c6b6bb 100644 --- a/APMrover2/APMrover2.cpp +++ b/APMrover2/APMrover2.cpp @@ -253,8 +253,8 @@ void Rover::update_logging1(void) Log_Write_Attitude(); } - if (should_log(MASK_LOG_CTUN)) { - Log_Write_Control_Tuning(); + if (should_log(MASK_LOG_THR)) { + Log_Write_Throttle(); Log_Write_Beacon(); } diff --git a/APMrover2/Log.cpp b/APMrover2/Log.cpp index d353a2c61b..333aadbdb1 100644 --- a/APMrover2/Log.cpp +++ b/APMrover2/Log.cpp @@ -94,27 +94,29 @@ void Rover::Log_Write_Startup(uint8_t type) DataFlash.WriteBlock(&pkt, sizeof(pkt)); } -struct PACKED log_Control_Tuning { +struct PACKED log_Throttle { LOG_PACKET_HEADER; uint64_t time_us; - int16_t steer_out; - int16_t roll; - int16_t pitch; - int16_t throttle_out; + int16_t throttle_in; + float throttle_out; + float desired_speed; + float speed; float accel_y; }; -// Write a control tuning packet. Total length : 22 bytes -void Rover::Log_Write_Control_Tuning() +// Write a throttle control packet +void Rover::Log_Write_Throttle() { const Vector3f accel = ins.get_accel(); - struct log_Control_Tuning pkt = { - LOG_PACKET_HEADER_INIT(LOG_CTUN_MSG), + float speed = DataFlash.quiet_nanf(); + g2.attitude_control.get_forward_speed(speed); + struct log_Throttle pkt = { + LOG_PACKET_HEADER_INIT(LOG_THR_MSG), time_us : AP_HAL::micros64(), - steer_out : (int16_t)g2.motors.get_steering(), - roll : (int16_t)ahrs.roll_sensor, - pitch : (int16_t)ahrs.pitch_sensor, - throttle_out : (int16_t)g2.motors.get_throttle(), + throttle_in : channel_throttle->get_control_in(), + throttle_out : g2.motors.get_throttle(), + desired_speed : g2.attitude_control.get_desired_speed(), + speed : speed, accel_y : accel.y }; DataFlash.WriteBlock(&pkt, sizeof(pkt)); @@ -348,8 +350,8 @@ const LogStructure Rover::log_structure[] = { "PM", "QIHIhhhBHI", "TimeUS,LTime,MLC,gDt,GDx,GDy,GDz,I2CErr,INSErr,Mem", "ss-------b", "FC-------0" }, { LOG_STARTUP_MSG, sizeof(log_Startup), "STRT", "QBH", "TimeUS,SType,CTot", "s--", "F--" }, - { LOG_CTUN_MSG, sizeof(log_Control_Tuning), - "CTUN", "Qhcchf", "TimeUS,Steer,Roll,Pitch,ThrOut,AccY", "s-dd-o", "F-BB-0" }, + { LOG_THR_MSG, sizeof(log_Throttle), + "THR", "Qhffff", "TimeUS,ThrIn,ThrOut,DesSpeed,Speed,AccY", "s--nno", "F--000" }, { LOG_NTUN_MSG, sizeof(log_Nav_Tuning), "NTUN", "QHfHHbf", "TimeUS,Yaw,WpDist,TargBrg,NavBrg,Thr,XT", "sdmdd-m", "FB0BB-0" }, { LOG_RANGEFINDER_MSG, sizeof(log_Rangefinder), @@ -387,7 +389,7 @@ void Rover::Log_Write_Startup(uint8_t type) {} void Rover::Log_Write_Current() {} void Rover::Log_Write_Nav_Tuning() {} void Rover::Log_Write_Performance() {} -void Rover::Log_Write_Control_Tuning() {} +void Rover::Log_Write_Throttle() {} void Rover::Log_Write_Rangefinder() {} void Rover::Log_Write_Attitude() {} void Rover::Log_Write_RC(void) {} diff --git a/APMrover2/Parameters.cpp b/APMrover2/Parameters.cpp index e12a806214..8a707e0f97 100644 --- a/APMrover2/Parameters.cpp +++ b/APMrover2/Parameters.cpp @@ -28,7 +28,7 @@ const AP_Param::Info Rover::var_info[] = { // @DisplayName: Log bitmask // @Description: Bitmap of what log types to enable in dataflash. This values is made up of the sum of each of the log types you want to be saved on dataflash. On a PX4 or Pixhawk the large storage size of a microSD card means it is usually best just to enable all log types by setting this to 65535. On APM2 the smaller 4 MByte dataflash means you need to be more selective in your logging or you may run out of log space while flying (in which case it will wrap and overwrite the start of the log). The individual bits are ATTITUDE_FAST=1, ATTITUDE_MEDIUM=2, GPS=4, PerformanceMonitoring=8, ControlTuning=16, NavigationTuning=32, Mode=64, IMU=128, Commands=256, Battery=512, Compass=1024, TECS=2048, Camera=4096, RCandServo=8192, Rangefinder=16384, Arming=32768, FullLogs=65535 // @Values: 0:Disabled,5190:APM2-Default,65535:PX4/Pixhawk-Default - // @Bitmask: 0:ATTITUDE_FAST,1:ATTITUDE_MED,2:GPS,3:PM,4:CTUN,5:NTUN,7:IMU,8:CMD,9:CURRENT,10:RANGEFINDER,11:COMPASS,12:CAMERA,13:STEERING,14:RC,15:ARM/DISARM,19:IMU_RAW + // @Bitmask: 0:ATTITUDE_FAST,1:ATTITUDE_MED,2:GPS,3:PM,4:THR,5:NTUN,7:IMU,8:CMD,9:CURRENT,10:RANGEFINDER,11:COMPASS,12:CAMERA,13:STEERING,14:RC,15:ARM/DISARM,19:IMU_RAW // @User: Advanced GSCALAR(log_bitmask, "LOG_BITMASK", DEFAULT_LOG_BITMASK), diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index 250c2de741..5a069b60bf 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -501,7 +501,7 @@ private: void Log_Write_Steering(); void Log_Write_Beacon(); void Log_Write_Startup(uint8_t type); - void Log_Write_Control_Tuning(); + void Log_Write_Throttle(); void Log_Write_Nav_Tuning(); void Log_Write_Attitude(); void Log_Write_Rangefinder(); diff --git a/APMrover2/defines.h b/APMrover2/defines.h index fd88f64adb..612b1b2a0a 100644 --- a/APMrover2/defines.h +++ b/APMrover2/defines.h @@ -53,7 +53,7 @@ enum mode { #define FAILSAFE_EVENT_RC (1<<2) // Logging parameters -#define LOG_CTUN_MSG 0x01 +#define LOG_THR_MSG 0x01 #define LOG_NTUN_MSG 0x02 #define LOG_PERFORMANCE_MSG 0x03 #define LOG_STARTUP_MSG 0x06 @@ -71,7 +71,7 @@ enum mode { #define MASK_LOG_ATTITUDE_MED (1<<1) #define MASK_LOG_GPS (1<<2) #define MASK_LOG_PM (1<<3) -#define MASK_LOG_CTUN (1<<4) +#define MASK_LOG_THR (1<<4) #define MASK_LOG_NTUN (1<<5) //#define MASK_LOG_MODE (1<<6) // no longer used #define MASK_LOG_IMU (1<<7)