Skip to content

Commit 1dfc945

Browse files
author
AngelVeraHerrera
committed
merge: rebasing.
1 parent 340eda4 commit 1dfc945

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

LibDegorasSLR/examples/TrackingMount/PredictorMountSLR/TrackingMount_PredictorMountSLR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int main()
129129
// -------------------- EXAMPLES CONFIGURATION ---------------------------------------------------------------------
130130

131131
// Example selector.
132-
size_t example_selector = 6; // Select the example to process (between reals and sintetics).
132+
size_t example_selector = 1; // Select the example to process (between reals and sintetics).
133133
bool plot_data = true; // Flag for enable the data plotting using a Python3 (>3.9) helper script.
134134

135135
// SFEL station geodetic position in degrees (north and east > 0) with 8 decimals (~1 mm precision).

LibDegorasSLR/includes/LibDegorasSLR/TrackingMount/types/tracking_analyzer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ namespace dpslr{
5353
namespace mount{
5454
// =====================================================================================================================
5555

56+
// CONSTANTS
57+
// =====================================================================================================================
58+
const math::units::Degrees kAvoidAngleOffset = 0.5L; ///< Offset to apply to avoid the Sun sector.
59+
// =====================================================================================================================
60+
5661
// ---------------------------------------------------------------------------------------------------------------------
5762
using timing::types::MJDateTime;
5863
using timing::types::MJDate;
@@ -71,6 +76,7 @@ using astro::PredictionSun;
7176
using astro::PredictionSunV;
7277
// ---------------------------------------------------------------------------------------------------------------------
7378

79+
7480
// TODO LIST:
7581
// If a not tracking movement (absolute, relative, continuous) starts at sun, the mount must go to error state.
7682
// If it ends at sun, the movment is not valid.

LibDegorasSLR/includes/LibDegorasSLR/TrackingMount/types/tracking_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ struct TrackingInfo
271271
TrackingInfo() :
272272
sun_deviation(false),
273273
sun_collision(false),
274+
sun_collision_high_el(false),
274275
sun_collision_at_middle(false),
275276
sun_collision_at_start(false),
276277
sun_collision_at_end(false),
@@ -296,6 +297,7 @@ struct TrackingInfo
296297
// Tracking alterations.
297298
bool sun_deviation; ///< Flag indicating if the track was deviated from pass due to Sun.
298299
bool sun_collision; ///< Flag indicating if the pass has a collision with the Sun.
300+
bool sun_collision_high_el; ///< Flag indicating if the pass has a collision with the Sun at high elevation.
299301
bool sun_collision_at_middle; ///< Flag indicating if the pass has a collision at middle with the Sun.
300302
bool sun_collision_at_start; ///< Flag indicating if the pass has a collision at start with the Sun.
301303
bool sun_collision_at_end; ///< Flag indicating if the pass has a collision at end with the Sun.

LibDegorasSLR/sources/TrackingMount/tracking_analyzer.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ bool TrackingAnalyzer::analyzeTrackingMiddle()
399399
MJDateTime max_elev_mjdt = 0;
400400
long double max_elev = -1.0L;
401401
const long double cfg_max_el = static_cast<long double>(this->config_.max_elev);
402-
const long double sun_avoid_angle = static_cast<long double>(this->config_.sun_avoid_angle);
402+
long double sun_avoid_angle = static_cast<long double>(this->config_.sun_avoid_angle) + kAvoidAngleOffset;
403403
TrackingPredictionV::iterator sun_sector_start;
404404

405405
// Check the tracking maximum altitudes. Positions that trespasses will be clipped to maximum elevation.
@@ -435,13 +435,15 @@ bool TrackingAnalyzer::analyzeTrackingMiddle()
435435
if(inside_sun && sun_high)
436436
{
437437
bool stop = false;
438-
long double limit_el = it->sun_pred.altaz_coord.el - sun_avoid_angle;
438+
auto sun_min_el_it = std::min_element(this->begin_, this->end_,
439+
[](const auto& a, const auto& b){return a.sun_pred.altaz_coord.el < b.sun_pred.altaz_coord.el;});
440+
long double limit_el = sun_min_el_it->sun_pred.altaz_coord.el - sun_avoid_angle;
439441
// TODO: if cfg_max_el is less than limit_el, then this position should not be called AVOIDING_SUN
440442
// Maybe there should be a position status LIMITED_ELEVATION or similar for this case and for the
441443
// case when elevation is clipped to max_el.
442444
limit_el = (limit_el < cfg_max_el) ? limit_el : cfg_max_el;
443445
this->track_info_.sun_deviation = true;
444-
this->track_info_.sun_collision_high = true;
446+
this->track_info_.sun_collision_high_el = true;
445447

446448
// Check backward.
447449
for (auto it_internal = it; it_internal != this->begin_ || !stop; it_internal--)
@@ -474,35 +476,32 @@ bool TrackingAnalyzer::analyzeTrackingMiddle()
474476
}
475477
}
476478
}
477-
478479
// If sun avoid is applied we have to store the data for each sector where the tracking goes through a sun
479480
// security sector.This data will be used for calculating an alternative trajetctory at those sectors.
480481
else if (inside_sun)
481482
{
482-
// If there is a sun collision, start saving sun positions for this sector.
483-
// The first position is the first position before entering
484-
// the sector, i.e., it is ouside sun security sector.
483+
// If there is a sun collision, start saving sun positions for this sector. The first position is the
484+
// first position before entering the sector, i.e., it is ouside sun security sector.
485485
if (!in_sun_sector)
486486
{
487487
in_sun_sector = true;
488488
sun_sector_start = it-1;
489489
sun_sector.altaz_entry = sun_sector_start->pos.altaz_coord;
490490
sun_sector.mjdt_entry = sun_sector_start->mjdt;
491-
492491
}
493492
}
494493
else if (!inside_sun && in_sun_sector)
495494
{
496-
// If we were inside a sun sector, and we are going out of it,
497-
// check sun sector rotation direction and positions within the sector and store the sector.
498-
// The last position stored is the first position after exiting the sector,
499-
// i.e., it is outside sun security sector.
495+
// If we were inside a sun sector, and we are going out of it, check sun sector rotation direction and
496+
// positions within the sector and store the sector. The last position stored is the first position
497+
// after exiting the sector, i.e., it is outside sun security sector.
500498
in_sun_sector = false;
501499
sun_sector.altaz_exit = it->pos.altaz_coord;
502500
sun_sector.mjdt_exit = it->mjdt;
503501
// If sector has no valid rotation direction, mark tracking as not valid, since sun cannot be avoided.
504502
if (!this->setSunSectorRotationDirection(sun_sector, sun_sector_start, it))
505503
return false;
504+
// Check the Sun sector positions.
506505
this->checkSunSectorPositions(sun_sector, sun_sector_start, it);
507506
this->sun_sectors_.push_back(std::move(sun_sector));
508507
sun_sector = {};
@@ -527,13 +526,13 @@ bool TrackingAnalyzer::analyzeTrackingMiddle()
527526

528527
bool TrackingAnalyzer::insideSunSector(const AltAzPos& pass_pos, const AltAzPos& sun_pos) const
529528
{
530-
531529
long double diff_az = pass_pos.az - sun_pos.az;
532530
// If azimuth difference is greater than 180, then take the shorter way
533531
if (diff_az > 180.L)
534532
diff_az = 360.L - diff_az;
535533
long double diff_el = pass_pos.el - sun_pos.el;
536-
return std::sqrt(diff_az * diff_az + diff_el * diff_el) < this->config_.sun_avoid_angle;
534+
long double sun_avoid_angle = static_cast<long double>(this->config_.sun_avoid_angle) + kAvoidAngleOffset;
535+
return std::sqrt(diff_az * diff_az + diff_el * diff_el) < sun_avoid_angle;
537536
}
538537

539538
bool TrackingAnalyzer::setSunSectorRotationDirection(SunCollisionSector &sector,
@@ -607,10 +606,10 @@ bool TrackingAnalyzer::setSunSectorRotationDirection(SunCollisionSector &sector,
607606
cw_angle = entry_angle + time_perc * cw_angle;
608607
ccw_angle = entry_angle + time_perc * ccw_angle;
609608

610-
long double elev_cw = it->sun_pred.altaz_coord.el +
611-
this->config_.sun_avoid_angle * std::sin(cw_angle);
612-
long double elev_ccw = it->sun_pred.altaz_coord.el +
613-
this->config_.sun_avoid_angle * std::sin(ccw_angle);
609+
long double sun_avoid_angle = static_cast<long double>(this->config_.sun_avoid_angle) + kAvoidAngleOffset;
610+
611+
long double elev_cw = it->sun_pred.altaz_coord.el + sun_avoid_angle * std::sin(cw_angle);
612+
long double elev_ccw = it->sun_pred.altaz_coord.el + sun_avoid_angle * std::sin(ccw_angle);
614613

615614
long double cfg_max_el = static_cast<long double>(this->config_.max_elev);
616615
long double cfg_min_el = static_cast<long double>(this->config_.min_elev);
@@ -768,17 +767,19 @@ long double TrackingAnalyzer::calcSunAvoidTrajectory(const MJDateTime &mjdt,
768767
void TrackingAnalyzer::calcSunAvoidPos(TrackingPrediction &pred,
769768
const SunCollisionSector &sector) const
770769
{
770+
long double sun_avoid_angle = static_cast<long double>(this->config_.sun_avoid_angle) + kAvoidAngleOffset;
771+
771772
// Get the trajectory avoid angle.
772773
long double angle_avoid = this->calcSunAvoidTrajectory(pred.mjdt, sector, pred.sun_pred.altaz_coord);
773774
// Calculate new azimuth and elevation using trajectory avoid angle
774-
Degrees new_az = pred.sun_pred.altaz_coord.az + this->config_.sun_avoid_angle * std::cos(angle_avoid);
775+
Degrees new_az = pred.sun_pred.altaz_coord.az + sun_avoid_angle * std::cos(angle_avoid);
775776
// Normalize new azimuth
776777
if (new_az < 0.L)
777778
new_az += 360.L;
778779
if (new_az > 360.L)
779780
new_az -= 360.L;
780781

781-
Degrees new_el = pred.sun_pred.altaz_coord.el + this->config_.sun_avoid_angle * std::sin(angle_avoid);
782+
Degrees new_el = pred.sun_pred.altaz_coord.el + sun_avoid_angle * std::sin(angle_avoid);
782783

783784
// Store difference between original position and new position
784785
pred.pos.diff_az = pred.pos.altaz_coord.az - new_az;

0 commit comments

Comments
 (0)