@@ -63,6 +63,7 @@ using dpslr::timing::timePointToModifiedJulianDateTime;
63
63
using dpslr::math::units::Angle;
64
64
using dpslr::math::units::DegreesU;
65
65
using dpslr::math::units::Degrees;
66
+ using dpslr::math::units::Seconds;
66
67
using dpslr::math::units::MillisecondsU;
67
68
using dpslr::math::units::Meters;
68
69
// Geocentric and geodetic containers.
@@ -85,11 +86,12 @@ using dpslr::utils::PredictorSlrPtr;
85
86
using dpslr::utils::PredictorSlrCPFPtr;
86
87
// Mount predictor related.
87
88
using dpslr::mount::PredictorMountSLR;
88
- // Helpers.
89
- using dpslr::helpers::strings::numberToStr;
90
- using dpslr::mount::PositionStatus;
89
+ using dpslr::mount::MountPredictionSLRV;
91
90
using dpslr::mount::MountTrackingSLR;
92
91
using dpslr::mount::TrackingAnalyzerConfig;
92
+ using dpslr::mount::PositionStatus;
93
+ // Helpers.
94
+ using dpslr::helpers::strings::numberToStr;
93
95
// ---------------------------------------------------------------------------------------------------------------------
94
96
95
97
// ---------------------------------------------------------------------------------------------------------------------
@@ -159,7 +161,6 @@ int main()
159
161
std::string python_plot_analysis (current_dir+" /python_scripts/Helper_Plotting_Analysis.py" );
160
162
std::string python_plot_track (current_dir+" /python_scripts/Helper_Plotting_Track.py" );
161
163
std::string python_cmd_analysis = " python \" " + python_plot_analysis + " \" " ;
162
- std::string python_cmd_track = " python \" " + python_plot_track + " \" " ;
163
164
164
165
// Create the ouput directory.
165
166
if (!dpslr::helpers::files::directoryExists (output_dir))
@@ -238,7 +239,8 @@ int main()
238
239
std::string example_alias = examples[example_selector].example_alias ;
239
240
PredictorSunPtr predictor_sun = examples[example_selector].predictor_sun ;
240
241
TrackingAnalyzerConfig analyzer_cfg = examples[example_selector].analyzer_cfg ;
241
- std::string track_csv_filename = example_alias + " _track.csv" ;
242
+ std::string track_csv_filename = example_alias + " _track_analyzed.csv" ;
243
+ std::string realtime_csv_filename = example_alias + " _track_realtime.csv" ;
242
244
243
245
// -------------------- PREDICTOR MOUNT PREPARATION ---------------------------------------------------------------
244
246
@@ -276,9 +278,6 @@ int main()
276
278
// Get the specializated SLR predictor to get useful information.
277
279
PredictorSlrCPFPtr pred_cpf_recover = PredictorSlrBase::specialization<PredictorSlrCPF>(predictor_cpf);
278
280
279
- // Get the new tracking start and end date. If there is sun overlapping at start or end, the affected date
280
- // is changed so the tracking will start or end after/before the sun security sector.
281
-
282
281
// Get the analyzed mount track with all the relevant data. You can use this data for example to print
283
282
// a polar plot with the space object pass, the mount track and the Sun position. In the example folder,
284
283
// you can see a Python illustrative example using the data of this struct.
@@ -356,8 +355,6 @@ int main()
356
355
file_analyzed_track << numberToStr (pred.sun_pred ->altaz_coord .az , 7 , 4 ) <<" ;" ;
357
356
file_analyzed_track << numberToStr (pred.sun_pred ->altaz_coord .el , 7 , 4 );
358
357
}
359
- //
360
-
361
358
}
362
359
//
363
360
// Close the file.
@@ -367,8 +364,7 @@ int main()
367
364
if (plot_data)
368
365
{
369
366
std::cout<<" Plotting analyzed data using Python helpers..." <<std::endl;
370
- python_cmd_analysis += (output_dir + " /" + track_csv_filename);
371
- if (system (python_cmd_analysis.c_str ()))
367
+ if (system (std::string (python_cmd_analysis + output_dir + " /" + track_csv_filename).c_str ()))
372
368
std::cout<<" Plotting failed!!" <<std::endl;
373
369
}
374
370
@@ -377,52 +373,127 @@ int main()
377
373
// TODO
378
374
// We have some issues at this momment in the real time predictor.
379
375
380
- /*
376
+ // Get the new tracking start and end date. If there is sun overlapping at start or end, the affected date
377
+ // is changed so the tracking will start or end after/before the sun security sector.
378
+ MJDateTime track_start = predictor_mount.getMountTrackingSLR ().track_info .mjdt_start ;
379
+ MJDateTime track_end = predictor_mount.getMountTrackingSLR ().track_info .mjdt_end ;
380
+
381
+ // Store the real time track data into a CSV file (only part of the data for easy usage).
382
+ // TODO: Store the full track data as JSON.
383
+ // --
384
+ // Create the file and header.
385
+ std::ofstream file_realtime_track (output_dir + " /" + realtime_csv_filename, std::ios_base::out);
386
+ file_realtime_track << data.str ();
387
+ file_realtime_track << " mjd;sod;pass_az;pass_el;track_az;track_el;sun_az;sun_el" ;
381
388
382
- // Real time.
389
+ // Now, we are simulating real time prediction operations. We can now predict any position within the valid
390
+ // tracking time window (stored in TrackingInfo struct). For the example, we will ask predictions from start to
391
+ // end with a step of 0.1 (simulating real time operations at 10 Hz in the tracking mount).
383
392
384
- // Now, we have the tracking configured, so we can ask the tracking to predict any position within the valid
385
- // tracking time window (determined by tracking start and tracking end). For the example, we will ask
386
- // predictions from start to end with a step of 0.5 s.
387
- MJDateTime mjd = mjd_start;
388
- PredictorMountSLR::MountPredictionSLRs results;
393
+ // Containers.
394
+ MJDateTime mjd = track_start;
395
+ MountPredictionSLRV results;
389
396
390
- while (mjd < mjd_end )
397
+ while (mjd < track_end )
391
398
{
392
399
// Store the resulting prediction
393
400
results.push_back ({});
394
401
auto status = predictor_mount.predict (mjd, results.back ());
395
402
396
- if (status == PredictorMountSLR::PositionStatus::INSIDE_SUN)
403
+ if (status == PositionStatus::ELEVATION_CLIPPED)
404
+ {
405
+ //
406
+ }
407
+ else if (status == PositionStatus::OUTSIDE_SUN)
408
+ {
409
+ // In this case the position predicted is valid and it is going outside a sun security sector. This is the
410
+ // normal case.
411
+ }
412
+ else if (status == PositionStatus::INSIDE_SUN)
397
413
{
398
414
// In this case the position predicted is valid, but it is going through a sun security sector.
399
415
// This case is only possible if sun avoid algorithm is disabled.
400
416
// BEWARE. If the mount points directly to this position it could be dangerous.
401
417
}
402
- else if (status == PredictorMountSLR::PositionStatus::OUTSIDE_SUN)
418
+
419
+ else if (status == PositionStatus::AVOIDING_SUN)
403
420
{
404
- // In this case the position predicted is valid and it is going outside a sun security sector. This is the
405
- // normal case.
421
+ // In this case the position predicted is valid and it is going through an alternative way to avoid a sun
422
+ // security sector. While the tracking returns this status, the tracking_position member in result
423
+ // represents the position used to avoid the sun (the secure position), while prediction_result contains
424
+ // the true position of the object (not secure).
425
+
406
426
}
407
- else if (status == PredictorMountSLR:: PositionStatus::AVOIDING_SUN )
427
+ else if (status == PositionStatus::CANT_AVOID_SUN )
408
428
{
409
429
// In this case the position predicted is valid and it is going through an alternative way to avoid a sun
410
430
// security sector. While the tracking returns this status, the tracking_position member in result
411
431
// represents the position used to avoid the sun (the secure position), while prediction_result contains
412
432
// the true position of the object (not secure).
413
433
414
434
}
415
- else
435
+ else if (status == PositionStatus::OUT_OF_TRACK)
416
436
{
417
- //std::cout << "Error at getting position " << status;
437
+ // Bad situation, the prediction time requested is out of track. Stop the tracking and notify to client.
438
+ // However, this should not happen if all is ok in the mount tracking controller software. Maybe if
439
+ // something is wrong with the CPF or in the timing tracking mount subsystem or in the SLR station system.
440
+ std::cerr << " Module: TrackingMount | Example: PredictorMountSLR" << std::endl;
441
+ std::cerr << " Error: The requested position is in OUT_OF_TRACK state." << std::endl;
442
+ std::cerr << " Example finished. Press Enter to exit..." << std::endl;
443
+ std::cin.ignore (std::numeric_limits<std::streamsize>::max (), ' \n ' );
444
+ return -1 ;
445
+ }
446
+ else if (status == PositionStatus::PREDICTION_ERROR)
447
+ {
448
+ // Bad situation, stop the tracking and notify to client. However, this should not happen if all is ok in
449
+ // the mount tracking controller software. Maybe if something is wrong with the with the CPF or in the
450
+ // timing tracking mount subsystem or in the SLR station system.
451
+ std::cerr << " Module: TrackingMount | Example: PredictorMountSLR" << std::endl;
452
+ std::cerr << " Error: The requested position is in PREDICTION_ERROR state." << std::endl;
453
+ std::cerr << " Example finished. Press Enter to exit..." << std::endl;
454
+ std::cin.ignore (std::numeric_limits<std::streamsize>::max (), ' \n ' );
418
455
return -1 ;
419
456
}
420
457
421
458
// Advance to next position
422
- mjd.add(0.5L);
459
+ mjd.add (Seconds (0 .1L ));
460
+ }
461
+
462
+ // Iterate the real time simulated predictions.
463
+ for (const auto & pred : results)
464
+ {
465
+ // Auxiliar container for track data.
466
+ std::string track_az = " " ;
467
+ std::string track_el = " " ;
468
+ //
469
+ // At this point, you only must check if the prediction is outside track. This is becaouse, for example,
470
+ // the beginning of the real satellite pass may coincide with the Sun sector, so at those points there
471
+ // would be no data from the mount's track, only the real pass.
472
+ if (pred.status != PositionStatus::OUT_OF_TRACK)
473
+ {
474
+ track_az = numberToStr (pred.mount_pos ->altaz_coord .az ,7 , 4 );
475
+ track_el = numberToStr (pred.mount_pos ->altaz_coord .el ,7 , 4 );
476
+
477
+ // Store the data.
478
+ file_realtime_track <<' \n ' ;
479
+ file_realtime_track << std::to_string (pred.mjdt .datetime ()) <<" ;" ;
480
+ file_realtime_track << numberToStr (pred.slr_pred ->instant_data ->altaz_coord .az , 7 , 4 ) <<" ;" ;
481
+ file_realtime_track << numberToStr (pred.slr_pred ->instant_data ->altaz_coord .el , 7 , 4 ) <<" ;" ;
482
+ file_realtime_track << track_az <<" ;" ;
483
+ file_realtime_track << track_el <<" ;" ;
484
+ file_realtime_track << numberToStr (pred.sun_pred ->altaz_coord .az , 7 , 4 ) <<" ;" ;
485
+ file_realtime_track << numberToStr (pred.sun_pred ->altaz_coord .el , 7 , 4 );
486
+ }
423
487
}
488
+ // Close the file.
489
+ file_realtime_track.close ();
424
490
425
- */
491
+ if (plot_data)
492
+ {
493
+ std::cout<<" Plotting real time simulated data using Python helpers..." <<std::endl;
494
+ if (system (std::string (python_cmd_analysis + output_dir + " /" + realtime_csv_filename).c_str ()))
495
+ std::cout<<" Plotting failed!!" <<std::endl;
496
+ }
426
497
427
498
// Final wait.
428
499
std::cout << " Example finished. Press Enter to exit..." << std::endl;
0 commit comments