StoRC
Autonomous Payload Delivery System
log.pde File Reference

Flash memory logging functions. More...

Go to the source code of this file.

Functions

byte get_num_logs (void)
void start_new_log (byte num_existing_logs)
void get_log_boundaries (byte log_num, int &start_page, int &end_page)
int find_last_log_page (int bottom_page)
void Log_Write_IMU (float gyro_x, float gyro_y, float gyro_z, float accel_x, float accel_y, float accel_z)
void Log_Write_GPS (long log_day, long log_hour, long log_minute, long log_second, long log_latitude, long log_longitude, long log_altitude, long log_ground_speed, long log_ground_course)
void Log_Write_Barometer (float temp, float press)
void Log_Write_RC (int elevator, int rudder, int throttle, int ch4, int ch5, int ch6, int ch7, int ch8)
void Log_Write_Airspeed (float a)
void Log_Write_Magnetometer (float h, float r, float p, float y)
void Log_Write_Controls_Rudder (float kpRud, float kpRudGm, float kdRud, float kdRudGm, float kiRud, float kiRudGm, float iRud, float delta)
void Log_Write_Controls_Elevator (float kpEle, float kpEleGm, float kpRp, float kiEle, float kiEleGm, float iEle, float delta)
void Log_Write_Controls_Throttle (float kpThr, float kpThrGm, float kiThr, float kiThrGm, float iThr, float delAlt, float delta)
void Log_Write_State (boolean drop_status, int logging_switch, boolean windProfile, float avgWindNS, float avgWindEW, float driftNS, float driftEW)
void Log_Write_Navigation (long latc, long lonc, long delLat, long delLon, float psic, float psierror, float phic, long dropThresh)

Detailed Description

Flash memory logging functions.

Author:
Michael Posner (CIS, MEAM '12)
Timothy Hennelly (ESE '12)
Jacob Orloff (MEAM '12)

logging file, mostly copied from ArduPilot. this allows us to write to the flash memory. when a logging Write() function is changed here, make sure its appropriate Read() counterpart is changed in the default code you use to download the log. (it will give an Error Reading END_BYTE error if the read() formate doesnt match the format that the data was written in below) Note: Instead of modifying the DataFlash library to write floats (kinda hard), instead a hack is to multiply the float value by 10^5 or whatever, then cast to long in the Write() function and write it using the long writing function. Then, in the Read() function, cast back to float and divide by 10^5.

Definition in file log.pde.


Function Documentation

int find_last_log_page ( int  bottom_page)

ArduPilot Mega function. finds the last log page.

Definition at line 180 of file log.pde.

void get_log_boundaries ( byte  log_num,
int &  start_page,
int &  end_page 
)

ArduPilot Mega function. figures out the boundaries of the log.

Definition at line 135 of file log.pde.

byte get_num_logs ( void  )

ArduPilot function. figures out how many logs are currently in flash memory.

Returns:
the number of logs currently in flash memory

Definition at line 52 of file log.pde.

void Log_Write_Airspeed ( float  a)

Logs Airspeed value

Definition at line 294 of file log.pde.

void Log_Write_Barometer ( float  temp,
float  press 
)

Logs barometer data.

Definition at line 260 of file log.pde.

void Log_Write_Controls_Elevator ( float  kpEle,
float  kpEleGm,
float  kpRp,
float  kiEle,
float  kiEleGm,
float  iEle,
float  delta 
)

Logs elevator controls values

Definition at line 345 of file log.pde.

void Log_Write_Controls_Rudder ( float  kpRud,
float  kpRudGm,
float  kdRud,
float  kdRudGm,
float  kiRud,
float  kiRudGm,
float  iRud,
float  delta 
)

Logs rudder controls values

Definition at line 325 of file log.pde.

void Log_Write_Controls_Throttle ( float  kpThr,
float  kpThrGm,
float  kiThr,
float  kiThrGm,
float  iThr,
float  delAlt,
float  delta 
)

Logs throttle controls values

Definition at line 364 of file log.pde.

void Log_Write_GPS ( long  log_day,
long  log_hour,
long  log_minute,
long  log_second,
long  log_latitude,
long  log_longitude,
long  log_altitude,
long  log_ground_speed,
long  log_ground_course 
)

modified function from ArduPilot Mega. Logs GPS data. Note that the GPS library already returns longitude and latitude as their actual values * 10^7, as well as the altitude, ground speed, and ground course as their actual values * 100, so there's no need to multiply before saving as longs.

Parameters:
log_daythe number of the day of the week (0=Sun, 1=Mon, ... 6=Sat)
log_hourthe hour of the current day (0 - 23)
log_minutethe minute of the current hour (0 - 59)
log_secondthe second of the current minute (0-59)
log_latitudethe GPS latitude, multiplied by 10^7 (this is necessary to log in long format while keeping significant digits)
log_longitudethe GPS longitude, multiplied by 10^7 (this is necessary to log in long format while keeping significant digits)
log_altitudethe altitude in cm (m * 100)
log_ground_speedthe ground speed in cm/s (m/s * 100)
log_ground_coursethe ground course in hundredths of a degree (deg * 100)

Definition at line 238 of file log.pde.

void Log_Write_IMU ( float  gyro_x,
float  gyro_y,
float  gyro_z,
float  accel_x,
float  accel_y,
float  accel_z 
)

modified function from ArduPilot Mega. Logs IMU data. Be careful when casting from float to long! long is an integer type and cannot store decimals. so this function takes in floats, but since the flash library can't write floats (I looked into modifying it, but this hack is easier), I multiply the float by 10000 and then cast to a long. Then the corresponding Read function divides by 10000 before writing to the text file.

Definition at line 207 of file log.pde.

void Log_Write_Magnetometer ( float  h,
float  r,
float  p,
float  y 
)

Logs magnetometer values

Definition at line 308 of file log.pde.

void Log_Write_Navigation ( long  latc,
long  lonc,
long  delLat,
long  delLon,
float  psic,
float  psierror,
float  phic,
long  dropThresh 
)

Logs navigation values

Definition at line 414 of file log.pde.

void Log_Write_RC ( int  elevator,
int  rudder,
int  throttle,
int  ch4,
int  ch5,
int  ch6,
int  ch7,
int  ch8 
)

Logs RC servo values.

Definition at line 274 of file log.pde.

void Log_Write_State ( boolean  drop_status,
int  logging_switch,
boolean  windProfile,
float  avgWindNS,
float  avgWindEW,
float  driftNS,
float  driftEW 
)

Logs code state (drop status, logging switch)

Definition at line 383 of file log.pde.

void start_new_log ( byte  num_existing_logs)

ArduPilot Mega function. starts a new log file.

Parameters:
num_existing_logsthe number of logs already in memory, as returned by get_num_logs}
See also:
get_num_logs

Definition at line 96 of file log.pde.