customize data logging content

207 views
Skip to first unread message

James Li

unread,
Sep 18, 2013, 1:55:15 PM9/18/13
to drones-...@googlegroups.com
The change is based on latest master branch of ArduPlane. The purpose is to obtain RCinput log, PWM output log alone with predefined imu log and attitude log. Then using the log in matlab for airplane system identification. 

In wiki and ardupilot site, the instruction shows that output is recorded with "motors" which is not defined yet in the ArduPlane yet. 

PLOG(ATTITUDE_FAST);
        PLOG(ATTITUDE_MED);
        PLOG(GPS);
        PLOG(PM);
        PLOG(CTUN);
        PLOG(NTUN);
        PLOG(MODE);
        PLOG(IMU);
        PLOG(CMD);
        PLOG(CURRENT);
        PLOG(COMPASS);
        PLOG(TECS);
        PLOG(CAMERA);


My attpemt is not the correct approach to obtain the data for sure. But it is not working either. So I wonder if I can get some help with understanding the code structure further and to modify the code. 

here's my fail approach. 

in Log.pde

struct PACKED log_Control_Tuning {
    LOG_PACKET_HEADER;
    int16_t nav_roll_cd;
    int16_t roll;
    int16_t nav_pitch_cd;
    int16_t pitch;
    int16_t throttle_out;
    int16_t rudder_out;
    int16_t roll_out; // add define for roll output
    int16_t pitch_out;  // add define for pitch output
    
    float   accel_y; 
};
// Write a control tuning packet. Total length : 22 bytes
static void Log_Write_Control_Tuning()
{
    Vector3f accel = ins.get_accel();
    struct log_Control_Tuning pkt = {
        LOG_PACKET_HEADER_INIT(LOG_CTUN_MSG),
        nav_roll_cd     : (int16_t)nav_roll_cd,
        roll            : (int16_t)ahrs.roll_sensor,
        nav_pitch_cd    : (int16_t)nav_pitch_cd,
        pitch           : (int16_t)ahrs.pitch_sensor,
        throttle_out    : (int16_t)channel_throttle->servo_out,
        rudder_out      : (int16_t)channel_rudder->servo_out,
        roll_out        : (int16_t)channel_roll->servo_out, // add string for roll output
        pitch_out       : (int16_t)channel_pitch->servo_out, // add string for pitch output
        accel_y         : accel.y
    };
    DataFlash.WriteBlock(&pkt, sizeof(pkt));
}
.............................................. 
 
    { LOG_CTUN_MSG, sizeof(log_Control_Tuning),     
      "CTUN", "cccchhf",    "NavRoll,Roll,NavPitch,Pitch,ThrOut,RdrOut,RolOut,PitOut,AccY" }, // add RolOut and PitOut for tab listing.

 
ArduPilot Arduino IDE does not want to compile this for error "unimplemented: non-trivial designated initializers not supported apm"


I changed to make under ubuntu. the firmware does compile. but in actual CTUN log, there are only the predefined ones being logged. the added pitch and roll is not logged. I believe I must have missed something alone the mod. It'd be great if some one can help me out with this. 






James Li

unread,
Sep 20, 2013, 3:21:35 PM9/20/13
to drones-...@googlegroups.com
update1..

successfully made a few changes to obtain pitch and roll output in one dedicate log page. But there is problem when adding throttle and rudder into the same message
mod info


when added throttle and rudder



//Write RC PWM output log
struct PACKED log_RCO {
    LOG_PACKET_HEADER;
    int16_t throttle_out;
    int16_t rudder_out;
    int16_t pitch_out;
    int16_t roll_out;
   
};

// Write a RCOutput packet. Total length : 
static void Log_Write_RCO()
{
        struct log_RCO pkt = {
        LOG_PACKET_HEADER_INIT(LOG_RCO_MSG),
        throttle_out    : (int16_t)channel_throttle->servo_out,
        pitch_out    : (int16_t)channel_pitch->servo_out,
        roll_out     : (int16_t)channel_roll->servo_out,
        rudder_out     : (int16_t)channel_rudder->servo_out,
    };
    DataFlash.WriteBlock(&pkt, sizeof(pkt));
}

    { LOG_RCO_MSG, sizeof(log_RCO),             
      "RCO", "hhhh",        "Thr,Pit,Rol,Rud" },




resulting in error message

