Skip to content

Commit

Permalink
Implemented SGP4 propagator. Implemented parser for subset of paramet…
Browse files Browse the repository at this point in the history
…ers required for SGP4 propagation. Updated Makefile, SpOCK user guide and README. Fixed bug in attprop.cpp which prevented the attitude propagator to run for a time longer then (simduration - inittime) when using atmospheric model NRLMSISE-00.
  • Loading branch information
Sergio De Florio committed Mar 2, 2022
1 parent 5dc1f68 commit 2b9f530
Show file tree
Hide file tree
Showing 17 changed files with 515 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Model of 6 spacecraft faces, 3 solar panels, 1 Sun camera, 1 Earth camera, 3 mag

*Dynamics*

Precise orbit and attitude propagation, mission events computation, atmospheric drag and solar radiation pressure with panels model (dependent on attitude) or reference area model, attitude and orbital maneuvers with different type of actuators.
Precise orbit and attitude propagation, mission events computation, atmospheric drag and solar radiation pressure with panels model (dependent on attitude) or reference area model, attitude and orbital maneuvers with different type of actuators. The simplified general perturbations (SGP4) propagator used with two-line mean element (TLE) sets is also implemented.

*Orbit environment models*

Expand Down Expand Up @@ -47,6 +47,8 @@ make install_mag (first compilation or after OS upgrade)

make orbit

make sgp4

make attitude

make events
Expand All @@ -65,7 +67,7 @@ Coomands make install_atmo and install_mag are used to compile external Fortran

## Configuration

Put correct inputs/outputs paths in input files simparam_sample.xml and eventsparam_sample.xml
Put correct inputs/outputs paths in input files simparam_sample.xml and eventsparam_sample.xml as explained in detail in SPOCK_UserGuide.pdf.

---

Expand All @@ -75,6 +77,8 @@ Put correct inputs/outputs paths in input files simparam_sample.xml and eventspa

./bin/OrbitPropagator input/SimulationParameters/simparam_sample.xml

./bin/SGP4Propagator input/SimulationParameters/simparam_sample.xml

./bin/AttitudePropagator input/SimulationParameters/simparam_sample.xml

./bin/EventsComputation input/SimulationParameters/eventsparam_sample.xml
Expand Down
1 change: 1 addition & 0 deletions attprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ int main(int argc, char *argv[])
SC_Attitude.mag_on = T_model[1];
SC_Attitude.drag_on = T_model[2];
SC_Attitude.srp_on = T_model[3];
SC_Attitude.simdur = SIM_DURATION;
SC_Attitude.magnetometer_on = Magnetometer1.On || Magnetometer1.On; // True if at least one of the magnetometers is switched-on

