From 0f65cc04597d691bcc13f1384d5ccf06b40661d0 Mon Sep 17 00:00:00 2001 From: Arnaud Becheler Date: Wed, 1 Jun 2022 14:29:25 -0400 Subject: [PATCH 1/3] fix: ignore the build folder --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 259148f..ad6dfbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Build +build + # Prerequisites *.d From f065a8a54b60b823e73b8abf63479bd5c030c10b Mon Sep 17 00:00:00 2001 From: Arnaud Becheler Date: Wed, 1 Jun 2022 14:30:05 -0400 Subject: [PATCH 2/3] refactor: export all compile-time variables in a dedicated file --- src/physic_constant.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/physic_constant.hpp diff --git a/src/physic_constant.hpp b/src/physic_constant.hpp new file mode 100644 index 0000000..7c18285 --- /dev/null +++ b/src/physic_constant.hpp @@ -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 From 0ac863acbb76881827b4d2f024854a1d9295d429 Mon Sep 17 00:00:00 2001 From: Arnaud Becheler Date: Wed, 1 Jun 2022 15:46:33 -0400 Subject: [PATCH 3/3] fix: integrates options from Aidan --- src/main.cpp | 3 +- src/options.h | 184 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 172 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c9dc61a..7469b70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; } diff --git a/src/options.h b/src/options.h index 953aac3..d3a5990 100644 --- a/src/options.h +++ b/src/options.h @@ -12,17 +12,25 @@ #ifndef __SPOCK_OPTIONS_H_INCLUDED__ #define __SPOCK_OPTIONS_H_INCLUDED__ +#include "physic_constant.hpp" + #include + #include #include #include +#include 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") @@ -31,24 +39,174 @@ auto handle_options(int argc, char* argv[]) ("config", bpo::value()->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(), "Origin point longitude") - ("lat_0", bpo::value(), "Origin point latitude") - ("alt_0", bpo::value(), "Number of gene copies at introduction point") - ("duration", bpo::value(), "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(), "Path to user SPICE installation") + // + ("thrust_file_path", bpo::value(), "path to user's thrust file") + // + ("solar_power_file_name", bpo::value(), "name of OpenGL solar power file") + // + ("surface_geometry_file_name", bpo::value(), "name of surface geometry file") + // + ("TLE_constellation_file_name", bpo::value(), "name of TLE constellation GPS file") + // + ("Kalman_file_name", bpo::value(), "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(), "desired density mod") + // + ("density_mod_amplitude", bpo::value(), "density mod amplitude") + // + ("density_mod_phase", bpo::value(), "density mod phase"); + + /// + /// @brief Time options + /// + bpo::options_description time_options("Time Options"); + time_options.add_options() + // + ("initial_epoch", bpo::value(), "initial epoch in UTC format DD-MM-YYYY HH:MM:SS") + // + ("final_epoch", bpo::value(), "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(), "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()->default_value(1), "number of spacecraft being modelled") + // + ("name", bpo::value >(), "names of each spacecraft in vector") + // + ("num_GPS spacecraft", bpo::value()->default_value(0), "number of spacecraft using GPS") + // + ("num_surfaces", bpo::value(), "number of surfaces on each spacecraft (must be same # for all SC)") + // + ("solar_cell_efficiency", bpo::value >(), "efficiency of solar cells on spacecraft") + // + ("inclination", bpo::value >(), "inclinations of spacecraft in vector of len=num spacecraft") + // + ("eccentricity", bpo::value >(), "eccentricity of all spacecraft in vector of len=num spacecraft") + // + ("apogee_altitude", bpo::value >(), "apogee altitude of all spacecraft in vector") + // + ("true_anomaly", bpo::value >(), "true anomalies of all spacecraft in vector") + // + ("arg_of_periapsis", bpo::value >(), "argument of periapsis of all spacecraft in vector") + // + ("x_pos", bpo::value >(), "x positon of all spacecraft in vector") + // + ("y_pos", bpo::value >(), "y position of all spacecraft in vector") + // + ("z_pos", bpo::value >(), "z position of all spacecraft in vector") + // + ("x_veloc", bpo::value >(), "x direction velocities of all spacecraft in vector") + // + ("y_veloc", bpo::value >(), "y direction velocities of all spacecraft in vector") + // + ("z_veloc", bpo::value >(), "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()->default_value("no"), "yes or no") + // + ("include_solar_pressure", bpo::value()->default_value("no"), "yes or no") + // + ("include_drag", bpo::value()->default_value("no"), "yes or no") + // + ("include_Sun_gravity", bpo::value()->default_value("no"), "yes or no") + // + ("include_Moon_gravity", bpo::value()->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()->default_value("nadir"), "desired attitude profile") + // + ("use angular_velocity_vector", bpo::value(), "yes or no") + // + ("angular_velocity", bpo::value >(), "array of angular velocity components"); + + /// + /// @brief KALMAN options + /// + bpo::options_description kalman_options("Kalman Options"); + kalman_options.add_options() + // + ("use_kalman", bpo::value()->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()->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(), "number of ground stations") + // + ("name", bpo::value >(), "names of all ground stations in vector") + // + ("lat", bpo::value >(), "latitude of all ground stations in vector") + // + ("long", bpo::value >(), "longitude of all ground stations in vector") + // + ("alt", bpo::value >(), "altitude of all ground stations in vector") + // + ("min_elev_angle", bpo::value >(), "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; @@ -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] ... |" << std::endl; + std::cout << "| - Usage: " << argv[0] << " [options] ... |" << std::endl; std::cout << "--------------------------------------------------------------------------------------|" << std::endl; std::cout << "\n" << generic_options << std::endl; std::cout << "\n" << file_options << std::endl;