Browse Source

Plane: added compass logging

master
Andrew Tridgell 12 years ago
parent
commit
0c5b393919
  1. 3
      ArduPlane/ArduPlane.pde
  2. 36
      ArduPlane/Log.pde
  3. 52
      ArduPlane/config.h
  4. 2
      ArduPlane/defines.h

3
ArduPlane/ArduPlane.pde

@ -814,6 +814,9 @@ static void medium_loop() @@ -814,6 +814,9 @@ static void medium_loop()
if (g.compass_enabled && compass.read()) {
ahrs.set_compass(&compass);
compass.null_offsets();
if (g.log_bitmask & MASK_LOG_COMPASS) {
Log_Write_Compass();
}
} else {
ahrs.set_compass(NULL);
}

36
ArduPlane/Log.pde

@ -48,6 +48,7 @@ print_log_menu(void) @@ -48,6 +48,7 @@ print_log_menu(void)
PLOG(IMU);
PLOG(CMD);
PLOG(CURRENT);
PLOG(COMPASS);
#undef PLOG
}
@ -136,6 +137,7 @@ select_logs(uint8_t argc, const Menu::arg *argv) @@ -136,6 +137,7 @@ select_logs(uint8_t argc, const Menu::arg *argv)
TARG(IMU);
TARG(CMD);
TARG(CURRENT);
TARG(COMPASS);
#undef TARG
}
@ -375,6 +377,40 @@ static void Log_Write_Current() @@ -375,6 +377,40 @@ static void Log_Write_Current()
DataFlash.WriteBlock(&pkt, sizeof(pkt));
}
struct PACKED log_Compass {
LOG_PACKET_HEADER;
int16_t mag_x;
int16_t mag_y;
int16_t mag_z;
int16_t offset_x;
int16_t offset_y;
int16_t offset_z;
int16_t motor_offset_x;
int16_t motor_offset_y;
int16_t motor_offset_z;
};
// Write a Compass packet. Total length : 15 bytes
static void Log_Write_Compass()
{
Vector3f mag_offsets = compass.get_offsets();
Vector3f mag_motor_offsets = compass.get_motor_offsets();
struct log_Compass pkt = {
LOG_PACKET_HEADER_INIT(LOG_COMPASS_MSG),
mag_x : compass.mag_x,
mag_y : compass.mag_y,
mag_z : compass.mag_z,
offset_x : (int16_t)mag_offsets.x,
offset_y : (int16_t)mag_offsets.y,
offset_z : (int16_t)mag_offsets.z,
motor_offset_x : (int16_t)mag_motor_offsets.x,
motor_offset_y : (int16_t)mag_motor_offsets.y,
motor_offset_z : (int16_t)mag_motor_offsets.z
};
DataFlash.WriteBlock(&pkt, sizeof(pkt));
}
static const struct LogStructure log_structure[] PROGMEM = {
LOG_COMMON_STRUCTURES,
{ LOG_ATTITUDE_MSG, sizeof(log_Attitude),

52
ArduPlane/config.h

@ -714,52 +714,14 @@ @@ -714,52 +714,14 @@
# define LOGGING_ENABLED ENABLED
#endif
#ifndef LOG_ATTITUDE_FAST
# define LOG_ATTITUDE_FAST DISABLED
#endif
#ifndef LOG_ATTITUDE_MED
# define LOG_ATTITUDE_MED ENABLED
#endif
#ifndef LOG_GPS
# define LOG_GPS ENABLED
#endif
#ifndef LOG_PM
# define LOG_PM ENABLED
#endif
#ifndef LOG_CTUN
# define LOG_CTUN DISABLED
#endif
#ifndef LOG_NTUN
# define LOG_NTUN DISABLED
#endif
#ifndef LOG_MODE
# define LOG_MODE ENABLED
#endif
#ifndef LOG_IMU
# define LOG_IMU DISABLED
#endif
#ifndef LOG_CMD
# define LOG_CMD ENABLED
#endif
#ifndef LOG_CURRENT
# define LOG_CURRENT DISABLED
#endif
// calculate the default log_bitmask
#define LOGBIT(_s) (LOG_ ## _s ? MASK_LOG_ ## _s : 0)
#define DEFAULT_LOG_BITMASK \
LOGBIT(ATTITUDE_FAST) | \
LOGBIT(ATTITUDE_MED) | \
LOGBIT(GPS) | \
LOGBIT(PM) | \
LOGBIT(CTUN) | \
LOGBIT(NTUN) | \
LOGBIT(MODE) | \
LOGBIT(IMU) | \
LOGBIT(CMD) | \
LOGBIT(CURRENT)
MASK_LOG_ATTITUDE_MED | \
MASK_LOG_GPS | \
MASK_LOG_PM | \
MASK_LOG_NTUN | \
MASK_LOG_MODE | \
MASK_LOG_CMD | \
MASK_LOG_COMPASS
//////////////////////////////////////////////////////////////////////////////

2
ArduPlane/defines.h

@ -169,6 +169,7 @@ enum log_messages { @@ -169,6 +169,7 @@ enum log_messages {
LOG_CAMERA_MSG,
LOG_ATTITUDE_MSG,
LOG_MODE_MSG,
LOG_COMPASS_MSG,
MAX_NUM_LOGS
};
@ -182,6 +183,7 @@ enum log_messages { @@ -182,6 +183,7 @@ enum log_messages {
#define MASK_LOG_IMU (1<<7)
#define MASK_LOG_CMD (1<<8)
#define MASK_LOG_CURRENT (1<<9)
#define MASK_LOG_COMPASS (1<<10)
// Waypoint Modes
// ----------------

Loading…
Cancel
Save