]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIShip.hxx
ITM radio calculations are only considered valid
[flightgear.git] / src / AIModel / AIShip.hxx
1 // FGAIShip - AIBase derived class creates an AI ship
2 //
3 // Written by David Culp, started November 2003.
4 // with major amendments and additions by Vivian Meazza, 2004 - 2007 
5 //
6 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifndef _FG_AISHIP_HXX
23 #define _FG_AISHIP_HXX
24
25 #include "AIBase.hxx"
26 #include "AIFlightPlan.hxx"
27 #include <simgear/scene/material/mat.hxx>
28
29 class FGAIManager;
30
31 class FGAIShip : public FGAIBase {
32
33 public:
34
35     FGAIShip(object_type ot = otShip);
36     virtual ~FGAIShip();
37
38     virtual void readFromScenario(SGPropertyNode* scFileNode);
39
40     virtual bool init(bool search_in_AI_path=false);
41     virtual void bind();
42     virtual void unbind();
43     virtual void update(double dt);
44     virtual void reinit();
45
46     void setFlightPlan(FGAIFlightPlan* f);
47     void setRudder(float r);
48     void setRoll(double rl);
49     void ProcessFlightPlan( double dt);
50     void AccelTo(double speed);
51     void PitchTo(double angle);
52     void RollTo(double angle);
53     void YawTo(double angle);
54     void ClimbTo(double altitude);
55     void TurnTo(double heading);
56     void setCurrName(const string&);
57     void setNextName(const string&);
58     void setPrevName(const string&);
59     void setLeadAngleGain(double g);
60     void setLeadAngleLimit(double l);
61     void setLeadAngleProp(double p);
62     void setRudderConstant(double rc);
63     void setSpeedConstant(double sc);
64     void setFixedTurnRadius(double ft);
65     void setRollFactor(double rf);
66
67     void setTunnel(bool t);
68     void setInitialTunnel(bool t);
69
70     void setWPNames();
71     void setWPPos();
72
73     double sign(double x);
74
75     bool _hdg_lock;
76     bool _serviceable;
77     bool _waiting;
78     bool _new_waypoint;
79     bool _tunnel, _initial_tunnel;
80     bool _restart;
81
82     virtual const char* getTypeString(void) const { return "ship"; }
83     double _rudder_constant, _speed_constant, _hdg_constant, _limit ;
84     double _elevation_m, _elevation_ft;
85     double _missed_range, _tow_angle, _wait_count, _missed_count,_wp_range;
86     double _dt_count, _next_run;
87
88     FGAIWaypoint* prev; // the one behind you
89     FGAIWaypoint* curr; // the one ahead
90     FGAIWaypoint* next; // the next plus 1
91
92 protected:
93
94 private:
95
96
97     void setRepeat(bool r);
98     void setRestart(bool r);
99     void setMissed(bool m);
100
101     void setServiceable(bool s);
102     void Run(double dt);
103     void setStartTime(const string&);
104     void setUntilTime(const string&);
105     //void setWPPos();
106     void setWPAlt();
107     void setXTrackError();
108
109     SGGeod wppos;
110
111     const SGMaterial* _material;
112
113     double getRange(double lat, double lon, double lat2, double lon2) const;
114     double getCourse(double lat, double lon, double lat2, double lon2) const;
115     double getDaySeconds();
116     double processTimeString(const string& time);
117
118     bool initFlightPlan();
119     bool advanceFlightPlan (double elapsed_sec, double day_sec);
120
121     float _rudder, _tgt_rudder;
122
123     double _roll_constant, _roll_factor;
124     double _sp_turn_radius_ft, _rd_turn_radius_ft, _fixed_turn_radius;
125     double _old_range, _range_rate;
126     double _missed_time_sec;
127     double _start_sec;
128     double _day;
129     double _lead_angle;
130     double _lead_angle_gain, _lead_angle_limit, _proportion;
131     double _course;
132     double _xtrack_error;
133     double _curr_alt, _prev_alt;
134
135     string _prev_name, _curr_name, _next_name;
136     string _path;
137     string _start_time, _until_time;
138
139     bool _repeat;
140     bool _fp_init;
141     bool _missed;
142    
143
144 };
145
146 #endif  // _FG_AISHIP_HXX