Program Listing for File ephemeris_gen_app.h¶
↰ Return to documentation for file (applications/ephemeris/ephemeris_gen_app.h)
#pragma once
#include <vector>
#include "lupnt/applications/ephemeris/lunanet_almanac.h"
#include "lupnt/applications/ephemeris/lunanet_ephemeris.h"
#include "lupnt/applications/ephemeris/lunanet_sat_app.h"
#include "lupnt/conversions/frame_converter.h"
#include "lupnt/core/constants.h"
#include "lupnt/core/definitions.h"
namespace lupnt {
struct BroadcastMessage {
double t_generated_s = 0.0; // elapsed time this message was generated [s]
double t_start_s = 0.0; // validity-window start [s, same origin]
double t_end_s = 0.0; // validity-window end [s, same origin]
Frame frame = Frame::MOON_CI; // frame of the fitted arc (= agent dynamics frame)
VecXd params; // fitted parameter vector
};
struct EphemerisGenConfig {
bool generate_ephemeris = true;
bool generate_almanac = true;
EphemerisFitOptions ephemeris_options;
double ephemeris_window_s = 2.0 * SECS_HOUR;
double ephemeris_refresh_s = 0.0;
AlmanacFitOptions almanac_options;
double almanac_window_s = 15.0 * SECS_DAY;
double almanac_refresh_s = 0.0;
int ephemeris_fit_samples = 121;
int almanac_fit_samples = 361;
Frame output_frame = Frame::MOON_CI;
};
class EphemerisGenApp : public LunaNetSubApp {
public:
explicit EphemerisGenApp(EphemerisGenConfig config = {});
void Setup(LunaNetSatApp& app) override;
void Step(Real t) override;
void Finish() override;
const BroadcastMessage& GenerateEphemerisFromArc(double t_gen_s, const VecXd& t_s,
const MatXd& rv);
const BroadcastMessage& GenerateAlmanacFromArc(double t_gen_s, const VecXd& t_s,
const MatXd& rv);
const std::vector<BroadcastMessage>& GetEphemerisMessages() const { return ephemeris_msgs_; }
const std::vector<BroadcastMessage>& GetAlmanacMessages() const { return almanac_msgs_; }
const BroadcastMessage* LatestEphemeris(double t_s) const;
const BroadcastMessage* LatestAlmanac(double t_s) const;
const EphemerisGenConfig& GetConfig() const { return config_; }
const LansEphemeris& GetEphemerisModel() const { return ephemeris_; }
const LansAlmanac& GetAlmanacModel() const { return almanac_; }
private:
// Sample the owning agent's predicted arc over [t_gen, t_gen + window] at
// `n_samples` uniform epochs and fit the ephemeris (`is_ephemeris`) or almanac.
void GenerateFromAgent(double t_gen_s, double window_s, int n_samples, bool is_ephemeris);
static const BroadcastMessage* Latest(const std::vector<BroadcastMessage>& msgs, double t_s);
EphemerisGenConfig config_;
LansEphemeris ephemeris_;
LansAlmanac almanac_;
LunaNetSatApp* sat_app_ = nullptr;
std::vector<BroadcastMessage> ephemeris_msgs_;
std::vector<BroadcastMessage> almanac_msgs_;
double next_ephemeris_gen_s_ = 0.0;
double next_almanac_gen_s_ = 0.0;
};
} // namespace lupnt