Skip to content

Commit

Permalink
add -filter option to MavLinkTest for exporting a single message type…
Browse files Browse the repository at this point in the history
… from mavlink logfile as .csv. Add csv headers to example sensor output.
  • Loading branch information
lovettchris committed Apr 3, 2017
1 parent 246edbf commit 6ba69e7
Show file tree
Hide file tree
Showing 3 changed files with 1,049 additions and 826 deletions.
43 changes: 23 additions & 20 deletions Examples/StandAloneSensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class StandALoneSensors {
public:
static void generateImuStaticData(std::ostream& output_stream, float period, float total_duration)
{
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(), 0);
msr::airlib::Environment environment(initial_environment);
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(), 0);
msr::airlib::Environment environment(initial_environment);

ImuSimple imu;
imu.initialize(&kinematics, &environment);


float interations = total_duration / period;

output_stream << std::fixed;
output_stream << "time\tx-gyro\ty-gyro\tz-gyro\tx-acc\ty-acc\t-z-acc" << std::endl;

double last = Utils::getTimeSinceEpoch();
for (auto i = 0; i < interations; ++i) {
Expand All @@ -42,19 +42,20 @@ class StandALoneSensors {
}
}

static void generateBarometerStaticData(std::ostream& output_stream, float period, float total_duration)
static void generateBarometerStaticData(std::ostream& output_stream, float period, float total_duration, GeoPoint loc)
{
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(), 0);
msr::airlib::Environment environment(initial_environment);
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, loc, 0);
msr::airlib::Environment environment(initial_environment);

BarometerSimple baro;
baro.initialize(&kinematics, &environment);


float interations = total_duration / period;

output_stream << std::fixed;
output_stream << "time\tpressure\taltitude" << std::endl;


double last = Utils::getTimeSinceEpoch();
for (auto i = 0; i < interations; ++i) {
Expand All @@ -73,19 +74,19 @@ class StandALoneSensors {
}


static void generateBarometerDynamicData(std::ostream& output_stream, float period, float total_duration)
static void generateBarometerDynamicData(std::ostream& output_stream, float period, float total_duration, GeoPoint loc)
{
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(), 0);
msr::airlib::Environment environment(initial_environment);
auto kinematics = Kinematics::State::zero();
msr::airlib::Environment::State initial_environment(kinematics.pose.position, loc, 0);
msr::airlib::Environment environment(initial_environment);

BarometerSimple baro;
baro.initialize(&kinematics, &environment);


float interations_20s = 20.0f / period;

output_stream << std::fixed;
output_stream << "time\tpressure\taltitude\tgps_alt" << std::endl;

double last = Utils::getTimeSinceEpoch();
bool which_alt = false;
Expand All @@ -111,20 +112,22 @@ class StandALoneSensors {
}


static void generateMagnetometerDataLoc(std::ostream& output_stream, float period, float total_duration)
static void generateMagnetometerDataLoc(std::ostream& output_stream, float period, float total_duration, GeoPoint loc)
{
output_stream << std::fixed;

output_stream << "time\tx-mag\ty-mag\tz-mag\tlat\tlon\talt\tw\tx\ty\tz" << std::endl;

float interations = total_duration / period;
double last = Utils::getTimeSinceEpoch();
for (float pitch = 0; pitch < 2.1*M_PIf; pitch += M_PIf/2) {
for (float roll = 0; roll < 2.1*M_PIf; roll += M_PIf/2) {
for (float yaw = 0; yaw < 2.1*M_PIf; yaw += M_PIf/2) {

auto kinematics = Kinematics::State::zero();
kinematics.pose.orientation = VectorMath::toQuaternion(pitch, roll, yaw);
//msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(47.7631699f, -122.0685655f, 111.208f), 0);
msr::airlib::Environment::State initial_environment(kinematics.pose.position, GeoPoint(47.6628040f, -122.1167039f, 7.564f), 0);
msr::airlib::Environment environment(initial_environment);
auto kinematics = Kinematics::State::zero();
kinematics.pose.orientation = VectorMath::toQuaternion(pitch, roll, yaw);
msr::airlib::Environment::State initial_environment(kinematics.pose.position, loc, 0);
msr::airlib::Environment environment(initial_environment);
MagnetometerSimple mag;
mag.initialize(&kinematics, &environment);

Expand Down
10 changes: 6 additions & 4 deletions Examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ int main(int argc, const char *argv[])

using namespace msr::airlib;

GeoPoint testLocation(47.763160, -122.068534, 120.6f);

std::ofstream out_file(argv[1]);
//StandALoneSensors::createStaticData(out_file, period, total_duration);
//StandALoneSensors::generateBarometerStaticData(out_file, period, total_duration);
StandALoneSensors::generateBarometerDynamicData(out_file, period, total_duration);
//StandALoneSensors::generateMagnetometerDataLoc(out_file, period, total_duration);
//StandALoneSensors::createStaticData(out_file, period, total_duration, testLocation);
StandALoneSensors::generateBarometerStaticData(out_file, period, total_duration, testLocation);
//StandALoneSensors::generateBarometerDynamicData(out_file, period, total_duration, testLocation);
//StandALoneSensors::generateMagnetometerDataLoc(out_file, period, total_duration, testLocation);
}
Loading

0 comments on commit 6ba69e7

Please sign in to comment.