/home/jamesl/codes/logmod/ardupilot/ArduPlane/Log.pde: In function 'void Log_Write_RCO()':
/home/jamesl/codes/logmod/ardupilot/ArduPlane/Log.pde:451:5: sorry, unimplemented: non-trivial designated initializers not supported
/home/jamesl/codes/logmod/ardupilot/ArduPlane/Log.pde:451:5: sorry, unimplemented: non-trivial designated initializers not supported
/home/jamesl/codes/logmod/ardupilot/ArduPlane/Log.pde:451:5: sorry, unimplemented: non-trivial designated initializers not supported
make: *** [/tmp/ArduPlane.build/ArduPlane.o] Error 1


Randy Mackay

unread,
Sep 20, 2013, 9:49:12 PM9/20/13
to drones-...@googlegroups.com
James,

     It seem the order matters.  So make the order of the log_RCO structure the same as the order in the Log_Write_RCO and it should work.

-Randy



From: James Li <jy0...@gmail.com>
To: drones-...@googlegroups.com
Sent: Saturday, September 21, 2013 4:21 AM
Subject: [drones-discuss] Re: customize data logging content

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


James Li

unread,
Sep 21, 2013, 3:33:34 PM9/21/13
to drones-...@googlegroups.com, Randy Mackay
Thanks Randy,

Now it works after reformatting the orders. 

Andrew Chapman

unread,
Sep 22, 2013, 12:01:17 AM9/22/13
to drones-...@googlegroups.com
James, did you get your new log values showing up in mission planner when you view it in the log browser?

I just added a temperature sensor, which I hope to use to diagnose an ESC overheating problem). I went through the same steps of adding it to a logging struct (I'm piggybacking onto the CURRENT logging) and filling in the self-describing header. The new column shows up in Mission Planner from one of those logs, but with no values in it:



I know everything about the gathering of the data is ok, as I've hijacked the total current variable for now and my values do show up in that column.

What else do we need to do to have a user-added parameter show up in Mission Planner log browser?
Screen Shot 2013-09-21 at 8.10.37 PM.png

Andrew Chapman

unread,
Sep 22, 2013, 12:34:37 AM9/22/13
to drones-...@googlegroups.com
Oops... red herring, looking at the dataflash log outside of Mission Planner I'm not seeing the extra value I've asked to be logged.

Here's the tweaked current log structs:

struct PACKED log_Current {
    LOG_PACKET_HEADER;
    int16_t throttle_in;
    uint32_t throttle_integrator;
    int16_t battery_voltage;
    int16_t current_amps;
    uint16_t board_voltage;
    float current_total;
    float temp_sensor;
};

// Write an Current data packet
static void Log_Write_Current()
{
    struct log_Current pkt = {
        LOG_PACKET_HEADER_INIT(LOG_CURRENT_MSG),
        throttle_in         : g.rc_3.control_in,
        throttle_integrator : throttle_integrator,
        battery_voltage     : (int16_t) (battery_voltage1 * 100.0f),
        current_amps        : (int16_t) (current_amps1 * 100.0f),
        board_voltage       : board_voltage(),
        current_total       : current_total1,
        temp_sensor         : temp_sensor1
    };
    DataFlash.WriteBlock(&pkt, sizeof(pkt));
}

...and the modified parameter description block:


static const struct LogStructure log_structure[] PROGMEM = {
    LOG_COMMON_STRUCTURES,
    { LOG_CURRENT_MSG, sizeof(log_Current),             
      "CURR", "hIhhhf",      "Thr,ThrInt,Volt,Curr,Vcc,CurrTot,TempSens" },
    ....

temp_sensor1 is a static float declared along with the battery monitor variables, and it is definitely being filled in correctly (I see the right value when i pump it into one of the existing logging variables, e.g. current_total1).

What am I missing? Any advice appreciated, thanks all.

Screen Shot 2013-09-21 at 8.10.37 PM.png

Andrew Chapman

unread,
Sep 22, 2013, 12:52:08 AM9/22/13
to drones-...@googlegroups.com
Ah... cracked it. I swear I've been banging my head against this for hours - there's something magical about posting for help that makes you realize the problem.

I'd missed adding a character for the datatype in the log structure (one more 'f' in 'hIhhhff'):

static const struct LogStructure log_structure[] PROGMEM = {
    LOG_COMMON_STRUCTURES,
    { LOG_CURRENT_MSG, sizeof(log_Current),             
      "CURR", "hIhhhff",      "Thr,ThrInt,Volt,Curr,Vcc,CurrTot,TempSens" },
    ....
Screen Shot 2013-09-21 at 8.10.37 PM.png

James Li

unread,
Sep 22, 2013, 11:56:34 AM9/22/13
to drones-...@googlegroups.com
cong Andrew, it is pretty tricky. took me a week to think thru it.
Reply all
Reply to author
Forward
0 new messages