🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
EventDetector.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstMath/ODEEventDetector.hpp"
25#include "AstUtil/ObjectNamed.hpp"
26#include "AstUtil/Dimension.hpp"
27
28AST_NAMESPACE_BEGIN
29
30
31class SpacecraftState;
32class ODEEventDetector;
33class StateMapper;
34
38class AST_CORE_API EventDetector: public ObjectNamed
39{
40public:
42 AST_OBJECT(EventDetector)
43 AST_PROPERT(active)
44 AST_PROPERT(repeatCount)
45 AST_PROPERT(threshold)
46 AST_PROPERT(goal)
47 EventDetector() = default;
48 virtual ~EventDetector() = default;
49
54 virtual double getDifference(const SpacecraftState& state, double t) const{return getValue(state, t) - goal_;}
55
60 virtual double getValue(const SpacecraftState& state, double t) const = 0;
61
64 virtual Dimension getDimension() const {return EDimension::eUnit;}
65
68 bool isAngle() const {return getDimension() == EDimension::eAngle;}
69public:
70
75 ODEEventDetector* newODEEventDetector(StateMapper* stateMapper) const;
76
77public: // rtti 暂时不支持枚举类型
78
79 EDirection direction() const {return direction_;}
80 void setDirection(EDirection dir) {direction_ = dir;}
81
82PROPERTIES:
83
84 bool active() const {return active_;}
85 void setActive(bool active) {active_ = active;}
86
87 int repeatCount() const {return repeatCount_;}
88 void setRepeatCount(int count) {repeatCount_ = count;}
89
90
91 double threshold() const {return threshold_;}
92 void setThreshold(double threshold) {threshold_ = threshold;}
93
94 double goal() const {return goal_;}
95 void setGoal(double goal) {goal_ = goal;}
96
97private:
98 bool active_{true};
99 int repeatCount_{1};
100 EDirection direction_{EDirection::eBoth};
101 double threshold_{1e-10};
102 double goal_{0.0};
103};
104
105
108template<typename Func>
110{
111public:
112 explicit EventDetectorGeneric(Func func)
113 : func_(std::move(func))
114 {}
115
116 double getValue(const SpacecraftState& state, double t) const override {
117 return func_(state, t);
118 }
119
120private:
121 Func func_;
122};
123
124
125AST_NAMESPACE_END
量纲
定义 Dimension.hpp:360
泛型事件检测器
定义 EventDetector.hpp:110
double getValue(const SpacecraftState &state, double t) const override
获取事件检测开关函数的值
定义 EventDetector.hpp:116
事件检测基类 事件检测基类,用于检测事件是否发生。 参考orekit的EventDetector类
定义 EventDetector.hpp:39
virtual double getValue(const SpacecraftState &state, double t) const =0
获取事件检测开关函数的值
bool isAngle() const
是否为角度事件检测器
定义 EventDetector.hpp:68
virtual Dimension getDimension() const
获取事件检测开关函数的量纲
定义 EventDetector.hpp:64
virtual double getDifference(const SpacecraftState &state, double t) const
获取事件检测开关函数与目标值的差值
定义 EventDetector.hpp:54
ODE积分的事件检测器
定义 ODEEventDetector.hpp:36
EDirection
事件检测开关函数的条件
定义 ODEEventDetector.hpp:40
命名对象
定义 ObjectNamed.hpp:36
航天器状态,包含轨道状态、航天器参数(质量、面积、阻力系数、光压、密度、压力、温度等)
定义 SpacecraftState.hpp:39
状态映射器
定义 StateMapper.hpp:36
@ eUnit
单位量纲