Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrating Aidan options file #2

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Build
build

# Prerequisites
*.d

Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ int main(int argc, char* argv[])
if (vm.count("verbose"))
{
verbose = true;
// to reactivate once the utils header is ready
// spock::utils::PrintVariableMap(vm);
spock::utils::PrintVariableMap(vm);
}

if(verbose){ std::cout << "Initialization" << std::endl; }
Expand Down
184 changes: 171 additions & 13 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@
#ifndef __SPOCK_OPTIONS_H_INCLUDED__
#define __SPOCK_OPTIONS_H_INCLUDED__

#include "physic_constant.hpp"

#include <boost/program_options.hpp>

#include <string>
#include <iostream>
#include <fstream>
#include <vector>

namespace bpo = boost::program_options;

///
/// @brief Returns a map with the program options
///
auto handle_options(int argc, char* argv[])
{
// Declare a group of options that will be allowed only on command line
///
/// @brief Declare a group of options that will be allowed only on command line
///
bpo::options_description generic_options{"Command-line-only options"};
generic_options.add_options()
("help,h", "help screen")
Expand All @@ -31,24 +39,174 @@ auto handle_options(int argc, char* argv[])
("config", bpo::value<std::string>()->required(), "configuration file")
;

// Declare a simpler way to call on command line
///
/// @brief Declare a simpler way to call on command line
///
bpo::positional_options_description positional_options;
positional_options.add("config", 1);

// Allowed both on command line and in config file
bpo::options_description model_options{"Propagation model parameters"};
model_options.add_options()
("lon_0", bpo::value<double>(), "Origin point longitude")
("lat_0", bpo::value<double>(), "Origin point latitude")
("alt_0", bpo::value<double>(), "Number of gene copies at introduction point")
("duration", bpo::value<int>(), "Number of generations to simulate")
;
///
/// @brief File paths options for file dependencies
///
/// \todo if we get user to provide all variables in one config file do we need these files? Obviously we keep SPICE and TLE but what about others?
///
bpo::options_description dependencies_options("Dependencies Options");
dependencies_options.add_options()
//
("SPICE_file_path", bpo::value<std::string>(), "Path to user SPICE installation")
//
("thrust_file_path", bpo::value<std::string>(), "path to user's thrust file")
//
("solar_power_file_name", bpo::value<std::string>(), "name of OpenGL solar power file")
//
("surface_geometry_file_name", bpo::value<std::string>(), "name of surface geometry file")
//
("TLE_constellation_file_name", bpo::value<std::string>(), "name of TLE constellation GPS file")
//
("Kalman_file_name", bpo::value<std::string>(), "name of Kalman filtering file");

///
/// @brief Density MOD options
///
bpo::options_description density_options("Density MOD Options");
density_options.add_options()
//
("density_mod", bpo::value<double>(), "desired density mod")
//
("density_mod_amplitude", bpo::value<double>(), "density mod amplitude")
//
("density_mod_phase", bpo::value<double>(), "density mod phase");

///
/// @brief Time options
///
bpo::options_description time_options("Time Options");
time_options.add_options()
//
("initial_epoch", bpo::value<std::string>(), "initial epoch in UTC format DD-MM-YYYY HH:MM:SS")
//
("final_epoch", bpo::value<std::string>(), "final epoch in UTC format DD-MM-YYYY HH:MM:SS")
// TODO what units is timestep in? does it need to be given in UTC?
("timestep", bpo::value<float>(), "timestep");

///
/// @brief Spacecraft options
///
/// \todo unfinished
///
/// \todo why isn't right ascention included in original code as an option?
///
/// \todo ask if we want pos and veloc provided in ECEF or ECI by user (it shouldn't matter which we just need a default)
///
bpo::options_description spacecraft_options("Spacecraft Options");
spacecraft_options.add_options()
//
("num_spacecraft", bpo::value<int>()->default_value(1), "number of spacecraft being modelled")
//
("name", bpo::value<std::vector<std::string> >(), "names of each spacecraft in vector")
//
("num_GPS spacecraft", bpo::value<int>()->default_value(0), "number of spacecraft using GPS")
//
("num_surfaces", bpo::value<int>(), "number of surfaces on each spacecraft (must be same # for all SC)")
//
("solar_cell_efficiency", bpo::value<std::vector<double> >(), "efficiency of solar cells on spacecraft")
//
("inclination", bpo::value<std::vector<double> >(), "inclinations of spacecraft in vector of len=num spacecraft")
//
("eccentricity", bpo::value<std::vector<double> >(), "eccentricity of all spacecraft in vector of len=num spacecraft")
//
("apogee_altitude", bpo::value<std::vector<double> >(), "apogee altitude of all spacecraft in vector")
//
("true_anomaly", bpo::value<std::vector<double> >(), "true anomalies of all spacecraft in vector")
//
("arg_of_periapsis", bpo::value<std::vector<double> >(), "argument of periapsis of all spacecraft in vector")
//
("x_pos", bpo::value<std::vector<double> >(), "x positon of all spacecraft in vector")
//
("y_pos", bpo::value<std::vector<double> >(), "y position of all spacecraft in vector")
//
("z_pos", bpo::value<std::vector<double> >(), "z position of all spacecraft in vector")
//
("x_veloc", bpo::value<std::vector<double> >(), "x direction velocities of all spacecraft in vector")
//
("y_veloc", bpo::value<std::vector<double> >(), "y direction velocities of all spacecraft in vector")
//
("z_veloc", bpo::value<std::vector<double> >(), "z direction velocities of all spacecraft in vector");

///
/// @brief Forces options
///
bpo::options_description forces_options("Forces Options");
forces_options.add_options()
//
("include_Earth_pressure", bpo::value<std::string>()->default_value("no"), "yes or no")
//
("include_solar_pressure", bpo::value<std::string>()->default_value("no"), "yes or no")
//
("include_drag", bpo::value<std::string>()->default_value("no"), "yes or no")
//
("include_Sun_gravity", bpo::value<std::string>()->default_value("no"), "yes or no")
//
("include_Moon_gravity", bpo::value<std::string>()->default_value("no"), "yes or no");

///
/// @brief Attitude options
///
/// \todo should the description list what the components are?
///
bpo::options_description attitude_options("Attitude Options");
attitude_options.add_options()
//
("attitude_profile", bpo::value<std::string>()->default_value("nadir"), "desired attitude profile")
//
("use angular_velocity_vector", bpo::value<std::string>(), "yes or no")
//
("angular_velocity", bpo::value<std::vector<double> >(), "array of angular velocity components");

///
/// @brief KALMAN options
///
bpo::options_description kalman_options("Kalman Options");
kalman_options.add_options()
//
("use_kalman", bpo::value<std::string>()->default_value("no"), "yes or no");

///
/// @brief Orbit options
///
/// \todo Section is incomplete
///
bpo::options_description orbit_options("Orbit Options");
orbit_options.add_options()
// TODO this is dumb, this should be in the spacecraft section? I think???
("orbit_type", bpo::value<std::string>()->default_value("state_ecef"), "type of orbit");

///
/// @brief Ground stations options
///
bpo::options_description ground_stations_options("Ground Stations Options");
ground_stations_options.add_options()
//
("num_ground_stations", bpo::value<int>(), "number of ground stations")
//
("name", bpo::value<std::vector<std::string> >(), "names of all ground stations in vector")
//
("lat", bpo::value<std::vector<double> >(), "latitude of all ground stations in vector")
//
("long", bpo::value<std::vector<double> >(), "longitude of all ground stations in vector")
//
("alt", bpo::value<std::vector<double> >(), "altitude of all ground stations in vector")
//
("min_elev_angle", bpo::value<std::vector<double> >(), "minimum elevation angle of all ground stations");

bpo::options_description command_line_options;
command_line_options.add(generic_options).add(model_options);
command_line_options.add(generic_options);

bpo::options_description file_options{"General options (command line values will overwrite congif file values)"};
file_options.add(model_options);

file_options.add(dependencies_options).add(density_options).add(time_options);
file_options.add(spacecraft_options).add(forces_options).add(attitude_options);
file_options.add(kalman_options).add(orbit_options);

bpo::variables_map vm;

Expand All @@ -68,7 +226,7 @@ auto handle_options(int argc, char* argv[])
std::cout << "| This is SpOCK propagator. |" << std::endl;
std::cout << "| - Purpose: propagates satellites orbits. |" << std::endl;
std::cout << "| - Author: Aaron Ridley, Aidan Kingwell, Arnaud Becheler 2022. |" << std::endl;
std::cout << "| - Usage: " << argv[0] << " [options] <config> ... |" << std::endl;
std::cout << "| - Usage: " << argv[0] << " [options] <config> ... |" << std::endl;
std::cout << "--------------------------------------------------------------------------------------|" << std::endl;
std::cout << "\n" << generic_options << std::endl;
std::cout << "\n" << file_options << std::endl;
Expand Down
37 changes: 37 additions & 0 deletions src/physic_constant.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef PHYSIC_CONSTANTS_HPP
#define PHYSIC_CONSTANTS_HPP

///
/// @brief Components for orbital propagation
///
namespace spock
{
///
/// @brief Compile-time physic constants
///
namespace physic_constant
{
///
/// @brief Number of days in a year
///
inline constexpr int DAYS_IN_ONE_YEAR = 365.;
///
/// @brief Number of seconds in a day
///
inline constexpr int SECONDS_IN_ONE_DAY = 86400.;
///
/// @brief Number of hours in one day
///
inline constexpr int HOURS_IN_ONE_DAY = 24.;
///
/// @brief Number of metres in a kilometer
///
inline constexpr int METRES_IN_ONE_KILOMETRE = 1000.;
///
/// @brief Number of seconds in one hour
///
inline constexpr int SECONDS_IN_ONE_HOUR = 3600.;
}
}

#endif