Log

The Log file library was written in a previous year. It stores flight data in an organized manner such that it can be easily interpreted with our MATLAB scripts. Furthermore, there are no executables in this library.

Defines

MYPROJECT_NEWLOG_H
class Log
#include <Log.h>

Log class to record flight results.

Public Functions

Log(std::string flightFilename, std::string programFilename, vn::sensors::VnSensor *imu, double sTime)

Construct a new Log object.

Parameters:
  • flightFilename – Name for flight log file

  • programFilename – Name for program log file

  • imu – Pointer to VN-100 sensor object

  • sTime – Timestamp that we don’t use

~Log()

Destroy the Log object.

void write(vn::sensors::ImuMeasurementsRegister &data)

Writes IMU data to flight log.

Parameters:

data – IMU Data

void write(std::string outputString)

Writes print statements to program log.

Parameters:

outputString – Print statements

void writeTime(std::string outputString)

Write string to program data file with timestamp and to console.

Parameters:

outputString – The timestamp

void tempSaveProgLog()

Saves the program log file while still keeping it open to writing.

void writeDelim(std::string outputString)

Write string to program data file with special delimiters and timestamp for MATLAB postprocessing, and to console.

Parameters:

outputString – The string written in the Log

double elapsedTime()

Calculate time in milliseconds since Log pointer was created.

Returns:

double representing the time in ms since Log was created

void saveBaselineParameters(float Rconst, float Bconst, float pressure, float temperature, float accelg)

Save baseline parameters to calculate altitude.

Parameters:
  • Rconst – Gas Constant

  • Bconst – Variation of temperature within the troposphere

  • pressure – Baseline pressure

  • temperature – Baseline temperature

  • accelg – Baseline gravity reading

std::string getTimestamp()

Get the start timestamp.

Returns:

string representing the timestamp

Private Functions

float calcAlt(vn::sensors::ImuMeasurementsRegister &data)

Calculates altitude based on IMU pressure data.

Parameters:

data – The data collected from the IMU Register

Returns:

float represnting the current altitude in meters

Private Members

std::ofstream mFlightLog

Flight Data Log File relative to current directory.

std::ofstream mProgLog

Program Outpu Log File relative to current directory.

vn::sensors::VnSensor *mIMU

VN-100 IMU sensor (pointer to the one in the main program)

double startTime

Start time in ms.

double currentTime

Current time in ms.

double sampleNumber

Current sample number.

float pressure0

Baseline pressure.

float temperature0

Baseline temperature.

float accelg0

Baseline gravity reading.

float R

Universal Gas Constant.

float B

Variation of temperature within the troposphere.

float currentAlt

Current altitude in meters.

bool savedParameters

Boolean indicating if we have saved the parameters yet.

int numSpecialCharacters = 10

match this to number of specialCharacters (don’t tell matt we hardcoded this lol)

std::string specialCharacters [10]  = {"/", "\\", "*", "<", ">", ",", ".", "`", "~", "|"}

not all of these are invalid but rather be safe than sorry

std::string delim

Character to specify when events happen in Program log ($)

std::string timestamp_

Timestamp of when program is initialized.

std::string flight_name_

String representing flight name.

std::string program_name_

String representing program name.