SC_Attitude.Setup(SC_prms,envmodels_paths);
Expand Down
Binary file modified doc/UserGuide/SPOCK_UserGuide.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions extlib/cspice/include/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
H_SRC += $(wildcard $(SELF_DIR)/*.h)
INCLUDE_PATH += $ -I"$(SELF_DIR)"
Expand Down
1 change: 1 addition & 0 deletions extlib/cspice/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
H_SRC += $(wildcard $(SELF_DIR)/*.h)
INCLUDE_PATH += $ -I"$(SELF_DIR)"
Expand Down
2 changes: 1 addition & 1 deletion extlib/make.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
#CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
H_SRC += $(wildcard $(SELF_DIR)/*.h)
INCLUDE_PATH += $ -I"$(SELF_DIR)"
Expand Down
4 changes: 2 additions & 2 deletions input/SimulationParameters/simparam_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@

<InputFiles>

<Orbit_ephemeris>/your_absolute_path/SpOCK/output/OrbitEphemerides/P00_S01_RO_3days_10s_20190409_100115_GGM02C.csv</Orbit_ephemeris>
<Orbit_ephemeris>/your_absolute_path/SpOCK/output/OrbitEphemerides/P00_S01_RO_3days_10s_20190409_100115_GGM02C.csv</Orbit_ephemeris> <!--Use this entry also for pathto TLE file for SGP4 propagation-->
<Attitude_ephemeris>/your_absolute_path/SpOCK/output/AttitudeEphemerides/Attitude.csv</Attitude_ephemeris>
<Data_path>/your_absolute_path/SpOCK/data</Data_path>
<Planet_ephemeris>de440.bsp</Planet_ephemeris>
Expand All @@ -199,7 +199,7 @@

<OutputFiles>

<Orbit_ephemeris>/your_absolute_path/SpOCK/output/OrbitEphemerides/P00_S01_3days_10s_20190409_100115_GGM02C_allpert.csv</Orbit_ephemeris> <!--Orbit ephemeris generated by orbit propagator-->
<Orbit_ephemeris>/your_absolute_path/SpOCK/output/OrbitEphemerides/P00_S01_3days_10s_20190409_100115_GGM02C_allpert.csv</Orbit_ephemeris> <!--Orbit ephemeris generated by orbit propagator (also SGP4)-->
<Attitude_ephemeris>/your_absolute_path/SpOCK/output/AttitudeEphemerides/Attitude.csv</Attitude_ephemeris> <!--Attitude ephemeris generated by attitude propagator-->
<Sensor_output>/your_absolute_path/SpOCK/output/Sensors/SensorsOutput.csv</Sensor_output> <!--Attitude sensors readings generated by attitude propagator-->
<Torques>/your_absolute_path/SpOCK/output/Dynamics/Torques.csv</Torques> <!--Environmental and actuators torques during attitude propagation-->
Expand Down
6 changes: 3 additions & 3 deletions lib/Astrodynamics/Environment/Atmosphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ namespace atmosphere
//return(0);
return;
}

doy = (int)SpaceWeather_idx(swind,1);
UTsecs = time - SpaceWeather_idx(swind,0); // Seconds of day
f107a = SpaceWeather_idx(swind,27);
f107 = SpaceWeather_idx(swind - 1, 29);

Ap_4days.segment(0,3) = SpaceWeather_idx.block<1,3>(swind - 3,18);
Ap_4days.segment(3,8) = SpaceWeather_idx.block<1,8>(swind - 2,13);
Ap_4days.segment(11,8) = SpaceWeather_idx.block<1,8>(swind - 1,13);
Expand Down Expand Up @@ -369,7 +369,7 @@ namespace atmosphere
if( modelname.compare("NRLMSISE-00") == 0 )
{
string spaceweather_file = modelfilepath + "/spaceweather/CssiSpaceWeather_indices.txt";
SpaceWeather_idx = read_SpaceWeather(spaceweather_file.c_str(),init_epoch, simduration); // inittime variable of class PROP
SpaceWeather_idx = read_SpaceWeather(spaceweather_file.c_str(),init_epoch, simduration + 86400); // inittime variable of class PROP
}

};
Expand Down
1 change: 1 addition & 0 deletions lib/Astrodynamics/Transformations/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_CONV += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_NAVSOLCONV += $(wildcard $(SELF_DIR)/*.cpp)
Expand Down
1 change: 1 addition & 0 deletions lib/Astrodynamics/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_CONV += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_NAVSOLCONV += $(wildcard $(SELF_DIR)/*.cpp)
Expand Down
186 changes: 185 additions & 1 deletion lib/IO/IO_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ Matrix3D read_gfc(const char* filename,
*
* @param filename Complete path to gfc gravity model file
* @param start_epoch Epoch from which to read the data [GPS seconds]
* @param start_epoch Time span of interest [s]
* @param sim_duration Time span of interest [s]
*
* @return Eigen matrix containing all space weather data in read file
*/
Expand Down Expand Up @@ -1278,6 +1278,190 @@ int XML_parser(const string XML_simparam_file,

return(0);
};











//-------------------------------------------------------------------------------------
// int SGP4_XML_parser(...)
//-------------------------------------------------------------------------------------
/**
* Load and read simulation parameters XML file and validate it against an XML schema file.
* This is a reduced version of function XML_parser for the SGP4 propagator which requires
* a small subset of the inputs required by the precise orbit propagation.
*
* @param XML_simparam_file Complete path to XML file (e.g. dir1/dir2/dir3/filenae.xml)
*
* @return exception against XML schema
*
* @note The implementation of this parser is based on CodeSynthesis XSD binding compiler and the xerces library
* @see http://www.codesynthesis.com/products/xsd/
* @see https://xerces.apache.org/xerces-c/
*/
//-------------------------------------------------------------------------------------
int SGP4_XML_parser(const string XML_simparam_file,
string& TLE_file,
string& Data_path,
string& eop,
string& pck_data,
string& leapsecond,
string& orbfile_name,
int& SIM_STEP,
int& SIM_DURATION)
{
::simparam_pimpl simparam_p;
::fileheader_pimpl fileheader_p;
::xml_schema::string_pimpl string_p;
::license_pimpl license_p;
::xml_schema::uri_pimpl uri_p;
::xml_schema::date_pimpl date_p;
::reference_pimpl reference_p;
::SC_Faces_pimpl SC_Faces_p;
::SC_properties_pimpl SC_properties_p;
::InputFiles_pimpl InputFiles_p;
::OutputFiles_pimpl OutputFiles_p;
::SimParameters_pimpl SimParameters_p;
::durstep_pimpl durstep_p;
::xml_schema::duration_pimpl duration_p;
::ORB_initstate_pimpl ORB_initstate_p;
::ATT_initstate_pimpl ATT_initstate_p;
::simoptions_pimpl simoptions_p;
::SensorsActuators_pimpl SensorsActuators_p;
::Maneuvers_pimpl Maneuvers_p;

// Connect the parsers together.
//
simparam_p.parsers (fileheader_p,
SC_Faces_p,
SC_properties_p,
InputFiles_p,
OutputFiles_p,
SimParameters_p,
SensorsActuators_p,
Maneuvers_p,
string_p);

fileheader_p.parsers (string_p,
string_p,
string_p,
license_p,
string_p,
date_p,
string_p,
string_p,
string_p,
string_p,
reference_p);

license_p.parsers (string_p,
uri_p);

reference_p.parsers (string_p,
string_p,
string_p,
string_p);

InputFiles_p.parsers (string_p,
string_p,
string_p,
string_p,
string_p,
string_p,
string_p,
string_p,
string_p,
string_p,
string_p);

OutputFiles_p.parsers (string_p,
string_p,
string_p,
string_p,
string_p,
string_p);

SimParameters_p.parsers (durstep_p,
ORB_initstate_p,
ATT_initstate_p,
simoptions_p);

durstep_p.parsers (duration_p,
duration_p);

try
{
// Parse the XML document.
//
::xml_schema::document doc_p(simparam_p, "simparam");

simparam_p.pre ();
doc_p.parse(XML_simparam_file);
simparam_p.post_simparam ();
}
catch (const ::xml_schema::exception& e)
{
std::cerr << e << std::endl;
return 1;
}

///////////////////////////////////////////////////////////////
///////////////////////// FILES PATHS /////////////////////////
///////////////////////////////////////////////////////////////
// Input files paths
TLE_file = InputFiles_p.Orbit_ephemeris_in;
Data_path = InputFiles_p.Data_path_in;
pck_data = InputFiles_p.pck_data_in;
eop = InputFiles_p.eop_in;
leapsecond = InputFiles_p.leapsecond_in;
// Output files paths
orbfile_name = OutputFiles_p.orbfile_name_in;
/////////////////////////////////////////////////////////////////////////
///////////////////////// SIMULATION PARAMETERS /////////////////////////
/////////////////////////////////////////////////////////////////////////
// Simulation step
SIM_STEP = durstep_p.sim_step;
// Simulation duration
SIM_DURATION = durstep_p.sim_duration;

return(0);
};






























//-------------------------------------------------------------------------------------
// void ReadXMLtoTXT(...)
//-------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions lib/IO/IO_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Eigen::MatrixXf read_SpaceWeather(const char* filename, double start_epoch, int
// Load and read simulation parameters XML file and validate it against an XML schema file
int XML_parser(const string XML_simparam_file, string& Orbit_ephemeris, string& Attitude_ephemeris, string& Data_path, string& planetephemeris, string& eop, string& pck_data, string& leapsecond, string& magneticfield, string& gravityfield, string& atmosphere, string& orbfile_name, string& attfile_name, string& sensors_filename, string& csv_torques_name, string& csv_accelerations_name, int& SIM_STEP, int& SIM_DURATION, Vector6d& init_orbtime, Vector6d& init_orbstate, double& phi, double& theta, double& psi, double& om_x, double& om_y, double& om_z, bool& initstate_in_RTN, bool& realtime, double& realtime_wait, bool& ggrad_on, bool& mag_on, bool& drag_on, bool& srp_on, int& nMAX, bool& sunmoon_on, string& Drag_Model, string& SRP_Model, string& AttitudeType, bool& attctrl_on, string& AttCtrlType, bool& orbctrl_on, string& OrbCtrlType, double& SC_mass, Mat3x3d& MoI, Vec3d& CoG, double& SC_Cd, double& SC_Cr, double& SC_Area_D, double& SC_Area_R, Vec3d& Mdip, Face& F_Xplus, Face& F_Xminus, Face& F_Yplus, Face& F_Yminus, Face& F_Zplus, Face& F_Zminus, SYS_params& Sensor_prm_SUN, SYS_params& Sensor_prm_EARTH, SYS_params& Sensor_prm_CSS1, SYS_params& Sensor_prm_CSS2, SYS_params& Sensor_prm_CSS3, SYS_params& Sensor_prm_CSS4, SYS_params& Sensor_prm_CSS5, SYS_params& Sensor_prm_CSS6, SYS_params& Sensor_prm_MAG, SYS_params& Sensor_prm_MAGstowed, SYS_params& Sensor_prm_RS, SYS_params& Sensor_prm_MAGTRQ, SYS_params& Sensor_prm_WHEEL1, SYS_params& Sensor_prm_WHEEL2, SYS_params& Sensor_prm_WHEEL3, SYS_params& Solarpan1_prm, SYS_params& Solarpan2_prm, SYS_params& Solarpan3_prm, SYS_params& OrbitPropulsion1_prm, SYS_params& OrbitPropulsion2_prm, vector<maneuver>& all_maneuvers);

// Load and read simulation parameters XML file and validate it against an XML schema file
int SGP4_XML_parser(const string XML_simparam_file, string& TLE_file, string& Data_path, string& eop, string& pck_data, string& leapsecond, string& orbfile_name, int& SIM_STEP, int& SIM_DURATION);

// Write simulation parameters read by parser XML_parser in a text file for verification purposes
void ReadXMLtoTXT(const string txt_file, string Orbit_ephemeris, string Attitude_ephemeris, string Data_path, string planetephemeris, string eop, string pck_data, string leapsecond, string magneticfield, string gravityfield, string atmosphere, string orbfile_name, string attfile_name, string sensors_filename, string csv_torques_name, string csv_accelerations_name, int SIM_STEP, int SIM_DURATION, Vector6d init_orbtime, Vector6d init_orbstate, double phi, double theta, double psi, double om_x, double om_y, double om_z, bool initstate_in_RTN, bool realtime, double realtime_wait, bool ggrad_on, bool mag_on, bool drag_on, bool srp_on, int nMAX, bool sunmoon_on, string Drag_Model, string SRP_Model, string AttitudeType, bool attctrl_on, string AttCtrlType, bool orbctrl_on, string OrbCtrlType, double SC_mass, Mat3x3d MoI, Vec3d CoG, double SC_Cd, double SC_Cr, double SC_Area_D, double SC_Area_R, Vec3d Mdip, Face F_Xplus, Face F_Xminus, Face F_Yplus, Face F_Yminus, Face F_Zplus, Face F_Zminus, SYS_params Sensor_prm_SUN, SYS_params Sensor_prm_EARTH, SYS_params Sensor_prm_CSS1, SYS_params Sensor_prm_CSS2, SYS_params Sensor_prm_CSS3, SYS_params Sensor_prm_CSS4, SYS_params Sensor_prm_CSS5, SYS_params Sensor_prm_CSS6, SYS_params Sensor_prm_MAG, SYS_params Sensor_prm_MAGstowed, SYS_params Sensor_prm_RS, SYS_params Sensor_prm_MAGTRQ, SYS_params Sensor_prm_WHEEL1, SYS_params Sensor_prm_WHEEL2, SYS_params Sensor_prm_WHEEL3, SYS_params Solarpan1_prm, SYS_params Solarpan2_prm, SYS_params Solarpan3_prm, SYS_params OrbitPropulsion1_prm, SYS_params OrbitPropulsion2_prm, vector<maneuver> all_maneuvers);

Expand Down
1 change: 1 addition & 0 deletions lib/IO/XML_Parser/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_NAVSOLCONV += $(wildcard $(SELF_DIR)/*.cpp)
H_SRC += $(wildcard $(SELF_DIR)/*.h)
Expand Down
1 change: 1 addition & 0 deletions lib/IO/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_NAVSOLCONV += $(wildcard $(SELF_DIR)/*.cpp)
H_SRC += $(wildcard $(SELF_DIR)/*.h)
Expand Down
1 change: 1 addition & 0 deletions lib/make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SELF_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
C_SRC += $(wildcard $(SELF_DIR)/*.c)
CPP_SRC_ATT += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_ORB += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_SGP4 += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_EVE += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_CONV += $(wildcard $(SELF_DIR)/*.cpp)
CPP_SRC_NAVSOLCONV += $(wildcard $(SELF_DIR)/*.cpp)
Expand Down
Loading

0 comments on commit 2b9f530

Please sign in to comment.