Skip to content

Commit b6a017c

Browse files
committed
srp not working
1 parent 43f5a97 commit b6a017c

File tree

5 files changed

+72
-29
lines changed

5 files changed

+72
-29
lines changed

bin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set(BIN_SOURCES
44
test_deriv_costg.cpp
55
eom.cpp
6-
stm.cpp
6+
#stm.cpp
77
)
88

99
# Process each source file and create an executable

bin/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ atmospheric-tide:
7676

7777
satellite-attitude:
7878
satellite: ja3
79+
cnes_sat_file: data/ja3mass.txt
7980
# data_file:
8081
data_file: data/qua_ja3.csv
81-
cnes_sat_file: data/ja3mass.txt

bin/eom.cpp

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,28 +265,40 @@ int deriv(double tsec, Eigen::Ref<const Eigen::VectorXd> y0,
265265
ac += dso::iers2010_relativistic_acceleration(y0, rsun);
266266
}
267267

268-
/* Solar Radiation Pressure */
269-
if (params->matt) {
268+
if (params->mCr) {
270269
const double of =
271-
dso::conical_occultation(y0.segment<3>(0), rsun.segment<3>(0));
270+
/* dso::conical_occultation(y0.segment<3>(0), rsun.segment<3>(0)); */
271+
dso::conical_occultation(y0.segment<3>(0), rsun.segment<3>(0), Eigen::Matrix<double,3,1>::Zero(), ::iers2010::Re) *
272+
dso::conical_occultation(y0.segment<3>(0), rsun.segment<3>(0), rmoon, 1737e3);
273+
272274
if (of > 0e0) {
273-
/* get attitude */
274-
if (params->matt->attitude_at(tt, *(params->mattdata))) {
275-
fprintf(stderr, "[ERROR] Failed getting attitude!\n");
275+
/* Solar Radiation Pressure */
276+
if (params->matt) {
277+
/* get attitude */
278+
if (params->matt->attitude_at(tt, *(params->mattdata))) {
279+
fprintf(stderr, "[ERROR] Failed getting attitude!\n");
276280
#ifdef USE_BOOST
277-
throw std::runtime_error(
278-
"ERROR. Failed computing derivative [attitude]\n");
281+
throw std::runtime_error(
282+
"ERROR. Failed computing derivative [attitude]\n");
279283
#else
280-
return 200;
284+
return 200;
281285
#endif
286+
}
287+
/* we may need (depending on satellite) the satellite-to-sun vector */
288+
Eigen::Vector3d sat2sun = -y0.segment<3>(0)+rsun.segment<3>(0);
289+
/* compute SRP acceleration */
290+
ac += (params->mCr * of) *
291+
dso::solar_radiation_pressure(
292+
params->msatmm->rotate_macromodel(
293+
params->mattdata->quaternions(),
294+
params->mattdata->angles(), &sat2sun),
295+
y0.segment<3>(0), rsun.segment<3>(0), params->msatmm->satellite_mass());
296+
} else {
297+
ac += (params->mCr * of) *
298+
dso::solar_radiation_pressure(
299+
params->msatmm->srp_cannoball_area(), y0.segment<3>(0),
300+
rsun.segment<3>(0), params->msatmm->satellite_mass());
282301
}
283-
/* compute SRP acceleration */
284-
ac +=
285-
(of / params->msatmm->satellite_mass()) *
286-
dso::solar_radiation_pressure(params->msatmm->rotate_macromodel(
287-
params->mattdata->quaternions(),
288-
params->mattdata->angles()),
289-
y0.segment<3>(0), rsun.segment<3>(0));
290302
}
291303
}
292304

@@ -454,7 +466,7 @@ int main(int argc, char *argv[]) {
454466
}
455467

456468
++it;
457-
if (it > 400)
469+
if (it > 600)
458470
break;
459471
}
460472

include/integration_parameters.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ namespace dso
4040
dso::attitude_details::MeasuredAttitudeData *mattdata{nullptr};
4141
/* satellite Macromodel */
4242
dso::SatelliteMacromodel *msatmm{nullptr};
43+
/* dynamic parameter for SRP, i.e. Cr */
44+
double mCr;
4345

4446
/* third body gravity
4547
* | Bit Nr. | Default state

src/integration_parameters_from_config.cpp

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,56 @@ dso::IntegrationParameters::from_config(const char *fn,
230230
}
231231
params.mdealias = dap;
232232

233+
/* get the satellite (mandatory) */
234+
dso::SATELLITE sat(dso::SATELLITE::UNKNOWN);
235+
if (is_nonempty_string(config["satellite-attitude"]["satellite"])) {
236+
const auto s = config["satellite-attitude"]["satellite"].as<std::string>();
237+
try {
238+
sat = dso::translate_satid(s.c_str());
239+
} catch (std::exception &e) {
240+
fprintf(stderr, e.what());
241+
std::string err_msg = "[ERROR] Failed to translate satellite name "
242+
"from "
243+
"config parameters " +
244+
s + " (traceback:" + std::string(__func__) + ")\n";
245+
throw std::runtime_error(err_msg);
246+
}
247+
}
248+
233249
/* Satellite attitude (if model satellite-attitude::data_file is non-empty) */
234250
dso::SatelliteAttitude *satat = nullptr;
235-
dso::SatelliteMacromodel *satmm = nullptr;
236251
dso::attitude_details::MeasuredAttitudeData *mad = nullptr;
237252
if (is_nonempty_string(config["satellite-attitude"]["data_file"])) {
238253
const auto d = config["satellite-attitude"]["data_file"].as<std::string>();
239-
const auto s = config["satellite-attitude"]["satellite"].as<std::string>();
240254
try {
241-
const dso::SATELLITE sat = dso::translate_satid(s.c_str());
242255
satat = new dso::MeasuredAttitude(sat, d.c_str());
243256
mad = new dso::attitude_details::MeasuredAttitudeData(
244257
dso::measured_attitude_data_factory(sat));
245-
satmm = new dso::SatelliteMacromodel(
246-
dso::SatelliteMacromodel::createSatelliteMacromodel(sat));
247258
} catch (std::exception &e) {
248259
fprintf(stderr, e.what());
249260
std::string err_msg = "[ERROR] Failed to construct a SatelliteAttitude "
250-
"and/or SatelliteMacromodel instance from "
261+
"and/or MeasuredAttitudeData instance from "
251262
"config parameters " +
252-
s + ", " + d +
263+
d +
253264
" (traceback:" + std::string(__func__) + ")\n";
254265
throw std::runtime_error(err_msg);
255266
}
267+
}
268+
params.matt = satat; // attitude
269+
params.mattdata = mad; // attitude data (for retrieving attitude from stream)
256270

271+
/* create the macromodel (independent of attitude) */
272+
dso::SatelliteMacromodel *satmm = nullptr;
273+
{
274+
try {
275+
satmm = new dso::SatelliteMacromodel(
276+
dso::SatelliteMacromodel::createSatelliteMacromodel(sat));
277+
} catch (std::exception &e) {
278+
fprintf(stderr, e.what());
279+
std::string err_msg = "[ERROR] Failed to construct a SatelliteMacromodel"
280+
" instance from config parameters (traceback:" + std::string(__func__) + ")\n";
281+
throw std::runtime_error(err_msg);
282+
}
257283
if (is_nonempty_string(config["satellite-attitude"]["cnes_sat_file"])) {
258284
const auto c =
259285
config["satellite-attitude"]["cnes_sat_file"].as<std::string>();
@@ -265,9 +291,12 @@ dso::IntegrationParameters::from_config(const char *fn,
265291
}
266292
}
267293
}
268-
params.matt = satat;
269-
params.mattdata = mad;
270-
params.msatmm = satmm;
294+
params.msatmm = satmm; // macromodel (maybe used or not depending on attitude)
295+
296+
/* Dynamic parameters */
297+
{
298+
params.mCr = config["dynamic-parameters"]["Cr"].as<double>();
299+
}
271300

272301
/* return */
273302
return params;

0 commit comments

Comments
 (0)