00001 #ifndef RIDE_CONFIG_HPP
00002 #define RIDE_CONFIG_HPP
00003
00004 #include <list>
00005 #include "ride/geom.hpp"
00006 #include "ride/constraints.hpp"
00007 #include "ride/threat.hpp"
00008 #include "ride/allocJammer.hpp"
00009 #include "ride/tableOpt.hpp"
00010 #include "ride/smoother.hpp"
00011
00012
00013
00014
00015 namespace jafar {
00016
00017 namespace ride {
00018
00023 class TimeLine {
00024 private :
00025 std::list<Interval> timeLine;
00026 std::list<int> wpIdList;
00027 SplitParam splitParam;
00028 bool readyToSplit;
00029 public :
00030 TimeLine();
00031 ~TimeLine();
00032 void computeTimeLine(Formation const& form, std::list<Constraint*> const& constList, Trajectory const& traj);
00033 void updateAdd(Constraint* constraint);
00034 void updateRemove(std::list<Constraint*> const& constList, ConstraintType type);
00035 Interval getInterval(int wpId) const;
00036 };
00037
00054 struct configState {
00055 int updateStep;
00056 int wpId;
00057 double distanceOnTraj;
00058 bool plannedMode;
00059 int planStep;
00060 int finalPlanStep;
00061 bool splitRunning;
00062 bool splitReady;
00063 double Dmin;
00064 double Dmax;
00065 double corridor;
00066 double meanRefreshTime;
00067 double meanTransitionTime;
00068 std::list<unprotectedSlot> unprotected;
00069 };
00070
00076 class Config {
00077 private :
00078 int updateStep;
00079 int slotUpdateStep;
00080 Formation goal,current;
00081 Trajectory trajectory;
00082 int currentWP;
00083 std::list<Constraint*> constraintList;
00084 GlobalThreat threats;
00085 GlobalAlloc alloc;
00086 TimeLine timeLine;
00087 bool plannedMode;
00088 int planStep;
00089 int lastPlanMoveStep;
00090 MultiTrajectory multiTraj;
00091 double meanRefreshTime;
00092 double meanTransitionTime;
00093 bool splitRunning;
00094 bool splitReady;
00095 std::list<int> splitGroupId;
00096 std::list<unprotectedSlot> unprotected;
00097
00098 void computeFormation(posTraj const& pos,
00099 Interval const& inter);
00100 std::vector<tagSlot> placeSingleFormation(
00101 posTraj const& pos,
00102 Interval const& inter,
00103 std::list<Alloc> & allocList);
00104 std::vector<tagSlot> placeGroupFormation(
00105 posTraj const& pos,
00106 Interval const& inter,
00107 std::list<Alloc> & allocList);
00108 void computePotential(posTraj const& pos,
00109 Interval const& inter);
00110 Vect getPotAttractive(State const& uav,
00111 State const& jammer,
00112 Vect const& pos,
00113 double Dmin);
00114 bool testPlannedMode(int slotUpdate, int planUpdate);
00115 bool plannedMoveNeeded() const;
00116 bool setMultiTrajStep(int index);
00117 bool testSplit(Interval const& inter) const;
00118
00119 public :
00120 Config(Formation const& form);
00121 ~Config();
00122 void addConstraint(std::list<Constraint*> fullConstList);
00123 void addConstraint(Constraint* constraint);
00124 void removeConstraint(int id);
00125 void clearConstraintList();
00126 std::list<Constraint*> getConstraintList() const;
00127 void addThreat(Threat threat);
00128 void removeThreat(int id);
00129 void clearThreatList();
00130 GlobalThreat getThreatList() const;
00131 void computeTimeLine(Trajectory const& traj);
00132 GlobalAlloc getAllocation() const;
00133 std::list<FormationCommand> updateFormation(Formation const& form,
00134 int slotUpdate = GC::SLOT_UPDATE_RATE,
00135 int planUpdate = GC::PLAN_UPDATE_RATE);
00136 configState getConfigState() const;
00137 Formation joinFormation(std::list<Formation> formList) const;
00138 std::list<Formation> splitFormation() const;
00139 void splitDone();
00140 };
00141
00142 }
00143
00144 }
00145
00146 #endif
00147