Rev 97 | Rev 99 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 97 | Rev 98 | ||
---|---|---|---|
1 | /*#######################################################################################*/ |
1 | /*#######################################################################################*/ |
2 | /*#######################################################################################*/ |
2 | /*#######################################################################################*/ |
3 | 3 | ||
4 | // IMPORTANT NOTE: |
4 | // IMPORTANT NOTE: |
5 | 5 | ||
6 | // This is only a dummy implementation for errorfree compiling of the NaviCtrl sources. |
6 | // This is only a dummy implementation for errorfree compiling of the NaviCtrl sources. |
7 | 7 | ||
8 | // The GPS navigation routines are NOT included ! |
8 | // The GPS navigation routines are NOT included ! |
9 | 9 | ||
10 | /*#######################################################################################*/ |
10 | /*#######################################################################################*/ |
11 | /*#######################################################################################*/ |
11 | /*#######################################################################################*/ |
12 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
12 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
13 | /*#######################################################################################*/ |
13 | /*#######################################################################################*/ |
14 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
15 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
15 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
16 | // + Nur für den privaten Gebrauch |
16 | // + Nur für den privaten Gebrauch |
17 | // + FOR NON COMMERCIAL USE ONLY |
17 | // + FOR NON COMMERCIAL USE ONLY |
18 | // + www.MikroKopter.com |
18 | // + www.MikroKopter.com |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
20 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
21 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
21 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
22 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
22 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
23 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
23 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
24 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
24 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
25 | // + Verkauf von Luftbildaufnahmen, usw. |
25 | // + Verkauf von Luftbildaufnahmen, usw. |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
26 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
27 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
28 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
28 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
30 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
31 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
31 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
32 | // + eindeutig als Ursprung verlinkt werden |
32 | // + eindeutig als Ursprung verlinkt werden |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
34 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
34 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
35 | // + Benutzung auf eigene Gefahr |
35 | // + Benutzung auf eigene Gefahr |
36 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
36 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
37 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
37 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
38 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
38 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
39 | // + mit unserer Zustimmung zulässig |
39 | // + mit unserer Zustimmung zulässig |
40 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
40 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
41 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
41 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
42 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
42 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
43 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
43 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
44 | // + this list of conditions and the following disclaimer. |
44 | // + this list of conditions and the following disclaimer. |
45 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
45 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
46 | // + from this software without specific prior written permission. |
46 | // + from this software without specific prior written permission. |
47 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
47 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
48 | // + for non-commercial use (directly or indirectly) |
48 | // + for non-commercial use (directly or indirectly) |
49 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
49 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
50 | // + with our written permission |
50 | // + with our written permission |
51 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
51 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
52 | // + clearly linked as origin |
52 | // + clearly linked as origin |
53 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
53 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
54 | // |
54 | // |
55 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
55 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
56 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
56 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
57 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
57 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
58 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
58 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
59 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
59 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
60 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
60 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
61 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
61 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
62 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
62 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
63 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
63 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
64 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
64 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
65 | // + POSSIBILITY OF SUCH DAMAGE. |
65 | // + POSSIBILITY OF SUCH DAMAGE. |
66 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
66 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
67 | #include <stdio.h> |
67 | #include <stdio.h> |
68 | #include <stdlib.h> |
68 | #include <stdlib.h> |
69 | #include <math.h> |
69 | #include <math.h> |
70 | #include "91x_lib.h" |
70 | #include "91x_lib.h" |
71 | #include "main.h" |
71 | #include "main.h" |
72 | #include "uart1.h" |
72 | #include "uart1.h" |
73 | #include "GPS.h" |
73 | #include "GPS.h" |
74 | #include "timer.h" |
74 | #include "timer.h" |
75 | #include "spi_slave.h" |
75 | #include "spi_slave.h" |
76 | #include "waypoints.h" |
76 | #include "waypoints.h" |
77 | #include "i2c.h" |
77 | #include "i2c.h" |
78 | 78 | ||
79 | 79 | ||
80 | #define M_PI_180 (M_PI / 180.0f) |
80 | #define M_PI_180 (M_PI / 180.0f) |
81 | #define GPS_UPDATETIME_MS 200 // 200ms is 5 Hz |
81 | #define GPS_UPDATETIME_MS 200 // 200ms is 5 Hz |
82 | typedef enum |
82 | typedef enum |
83 | { |
83 | { |
84 | GPS_FLIGHT_MODE_UNDEF, |
84 | GPS_FLIGHT_MODE_UNDEF, |
85 | GPS_FLIGHT_MODE_FREE, |
85 | GPS_FLIGHT_MODE_FREE, |
86 | GPS_FLIGHT_MODE_AID, |
86 | GPS_FLIGHT_MODE_AID, |
87 | GPS_FLIGHT_MODE_WAYPOINT |
87 | GPS_FLIGHT_MODE_WAYPOINT |
88 | } GPS_FlightMode_t; |
88 | } GPS_FlightMode_t; |
89 | 89 | ||
90 | typedef struct |
90 | typedef struct |
91 | { |
91 | { |
92 | float Gain; |
92 | float Gain; |
93 | float P; |
93 | float P; |
94 | float I; |
94 | float I; |
95 | float D; |
95 | float D; |
96 | float A; |
96 | float A; |
97 | float ACC; |
97 | float ACC; |
98 | u32 P_Limit; |
98 | u32 P_Limit; |
99 | u32 I_Limit; |
99 | u32 I_Limit; |
100 | u32 D_Limit; |
100 | u32 D_Limit; |
101 | u32 PID_Limit; |
101 | u32 PID_Limit; |
102 | u32 BrakingDuration; |
102 | u32 BrakingDuration; |
103 | u8 MinSat; |
103 | u8 MinSat; |
104 | s8 StickThreshold; |
104 | s8 StickThreshold; |
105 | float WindCorrection; |
105 | float WindCorrection; |
106 | float SpeedCompensation; |
106 | float SpeedCompensation; |
107 | u32 OperatingRadius; |
107 | u32 OperatingRadius; |
108 | GPS_FlightMode_t FlightMode; |
108 | GPS_FlightMode_t FlightMode; |
109 | } __attribute__((packed)) GPS_Parameter_t; |
109 | } __attribute__((packed)) GPS_Parameter_t; |
110 | 110 | ||
111 | typedef struct |
111 | typedef struct |
112 | { |
112 | { |
113 | u8 Status; // invalid, newdata, processed |
113 | u8 Status; // invalid, newdata, processed |
114 | s32 North; // in cm |
114 | s32 North; // in cm |
115 | s32 East; // in cm |
115 | s32 East; // in cm |
116 | s32 Bearing; // in deg |
116 | s32 Bearing; // in deg |
117 | u32 Distance; // in cm |
117 | u32 Distance; // in cm |
118 | } __attribute__((packed)) GPS_Deviation_t; |
118 | } __attribute__((packed)) GPS_Deviation_t; |
119 | GPS_Deviation_t CurrentTargetDeviation; // Deviation from Target |
119 | GPS_Deviation_t CurrentTargetDeviation; // Deviation from Target |
120 | GPS_Deviation_t CurrentHomeDeviation; // Deviation from Home |
120 | GPS_Deviation_t CurrentHomeDeviation; // Deviation from Home |
121 | GPS_Deviation_t TargetHomeDeviation; // Deviation from Target to Home |
121 | GPS_Deviation_t TargetHomeDeviation; // Deviation from Target to Home |
122 | 122 | ||
123 | GPS_Stick_t GPS_Stick; |
123 | GPS_Stick_t GPS_Stick; |
124 | GPS_Parameter_t GPS_Parameter; |
124 | GPS_Parameter_t GPS_Parameter; |
125 | 125 | ||
126 | // the gps reference positions |
126 | // the gps reference positions |
127 | GPS_Pos_t GPS_HoldPosition = {0,0,0, INVALID}; // the hold position |
127 | GPS_Pos_t GPS_HoldPosition = {0,0,0, INVALID}; // the hold position |
128 | GPS_Pos_t GPS_HomePosition = {0,0,0, INVALID}; // the home position |
128 | GPS_Pos_t GPS_HomePosition = {0,0,0, INVALID}; // the home position |
129 | GPS_Pos_t * GPS_pTargetPosition = NULL; // pointer to the actual target position |
129 | GPS_Pos_t * GPS_pTargetPosition = NULL; // pointer to the actual target position |
130 | u32 GPS_TargetRadius = 0; // catch radius for target area |
130 | u32 GPS_TargetRadius = 0; // catch radius for target area |
131 | Waypoint_t* GPS_pWaypoint = NULL; // pointer to the actual waypoint |
131 | Waypoint_t* GPS_pWaypoint = NULL; // pointer to the actual waypoint |
132 | 132 | ||
133 | //------------------------------------------------------------- |
133 | //------------------------------------------------------------- |
134 | // Update GPSParamter |
134 | // Update GPSParamter |
135 | void GPS_UpdateParameter(void) |
135 | void GPS_UpdateParameter(void) |
136 | { |
136 | { |
137 | static GPS_FlightMode_t FlightMode_Old = GPS_FLIGHT_MODE_UNDEF; |
137 | static GPS_FlightMode_t FlightMode_Old = GPS_FLIGHT_MODE_UNDEF; |
138 | // in case of bad receiving conditions |
138 | // in case of bad receiving conditions |
139 | if(FC.RC_Quality < 100) |
139 | if(FC.RC_Quality < 100) |
140 | { // set fixed parameter |
140 | { // set fixed parameter |
141 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
141 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
142 | GPS_Parameter.Gain = (float) 100; |
142 | GPS_Parameter.Gain = (float) 100; |
143 | GPS_Parameter.P = (float) 90; |
143 | GPS_Parameter.P = (float) 90; |
144 | GPS_Parameter.I = (float) 90; |
144 | GPS_Parameter.I = (float) 90; |
145 | GPS_Parameter.D = (float) 90; |
145 | GPS_Parameter.D = (float) 90; |
146 | GPS_Parameter.A = (float) 90; |
146 | GPS_Parameter.A = (float) 90; |
147 | GPS_Parameter.ACC = (float) 0; |
147 | GPS_Parameter.ACC = (float) 0; |
148 | GPS_Parameter.P_Limit = 90; |
148 | GPS_Parameter.P_Limit = 90; |
149 | GPS_Parameter.I_Limit = 90; |
149 | GPS_Parameter.I_Limit = 90; |
150 | GPS_Parameter.D_Limit = 90; |
150 | GPS_Parameter.D_Limit = 90; |
151 | GPS_Parameter.PID_Limit = 200; |
151 | GPS_Parameter.PID_Limit = 200; |
152 | GPS_Parameter.BrakingDuration = 0; |
152 | GPS_Parameter.BrakingDuration = 0; |
153 | GPS_Parameter.SpeedCompensation = (float) 30; |
153 | GPS_Parameter.SpeedCompensation = (float) 30; |
154 | GPS_Parameter.MinSat = 6; |
154 | GPS_Parameter.MinSat = 6; |
155 | GPS_Parameter.StickThreshold = 8; |
155 | GPS_Parameter.StickThreshold = 8; |
156 | GPS_Parameter.WindCorrection = 0.0; |
156 | GPS_Parameter.WindCorrection = 0.0; |
157 | GPS_Parameter.OperatingRadius = 0; // forces the aircraft to fly to home positon |
157 | GPS_Parameter.OperatingRadius = 0; // forces the aircraft to fly to home positon |
158 | 158 | ||
159 | } |
159 | } |
160 | else |
160 | else |
161 | { |
161 | { |
162 | // update parameter from FC |
162 | // update parameter from FC |
163 | if(StopNavigation) GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
163 | if(StopNavigation) GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
164 | else |
164 | else |
165 | { |
165 | { |
166 | if(Parameter.NaviGpsModeControl < 50) |
166 | if(Parameter.NaviGpsModeControl < 50) |
167 | { |
167 | { |
168 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
168 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_FREE; |
169 | NCFlags &= ~(NC_FLAG_PH | NC_FLAG_CH); |
169 | NCFlags &= ~(NC_FLAG_PH | NC_FLAG_CH); |
170 | NCFlags |= NC_FLAG_FREE; |
170 | NCFlags |= NC_FLAG_FREE; |
171 | } |
171 | } |
172 | else if(Parameter.NaviGpsModeControl < 180) |
172 | else if(Parameter.NaviGpsModeControl < 180) |
173 | { |
173 | { |
174 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_AID; |
174 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_AID; |
175 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_CH); |
175 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_CH); |
176 | NCFlags |= NC_FLAG_PH; |
176 | NCFlags |= NC_FLAG_PH; |
177 | } |
177 | } |
178 | else |
178 | else |
179 | { |
179 | { |
180 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
180 | GPS_Parameter.FlightMode = GPS_FLIGHT_MODE_WAYPOINT; |
181 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_PH); |
181 | NCFlags &= ~(NC_FLAG_FREE | NC_FLAG_PH); |
182 | NCFlags |= NC_FLAG_CH; |
182 | NCFlags |= NC_FLAG_CH; |
183 | } |
183 | } |
184 | } |
184 | } |
185 | GPS_Parameter.Gain = (float)Parameter.NaviGpsGain; |
185 | GPS_Parameter.Gain = (float)Parameter.NaviGpsGain; |
186 | GPS_Parameter.P = (float)Parameter.NaviGpsP; |
186 | GPS_Parameter.P = (float)Parameter.NaviGpsP; |
187 | GPS_Parameter.I = (float)Parameter.NaviGpsI; |
187 | GPS_Parameter.I = (float)Parameter.NaviGpsI; |
188 | GPS_Parameter.D = (float)Parameter.NaviGpsD; |
188 | GPS_Parameter.D = (float)Parameter.NaviGpsD; |
189 | GPS_Parameter.A = (float)Parameter.NaviGpsD; |
189 | GPS_Parameter.A = (float)Parameter.NaviGpsD; |
190 | GPS_Parameter.ACC = (float)Parameter.NaviGpsACC; |
190 | GPS_Parameter.ACC = (float)Parameter.NaviGpsACC; |
191 | GPS_Parameter.P_Limit = (u32)Parameter.NaviGpsPLimit; |
191 | GPS_Parameter.P_Limit = (u32)Parameter.NaviGpsPLimit; |
192 | GPS_Parameter.I_Limit = (u32)Parameter.NaviGpsILimit; |
192 | GPS_Parameter.I_Limit = (u32)Parameter.NaviGpsILimit; |
193 | GPS_Parameter.D_Limit = (u32)Parameter.NaviGpsDLimit; |
193 | GPS_Parameter.D_Limit = (u32)Parameter.NaviGpsDLimit; |
194 | GPS_Parameter.PID_Limit = 2* (u32)Parameter.NaviAngleLimitation; |
194 | GPS_Parameter.PID_Limit = 2* (u32)Parameter.NaviAngleLimitation; |
195 | GPS_Parameter.BrakingDuration = (u32)Parameter.NaviPH_LoginTime; |
195 | GPS_Parameter.BrakingDuration = (u32)Parameter.NaviPH_LoginTime; |
196 | GPS_Parameter.SpeedCompensation = (float)Parameter.NaviSpeedCompensation; |
196 | GPS_Parameter.SpeedCompensation = (float)Parameter.NaviSpeedCompensation; |
197 | GPS_Parameter.MinSat = (u8)Parameter.NaviGpsMinSat; |
197 | GPS_Parameter.MinSat = (u8)Parameter.NaviGpsMinSat; |
198 | GPS_Parameter.StickThreshold = (s8)Parameter.NaviStickThreshold; |
198 | GPS_Parameter.StickThreshold = (s8)Parameter.NaviStickThreshold; |
199 | GPS_Parameter.WindCorrection = (float)Parameter.NaviWindCorrection; |
199 | GPS_Parameter.WindCorrection = (float)Parameter.NaviWindCorrection; |
200 | GPS_Parameter.OperatingRadius = (u32)Parameter.NaviOperatingRadius * 100; // conversion of m to cm |
200 | GPS_Parameter.OperatingRadius = (u32)Parameter.NaviOperatingRadius * 100; // conversion of m to cm |
201 | } |
201 | } |
202 | // FlightMode changed? |
202 | // FlightMode changed? |
203 | if(GPS_Parameter.FlightMode != FlightMode_Old) BeepTime = 100; // beep to indicate that mode has switched |
203 | if(GPS_Parameter.FlightMode != FlightMode_Old) BeepTime = 100; // beep to indicate that mode has switched |
204 | FlightMode_Old = GPS_Parameter.FlightMode; |
204 | FlightMode_Old = GPS_Parameter.FlightMode; |
205 | } |
205 | } |
206 | 206 | ||
207 | //------------------------------------------------------------- |
207 | //------------------------------------------------------------- |
208 | // This function defines a good GPS signal condition |
208 | // This function defines a good GPS signal condition |
209 | u8 GPS_IsSignalOK(void) |
209 | u8 GPS_IsSignalOK(void) |
210 | { |
210 | { |
211 | if( (GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.NumOfSats >= GPS_Parameter.MinSat)) return(1); |
211 | if( (GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.NumOfSats >= GPS_Parameter.MinSat)) return(1); |
212 | else return(0); |
212 | else return(0); |
213 | } |
213 | } |
214 | 214 | ||
215 | //------------------------------------------------------------ |
215 | //------------------------------------------------------------ |
216 | // Checks for manual control action |
216 | // Checks for manual control action |
217 | u8 GPS_IsManuallyControlled(void) |
217 | u8 GPS_IsManuallyControlled(void) |
218 | { |
218 | { |
219 | if( ( (abs(FC.StickNick) > GPS_Parameter.StickThreshold) || (abs(FC.StickRoll) > GPS_Parameter.StickThreshold)) && (GPS_Parameter.StickThreshold > 0)) return 1; |
219 | if( ( (abs(FC.StickNick) > GPS_Parameter.StickThreshold) || (abs(FC.StickRoll) > GPS_Parameter.StickThreshold)) && (GPS_Parameter.StickThreshold > 0)) return 1; |
220 | else return 0; |
220 | else return 0; |
221 | } |
221 | } |
222 | 222 | ||
223 | //------------------------------------------------------------ |
223 | //------------------------------------------------------------ |
224 | // copy GPS position from source position to target position |
224 | // copy GPS position from source position to target position |
225 | u8 GPS_CopyPosition(GPS_Pos_t * pGPSPosSrc, GPS_Pos_t* pGPSPosTgt) |
225 | u8 GPS_CopyPosition(GPS_Pos_t * pGPSPosSrc, GPS_Pos_t* pGPSPosTgt) |
226 | { |
226 | { |
227 | u8 retval = 0; |
227 | u8 retval = 0; |
228 | if((pGPSPosSrc == NULL) || (pGPSPosTgt == NULL)) return(retval); // bad pointer |
228 | if((pGPSPosSrc == NULL) || (pGPSPosTgt == NULL)) return(retval); // bad pointer |
229 | // copy only valid positions |
229 | // copy only valid positions |
230 | if(pGPSPosSrc->Status != INVALID) |
230 | if(pGPSPosSrc->Status != INVALID) |
231 | { |
231 | { |
232 | // if the source GPS position is not invalid |
232 | // if the source GPS position is not invalid |
233 | pGPSPosTgt->Longitude = pGPSPosSrc->Longitude; |
233 | pGPSPosTgt->Longitude = pGPSPosSrc->Longitude; |
234 | pGPSPosTgt->Latitude = pGPSPosSrc->Latitude; |
234 | pGPSPosTgt->Latitude = pGPSPosSrc->Latitude; |
235 | pGPSPosTgt->Altitude = pGPSPosSrc->Altitude; |
235 | pGPSPosTgt->Altitude = pGPSPosSrc->Altitude; |
236 | pGPSPosTgt->Status = NEWDATA; // mark data in target position as new |
236 | pGPSPosTgt->Status = NEWDATA; // mark data in target position as new |
237 | retval = 1; |
237 | retval = 1; |
238 | } |
238 | } |
239 | return(retval); |
239 | return(retval); |
240 | } |
240 | } |
241 | 241 | ||
242 | //------------------------------------------------------------ |
242 | //------------------------------------------------------------ |
243 | // clear position data |
243 | // clear position data |
244 | u8 GPS_ClearPosition(GPS_Pos_t * pGPSPos) |
244 | u8 GPS_ClearPosition(GPS_Pos_t * pGPSPos) |
245 | { |
245 | { |
246 | u8 retval = FALSE; |
246 | u8 retval = FALSE; |
247 | if(pGPSPos == NULL) return(retval); // bad pointer |
247 | if(pGPSPos == NULL) return(retval); // bad pointer |
248 | else |
248 | else |
249 | { |
249 | { |
250 | pGPSPos->Longitude = 0; |
250 | pGPSPos->Longitude = 0; |
251 | pGPSPos->Latitude = 0; |
251 | pGPSPos->Latitude = 0; |
252 | pGPSPos->Altitude = 0; |
252 | pGPSPos->Altitude = 0; |
253 | pGPSPos->Status = INVALID; |
253 | pGPSPos->Status = INVALID; |
254 | retval = TRUE; |
254 | retval = TRUE; |
255 | } |
255 | } |
256 | return (retval); |
256 | return (retval); |
257 | } |
257 | } |
258 | 258 | ||
259 | 259 | ||
260 | //------------------------------------------------------------ |
260 | //------------------------------------------------------------ |
261 | void GPS_Neutral(void) |
261 | void GPS_Neutral(void) |
262 | { |
262 | { |
263 | GPS_Stick.Nick = 0; |
263 | GPS_Stick.Nick = 0; |
264 | GPS_Stick.Roll = 0; |
264 | GPS_Stick.Roll = 0; |
265 | GPS_Stick.Yaw = 0; |
265 | GPS_Stick.Yaw = 0; |
266 | } |
266 | } |
267 | 267 | ||
268 | //------------------------------------------------------------ |
268 | //------------------------------------------------------------ |
269 | void GPS_Init(void) |
269 | void GPS_Init(void) |
270 | { |
270 | { |
271 | SerialPutString("\r\n GPS init..."); |
271 | SerialPutString("\r\n GPS init..."); |
272 | UBX_Init(); |
272 | UBX_Init(); |
273 | GPS_Neutral(); |
273 | GPS_Neutral(); |
274 | GPS_ClearPosition(&GPS_HoldPosition); |
274 | GPS_ClearPosition(&GPS_HoldPosition); |
275 | GPS_ClearPosition(&GPS_HomePosition); |
275 | GPS_ClearPosition(&GPS_HomePosition); |
276 | GPS_pTargetPosition = NULL; |
276 | GPS_pTargetPosition = NULL; |
277 | WPList_Init(); |
277 | WPList_Init(); |
278 | GPS_pWaypoint = WPList_Begin(); |
278 | GPS_pWaypoint = WPList_Begin(); |
279 | GPS_UpdateParameter(); |
279 | GPS_UpdateParameter(); |
280 | SerialPutString("ok"); |
280 | SerialPutString("ok"); |
281 | } |
281 | } |
282 | 282 | ||
283 | //------------------------------------------------------------ |
283 | //------------------------------------------------------------ |
284 | // calculate the bearing to target position from its deviation |
284 | // calculate the bearing to target position from its deviation |
285 | s32 DirectionToTarget_N_E(float northdev, float eastdev) |
285 | s32 DirectionToTarget_N_E(float northdev, float eastdev) |
286 | { |
286 | { |
287 | s32 bearing; |
287 | s32 bearing; |
288 | bearing = (s32)(atan2(northdev, eastdev) / M_PI_180); |
288 | bearing = (s32)(atan2(northdev, eastdev) / M_PI_180); |
289 | bearing = (270L - bearing)%360L; |
289 | bearing = (270L - bearing)%360L; |
290 | return(bearing); |
290 | return(bearing); |
291 | } |
291 | } |
292 | 292 | ||
293 | 293 | ||
294 | //------------------------------------------------------------ |
294 | //------------------------------------------------------------ |
295 | // Rescale xy-vector length if length limit is violated |
295 | // Rescale xy-vector length if length limit is violated |
296 | void GPS_LimitXY(s32 *x, s32 *y, u32 limit) |
296 | void GPS_LimitXY(s32 *x, s32 *y, u32 limit) |
297 | { |
297 | { |
298 | u32 dist; |
298 | double dist; |
- | 299 | ||
299 | dist = (u32)hypot(*x,*y); // the length of the vector |
300 | dist = hypot(*x,*y); // the length of the vector |
300 | if (dist == 0) |
- | |
301 | { |
- | |
302 | *x = 0; |
- | |
303 | *y = 0; |
- | |
304 | } |
- | |
305 | else if (dist > limit) |
301 | if ((u32)dist > limit) |
306 | // if vector length is larger than the given limit |
302 | // if vector length is larger than the given limit |
307 | { // scale vector compontents so that the length is cut off to limit |
303 | { // scale vector compontents so that the length is cut off to limit |
308 | *x = (*x * limit) / dist; |
304 | *x = (s32)(((double)(*x) * limit) / dist); |
309 | *y = (*y * limit) / dist; |
305 | *y = (s32)(((double)(*y) * limit) / dist); |
310 | } |
306 | } |
311 | } |
307 | } |
312 | 308 | ||
313 | //------------------------------------------------------------ |
309 | //------------------------------------------------------------ |
314 | // transform the integer deg into float radians |
310 | // transform the integer deg into float radians |
315 | inline double RadiansFromGPS(s32 deg) |
311 | inline double RadiansFromGPS(s32 deg) |
316 | { |
312 | { |
317 | return ((double)deg * 1e-7f * M_PI_180); // 1E-7 because deg is the value in ° * 1E7 |
313 | return ((double)deg * 1e-7f * M_PI_180); // 1E-7 because deg is the value in ° * 1E7 |
318 | } |
314 | } |
319 | 315 | ||
320 | //------------------------------------------------------------ |
316 | //------------------------------------------------------------ |
321 | // transform the integer deg into float deg |
317 | // transform the integer deg into float deg |
322 | inline double DegFromGPS(s32 deg) |
318 | inline double DegFromGPS(s32 deg) |
323 | { |
319 | { |
324 | return ((double)deg * 1e-7f); // 1E-7 because deg is the value in ° * 1E7 |
320 | return ((double)deg * 1e-7f); // 1E-7 because deg is the value in ° * 1E7 |
325 | } |
321 | } |
326 | 322 | ||
327 | //------------------------------------------------------------ |
323 | //------------------------------------------------------------ |
328 | // calculate the deviation from the current position to the target position |
324 | // calculate the deviation from the current position to the target position |
329 | u8 GPS_CalculateDeviation(GPS_Pos_t * pCurrentPos, GPS_Pos_t * pTargetPos, GPS_Deviation_t* pDeviationFromTarget) |
325 | u8 GPS_CalculateDeviation(GPS_Pos_t * pCurrentPos, GPS_Pos_t * pTargetPos, GPS_Deviation_t* pDeviationFromTarget) |
330 | { |
326 | { |
331 | double temp1, temp2; |
327 | double temp1, temp2; |
332 | // if given pointer is NULL |
328 | // if given pointer is NULL |
333 | if((pCurrentPos == NULL) || (pTargetPos == NULL)) goto baddata; |
329 | if((pCurrentPos == NULL) || (pTargetPos == NULL)) goto baddata; |
334 | // if positions are invalid |
330 | // if positions are invalid |
335 | if((pCurrentPos->Status == INVALID) || (pTargetPos->Status == INVALID)) goto baddata; |
331 | if((pCurrentPos->Status == INVALID) || (pTargetPos->Status == INVALID)) goto baddata; |
336 | 332 | ||
337 | // The deviation from the current to the target position along north and east direction is |
333 | // The deviation from the current to the target position along north and east direction is |
338 | // simple the lat/lon difference. To convert that angular deviation into an |
334 | // simple the lat/lon difference. To convert that angular deviation into an |
339 | // arc length the spherical projection has to be considered. |
335 | // arc length the spherical projection has to be considered. |
340 | // The mean earth radius is 6371km. Therfore the arc length per latitude degree |
336 | // The mean earth radius is 6371km. Therfore the arc length per latitude degree |
341 | // is always 6371km * 2 * Pi / 360deg = 111.2 km/deg. |
337 | // is always 6371km * 2 * Pi / 360deg = 111.2 km/deg. |
342 | // The arc length per longitude degree depends on the correspondig latitude and |
338 | // The arc length per longitude degree depends on the correspondig latitude and |
343 | // is 111.2km * cos(latitude). |
339 | // is 111.2km * cos(latitude). |
344 | 340 | ||
345 | // calculate the shortest longitude deviation from target |
341 | // calculate the shortest longitude deviation from target |
346 | temp1 = DegFromGPS(pCurrentPos->Longitude) - DegFromGPS(pTargetPos->Longitude); |
342 | temp1 = DegFromGPS(pCurrentPos->Longitude) - DegFromGPS(pTargetPos->Longitude); |
347 | // outside an angular difference of -180 deg ... +180 deg its shorter to go the other way around |
343 | // outside an angular difference of -180 deg ... +180 deg its shorter to go the other way around |
348 | // In our application we wont fly more than 20.000 km but along the date line this is important. |
344 | // In our application we wont fly more than 20.000 km but along the date line this is important. |
349 | if(temp1 > 180.0f) temp1 -= 360.0f; |
345 | if(temp1 > 180.0f) temp1 -= 360.0f; |
350 | else if (temp1 < -180.0f) temp1 += 360.0f; |
346 | else if (temp1 < -180.0f) temp1 += 360.0f; |
351 | temp1 *= cos((RadiansFromGPS(pTargetPos->Latitude) + RadiansFromGPS(pCurrentPos->Latitude))/2); |
347 | temp1 *= cos((RadiansFromGPS(pTargetPos->Latitude) + RadiansFromGPS(pCurrentPos->Latitude))/2); |
352 | // calculate latitude deviation from target |
348 | // calculate latitude deviation from target |
353 | // this is allways within -180 deg ... 180 deg |
349 | // this is allways within -180 deg ... 180 deg |
354 | temp2 = DegFromGPS(pCurrentPos->Latitude) - DegFromGPS(pTargetPos->Latitude); |
350 | temp2 = DegFromGPS(pCurrentPos->Latitude) - DegFromGPS(pTargetPos->Latitude); |
355 | // deviation from target position in cm |
351 | // deviation from target position in cm |
356 | // i.e. the distance to walk from the target in northern and eastern direction to reach the current position |
352 | // i.e. the distance to walk from the target in northern and eastern direction to reach the current position |
357 | 353 | ||
358 | pDeviationFromTarget->Status = INVALID; |
354 | pDeviationFromTarget->Status = INVALID; |
359 | pDeviationFromTarget->North = (s32)(11119492.7f * temp2); |
355 | pDeviationFromTarget->North = (s32)(11119492.7f * temp2); |
360 | pDeviationFromTarget->East = (s32)(11119492.7f * temp1); |
356 | pDeviationFromTarget->East = (s32)(11119492.7f * temp1); |
361 | // If the position deviation is small enough to neglect the earth curvature |
357 | // If the position deviation is small enough to neglect the earth curvature |
362 | // (this is for our application always fulfilled) the distance to target |
358 | // (this is for our application always fulfilled) the distance to target |
363 | // can be calculated by the pythagoras of north and east deviation. |
359 | // can be calculated by the pythagoras of north and east deviation. |
364 | pDeviationFromTarget->Distance = (u32)(11119492.7f * hypot(temp1, temp2)); |
360 | pDeviationFromTarget->Distance = (u32)(11119492.7f * hypot(temp1, temp2)); |
365 | if (pDeviationFromTarget->Distance == 0L) pDeviationFromTarget->Bearing = 0L; |
361 | if (pDeviationFromTarget->Distance == 0L) pDeviationFromTarget->Bearing = 0L; |
366 | else pDeviationFromTarget->Bearing = DirectionToTarget_N_E(temp2, temp1); |
362 | else pDeviationFromTarget->Bearing = DirectionToTarget_N_E(temp2, temp1); |
367 | pDeviationFromTarget->Status = NEWDATA; |
363 | pDeviationFromTarget->Status = NEWDATA; |
368 | return TRUE; |
364 | return TRUE; |
369 | 365 | ||
370 | baddata: |
366 | baddata: |
371 | pDeviationFromTarget->North = 0L; |
367 | pDeviationFromTarget->North = 0L; |
372 | pDeviationFromTarget->East = 0L; |
368 | pDeviationFromTarget->East = 0L; |
373 | pDeviationFromTarget->Distance = 0L; |
369 | pDeviationFromTarget->Distance = 0L; |
374 | pDeviationFromTarget->Bearing = 0L; |
370 | pDeviationFromTarget->Bearing = 0L; |
375 | pDeviationFromTarget->Status = INVALID; |
371 | pDeviationFromTarget->Status = INVALID; |
376 | return FALSE; |
372 | return FALSE; |
377 | } |
373 | } |
378 | 374 | ||
379 | //------------------------------------------------------------ |
375 | //------------------------------------------------------------ |
380 | void GPS_Navigation(void) |
376 | void GPS_Navigation(void) |
381 | { |
377 | { |
382 | static u32 beep_rythm; |
378 | static u32 beep_rythm; |
383 | static u32 GPSDataTimeout = 0; |
379 | static u32 GPSDataTimeout = 0; |
384 | 380 | ||
385 | // pointer to current target position |
381 | // pointer to current target position |
386 | static GPS_Pos_t * pTargetPositionOld = NULL; |
382 | static GPS_Pos_t * pTargetPositionOld = NULL; |
387 | static Waypoint_t* GPS_pWaypointOld = NULL; |
383 | static Waypoint_t* GPS_pWaypointOld = NULL; |
388 | 384 | ||
389 | static GPS_Pos_t RangedTargetPosition = {0,0,0, INVALID}; // the limited target position, this is derived from the target position with repect to the operating radius |
385 | static GPS_Pos_t RangedTargetPosition = {0,0,0, INVALID}; // the limited target position, this is derived from the target position with repect to the operating radius |
390 | static u32 OperatingRadiusOld = -1; |
386 | static u32 OperatingRadiusOld = -1; |
391 | static u32 WPTime = 0; |
387 | static u32 WPTime = 0; |
392 | 388 | ||
393 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
389 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
394 | //+ Check for new data from GPS-receiver |
390 | //+ Check for new data from GPS-receiver |
395 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
391 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
396 | switch(GPSData.Status) |
392 | switch(GPSData.Status) |
397 | { |
393 | { |
398 | case INVALID: // no gps data available |
394 | case INVALID: // no gps data available |
399 | // do nothing |
395 | // do nothing |
400 | GPS_Parameter.PID_Limit = 0; // disables PID output |
396 | GPS_Parameter.PID_Limit = 0; // disables PID output |
401 | break; |
397 | break; |
402 | 398 | ||
403 | case PROCESSED: // the current data have been allready processed |
399 | case PROCESSED: // the current data have been allready processed |
404 | // if no new data are available within the timeout switch to invalid state. |
400 | // if no new data are available within the timeout switch to invalid state. |
405 | if(CheckDelay(GPSDataTimeout)) GPSData.Status = INVALID; |
401 | if(CheckDelay(GPSDataTimeout)) GPSData.Status = INVALID; |
406 | // wait for new gps data |
402 | // wait for new gps data |
407 | break; |
403 | break; |
408 | 404 | ||
409 | case NEWDATA: // handle new gps data |
405 | case NEWDATA: // handle new gps data |
410 | 406 | ||
411 | // update GPS Parameter from FC-Data via SPI interface |
407 | // update GPS Parameter from FC-Data via SPI interface |
412 | GPS_UpdateParameter(); |
408 | GPS_UpdateParameter(); |
413 | 409 | ||
414 | // wait maximum of 3 times the normal data update time before data timemout |
410 | // wait maximum of 3 times the normal data update time before data timemout |
415 | GPSDataTimeout = SetDelay(3 * GPS_UPDATETIME_MS); |
411 | GPSDataTimeout = SetDelay(3 * GPS_UPDATETIME_MS); |
416 | beep_rythm++; |
412 | beep_rythm++; |
417 | 413 | ||
418 | // debug |
414 | // debug |
419 | DebugOut.Analog[21] = (s16)GPSData.Speed_North; |
415 | DebugOut.Analog[21] = (s16)GPSData.Speed_North; |
420 | DebugOut.Analog[22] = (s16)GPSData.Speed_East; |
416 | DebugOut.Analog[22] = (s16)GPSData.Speed_East; |
421 | DebugOut.Analog[31] = (s16)GPSData.NumOfSats; |
417 | DebugOut.Analog[31] = (s16)GPSData.NumOfSats; |
422 | 418 | ||
423 | // If GPS signal condition is sufficient for a reliable position measurement |
419 | // If GPS signal condition is sufficient for a reliable position measurement |
424 | if(GPS_IsSignalOK()) |
420 | if(GPS_IsSignalOK()) |
425 | { |
421 | { |
426 | // update home deviation info |
422 | // update home deviation info |
427 | GPS_CalculateDeviation(&(GPSData.Position), &GPS_HomePosition, &CurrentHomeDeviation); |
423 | GPS_CalculateDeviation(&(GPSData.Position), &GPS_HomePosition, &CurrentHomeDeviation); |
428 | 424 | ||
429 | // if the MK is starting or the home position is invalid then store the home position |
425 | // if the MK is starting or the home position is invalid then store the home position |
430 | if((FC.MKFlags & MKFLAG_START) || (GPS_HomePosition.Status == INVALID)) |
426 | if((FC.MKFlags & MKFLAG_START) || (GPS_HomePosition.Status == INVALID)) |
431 | { // try to update the home position from the current position |
427 | { // try to update the home position from the current position |
432 | if(GPS_CopyPosition(&(GPSData.Position), &GPS_HomePosition)) |
428 | if(GPS_CopyPosition(&(GPSData.Position), &GPS_HomePosition)) |
433 | { |
429 | { |
434 | BeepTime = 700; // beep on success |
430 | BeepTime = 700; // beep on success |
435 | GPS_CopyPosition(&GPS_HomePosition, &(NaviData.HomePosition)); |
431 | GPS_CopyPosition(&GPS_HomePosition, &(NaviData.HomePosition)); |
436 | } |
432 | } |
437 | GPS_pWaypoint = WPList_Begin(); // go to start of waypoint list, return NULL of the list is empty |
433 | GPS_pWaypoint = WPList_Begin(); // go to start of waypoint list, return NULL of the list is empty |
438 | } |
434 | } |
439 | 435 | ||
440 | /* The selected flight mode influences the target position pointer and therefore the behavior */ |
436 | /* The selected flight mode influences the target position pointer and therefore the behavior */ |
441 | 437 | ||
442 | // check for current flight mode and set the target pointer GPS_pTargetPosition respectively |
438 | // check for current flight mode and set the target pointer GPS_pTargetPosition respectively |
443 | switch(GPS_Parameter.FlightMode) |
439 | switch(GPS_Parameter.FlightMode) |
444 | { |
440 | { |
445 | // the GPS control is deactived |
441 | // the GPS control is deactived |
446 | case GPS_FLIGHT_MODE_FREE: |
442 | case GPS_FLIGHT_MODE_FREE: |
447 | 443 | ||
448 | GPS_Parameter.PID_Limit = 0; // disables PID output |
444 | GPS_Parameter.PID_Limit = 0; // disables PID output |
449 | // update hold position |
445 | // update hold position |
450 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
446 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
451 | // no target position |
447 | // no target position |
452 | GPS_pTargetPosition = NULL; |
448 | GPS_pTargetPosition = NULL; |
453 | GPS_TargetRadius = 0; |
449 | GPS_TargetRadius = 0; |
454 | break; |
450 | break; |
455 | 451 | ||
456 | // the GPS supports the position hold, if the pilot takes no action |
452 | // the GPS supports the position hold, if the pilot takes no action |
457 | case GPS_FLIGHT_MODE_AID: |
453 | case GPS_FLIGHT_MODE_AID: |
458 | 454 | ||
459 | // reset WPList to begin |
455 | // reset WPList to begin |
460 | GPS_pWaypoint = WPList_Begin(); |
456 | GPS_pWaypoint = WPList_Begin(); |
461 | 457 | ||
462 | if(GPS_IsManuallyControlled()) |
458 | if(GPS_IsManuallyControlled()) |
463 | { |
459 | { |
464 | GPS_Parameter.PID_Limit = 0; // disables PID output, as long as the manual conrol is active |
460 | GPS_Parameter.PID_Limit = 0; // disables PID output, as long as the manual conrol is active |
465 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
461 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
466 | GPS_pTargetPosition = NULL; |
462 | GPS_pTargetPosition = NULL; |
467 | GPS_TargetRadius = 0; |
463 | GPS_TargetRadius = 0; |
468 | } |
464 | } |
469 | else |
465 | else |
470 | { |
466 | { |
471 | GPS_pTargetPosition = &GPS_HoldPosition; |
467 | GPS_pTargetPosition = &GPS_HoldPosition; |
472 | GPS_TargetRadius = 100; // 1 meter |
468 | GPS_TargetRadius = 100; // 1 meter |
473 | } |
469 | } |
474 | break; |
470 | break; |
475 | 471 | ||
476 | // the GPS control is directed to a target position |
472 | // the GPS control is directed to a target position |
477 | // given by a waypoint or by the home position |
473 | // given by a waypoint or by the home position |
478 | case GPS_FLIGHT_MODE_WAYPOINT: |
474 | case GPS_FLIGHT_MODE_WAYPOINT: |
479 | 475 | ||
480 | if(GPS_IsManuallyControlled()) // the human pilot takes the action |
476 | if(GPS_IsManuallyControlled()) // the human pilot takes the action |
481 | { |
477 | { |
482 | GPS_Parameter.PID_Limit = 0; // disables PID output, as long as the manual conrol is active |
478 | GPS_Parameter.PID_Limit = 0; // disables PID output, as long as the manual conrol is active |
483 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); // update hold position |
479 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); // update hold position |
484 | GPS_pTargetPosition = NULL; // set target position invalid |
480 | GPS_pTargetPosition = NULL; // set target position invalid |
485 | GPS_TargetRadius = 0; |
481 | GPS_TargetRadius = 0; |
486 | } |
482 | } |
487 | else // no manual control -> gps position hold active |
483 | else // no manual control -> gps position hold active |
488 | { |
484 | { |
489 | // waypoint trigger logic |
485 | // waypoint trigger logic |
490 | if(GPS_pWaypoint != NULL) // waypoint exist |
486 | if(GPS_pWaypoint != NULL) // waypoint exist |
491 | { |
487 | { |
492 | if(GPS_pWaypoint->Position.Status == INVALID) // should never happen |
488 | if(GPS_pWaypoint->Position.Status == INVALID) // should never happen |
493 | { |
489 | { |
494 | GPS_pWaypoint = WPList_Next(); // goto to next WP |
490 | GPS_pWaypoint = WPList_Next(); // goto to next WP |
495 | BeepTime = 255; |
491 | BeepTime = 255; |
496 | } |
492 | } |
497 | else // waypoint position is valid |
493 | else // waypoint position is valid |
498 | { |
494 | { |
499 | // check if the pointer to the waypoint has been changed or the data have been updated |
495 | // check if the pointer to the waypoint has been changed or the data have been updated |
500 | if((GPS_pWaypoint != GPS_pWaypointOld) || (GPS_pWaypoint->Position.Status == NEWDATA)) |
496 | if((GPS_pWaypoint != GPS_pWaypointOld) || (GPS_pWaypoint->Position.Status == NEWDATA)) |
501 | { |
497 | { |
502 | GPS_pWaypointOld = GPS_pWaypoint; |
498 | GPS_pWaypointOld = GPS_pWaypoint; |
503 | } |
499 | } |
504 | // if WP has been reached once, wait hold time before trigger to next one |
500 | // if WP has been reached once, wait hold time before trigger to next one |
505 | if(NCFlags & NC_FLAG_TARGET_REACHED) |
501 | if(NCFlags & NC_FLAG_TARGET_REACHED) |
506 | { |
502 | { |
507 | /* ToDo: Adjust GPS_pWaypoint->Heading, GPS_pWaypoint->Event handling */ |
503 | /* ToDo: Adjust GPS_pWaypoint->Heading, GPS_pWaypoint->Event handling */ |
508 | if(CheckDelay(WPTime)) |
504 | if(CheckDelay(WPTime)) |
509 | { |
505 | { |
510 | GPS_pWaypoint = WPList_Next(); // goto to next waypoint, return NULL if end of list has been reached |
506 | GPS_pWaypoint = WPList_Next(); // goto to next waypoint, return NULL if end of list has been reached |
511 | } |
507 | } |
512 | } // EOF if(WPArrived) |
508 | } // EOF if(WPArrived) |
513 | else |
509 | else |
514 | { |
510 | { |
515 | WPTime = SetDelay(GPS_pWaypoint->HoldTime * 1000); // set hold time stamp |
511 | WPTime = SetDelay(GPS_pWaypoint->HoldTime * 1000); // set hold time stamp |
516 | } |
512 | } |
517 | } |
513 | } |
518 | } // EOF waypoint trigger logic |
514 | } // EOF waypoint trigger logic |
519 | 515 | ||
520 | if(GPS_pWaypoint != NULL) // Waypoint exist |
516 | if(GPS_pWaypoint != NULL) // Waypoint exist |
521 | { |
517 | { |
522 | // update the hold position |
518 | // update the hold position |
523 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
519 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
524 | GPS_pTargetPosition = &(GPS_pWaypoint->Position); |
520 | GPS_pTargetPosition = &(GPS_pWaypoint->Position); |
525 | GPS_TargetRadius = (u32)(GPS_pWaypoint->ToleranceRadius) * 100L; |
521 | GPS_TargetRadius = (u32)(GPS_pWaypoint->ToleranceRadius) * 100L; |
526 | 522 | ||
527 | } |
523 | } |
528 | else // no waypoint info available, i.e. the WPList is empty or the end of the list has been reached |
524 | else // no waypoint info available, i.e. the WPList is empty or the end of the list has been reached |
529 | { |
525 | { |
530 | // fly back to home postion |
526 | // fly back to home postion |
531 | if(GPS_HomePosition.Status == INVALID) |
527 | if(GPS_HomePosition.Status == INVALID) |
532 | { |
528 | { |
533 | GPS_pTargetPosition = &GPS_HoldPosition; // fall back to hold mode if home position is not available |
529 | GPS_pTargetPosition = &GPS_HoldPosition; // fall back to hold mode if home position is not available |
534 | GPS_TargetRadius = 100; |
530 | GPS_TargetRadius = 100; |
535 | BeepTime = 255; // beep to indicate missin home position |
531 | BeepTime = 255; // beep to indicate missin home position |
536 | } |
532 | } |
537 | else // the home position is valid |
533 | else // the home position is valid |
538 | { |
534 | { |
539 | // update the hold position |
535 | // update the hold position |
540 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
536 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
541 | // set target to home position |
537 | // set target to home position |
542 | GPS_pTargetPosition = &GPS_HomePosition; |
538 | GPS_pTargetPosition = &GPS_HomePosition; |
543 | GPS_TargetRadius = 100; |
539 | GPS_TargetRadius = 100; |
544 | } |
540 | } |
545 | } |
541 | } |
546 | } // EOF no manual control |
542 | } // EOF no manual control |
547 | break; |
543 | break; |
548 | 544 | ||
549 | case GPS_FLIGHT_MODE_UNDEF: |
545 | case GPS_FLIGHT_MODE_UNDEF: |
550 | default: |
546 | default: |
551 | GPS_Parameter.PID_Limit = 0; // disables PID output |
547 | GPS_Parameter.PID_Limit = 0; // disables PID output |
552 | // update hold position |
548 | // update hold position |
553 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
549 | GPS_CopyPosition(&(GPSData.Position), &GPS_HoldPosition); |
554 | // no target position |
550 | // no target position |
555 | GPS_pTargetPosition = NULL; |
551 | GPS_pTargetPosition = NULL; |
556 | GPS_TargetRadius = 0; |
552 | GPS_TargetRadius = 0; |
557 | break; |
553 | break; |
558 | 554 | ||
559 | }// EOF GPS Mode Handling |
555 | }// EOF GPS Mode Handling |
560 | 556 | ||
561 | 557 | ||
562 | /* Calculation of range target based on the real target */ |
558 | /* Calculation of range target based on the real target */ |
563 | 559 | ||
564 | // if no target position exist clear the ranged target position |
560 | // if no target position exist clear the ranged target position |
565 | if(GPS_pTargetPosition == NULL) GPS_ClearPosition(&RangedTargetPosition); |
561 | if(GPS_pTargetPosition == NULL) GPS_ClearPosition(&RangedTargetPosition); |
566 | else |
562 | else |
567 | { // if the target position has been changed or the value has been updated or the OperatingRadius has changed |
563 | { // if the target position has been changed or the value has been updated or the OperatingRadius has changed |
568 | if((GPS_pTargetPosition != pTargetPositionOld) || (GPS_pTargetPosition->Status == NEWDATA) || (GPS_Parameter.OperatingRadius != OperatingRadiusOld) ) |
564 | if((GPS_pTargetPosition != pTargetPositionOld) || (GPS_pTargetPosition->Status == NEWDATA) || (GPS_Parameter.OperatingRadius != OperatingRadiusOld) ) |
569 | { |
565 | { |
570 | BeepTime = 255; // beep to indicate setting of a new target position |
566 | BeepTime = 255; // beep to indicate setting of a new target position |
571 | NCFlags &= ~NC_FLAG_TARGET_REACHED; // clear target reached flag |
567 | NCFlags &= ~NC_FLAG_TARGET_REACHED; // clear target reached flag |
572 | // calculate deviation of new target position from home position |
568 | // calculate deviation of new target position from home position |
573 | if(GPS_CalculateDeviation(GPS_pTargetPosition, &GPS_HomePosition, &TargetHomeDeviation)) |
569 | if(GPS_CalculateDeviation(GPS_pTargetPosition, &GPS_HomePosition, &TargetHomeDeviation)) |
574 | { |
570 | { |
575 | // check distance from home position |
571 | // check distance from home position |
576 | if(TargetHomeDeviation.Distance > GPS_Parameter.OperatingRadius) |
572 | if(TargetHomeDeviation.Distance > GPS_Parameter.OperatingRadius) |
577 | { |
573 | { |
578 | //calculate ranged target position to be within the operation radius area |
574 | //calculate ranged target position to be within the operation radius area |
579 | NCFlags |= NC_FLAG_RANGE_LIMIT; |
575 | NCFlags |= NC_FLAG_RANGE_LIMIT; |
580 | 576 | ||
581 | TargetHomeDeviation.North *= GPS_Parameter.OperatingRadius; |
577 | TargetHomeDeviation.North *= GPS_Parameter.OperatingRadius; |
582 | TargetHomeDeviation.North /= TargetHomeDeviation.Distance; |
578 | TargetHomeDeviation.North /= TargetHomeDeviation.Distance; |
583 | TargetHomeDeviation.East *= GPS_Parameter.OperatingRadius; |
579 | TargetHomeDeviation.East *= GPS_Parameter.OperatingRadius; |
584 | TargetHomeDeviation.East /= TargetHomeDeviation.Distance; |
580 | TargetHomeDeviation.East /= TargetHomeDeviation.Distance; |
585 | TargetHomeDeviation.Distance = GPS_Parameter.OperatingRadius; |
581 | TargetHomeDeviation.Distance = GPS_Parameter.OperatingRadius; |
586 | 582 | ||
587 | RangedTargetPosition.Status = INVALID; |
583 | RangedTargetPosition.Status = INVALID; |
588 | RangedTargetPosition.Latitude = GPS_HomePosition.Latitude; |
584 | RangedTargetPosition.Latitude = GPS_HomePosition.Latitude; |
589 | RangedTargetPosition.Latitude += (s32)((float)TargetHomeDeviation.North / 1.11194927f); |
585 | RangedTargetPosition.Latitude += (s32)((float)TargetHomeDeviation.North / 1.11194927f); |
590 | RangedTargetPosition.Longitude = GPS_HomePosition.Longitude; |
586 | RangedTargetPosition.Longitude = GPS_HomePosition.Longitude; |
591 | RangedTargetPosition.Longitude += (s32)((float)TargetHomeDeviation.East / (1.11194927f * cos(RadiansFromGPS(GPS_HomePosition.Latitude))) ); |
587 | RangedTargetPosition.Longitude += (s32)((float)TargetHomeDeviation.East / (1.11194927f * cos(RadiansFromGPS(GPS_HomePosition.Latitude))) ); |
592 | RangedTargetPosition.Altitude = GPS_pTargetPosition->Altitude; |
588 | RangedTargetPosition.Altitude = GPS_pTargetPosition->Altitude; |
593 | RangedTargetPosition.Status = NEWDATA; |
589 | RangedTargetPosition.Status = NEWDATA; |
594 | } |
590 | } |
595 | else |
591 | else |
596 | { // the target is located within the operation radius area |
592 | { // the target is located within the operation radius area |
597 | // simple copy the loaction to the ranged target position |
593 | // simple copy the loaction to the ranged target position |
598 | GPS_CopyPosition(GPS_pTargetPosition, &RangedTargetPosition); |
594 | GPS_CopyPosition(GPS_pTargetPosition, &RangedTargetPosition); |
599 | NCFlags &= ~NC_FLAG_RANGE_LIMIT; |
595 | NCFlags &= ~NC_FLAG_RANGE_LIMIT; |
600 | } |
596 | } |
601 | } |
597 | } |
602 | else |
598 | else |
603 | { // deviation could not be determined |
599 | { // deviation could not be determined |
604 | GPS_ClearPosition(&RangedTargetPosition); |
600 | GPS_ClearPosition(&RangedTargetPosition); |
605 | } |
601 | } |
606 | GPS_pTargetPosition->Status = PROCESSED; // mark current target as processed! |
602 | GPS_pTargetPosition->Status = PROCESSED; // mark current target as processed! |
607 | } |
603 | } |
608 | } |
604 | } |
609 | OperatingRadiusOld = GPS_Parameter.OperatingRadius; |
605 | OperatingRadiusOld = GPS_Parameter.OperatingRadius; |
610 | // remember last target position pointer |
606 | // remember last target position pointer |
611 | pTargetPositionOld = GPS_pTargetPosition; |
607 | pTargetPositionOld = GPS_pTargetPosition; |
612 | 608 | ||
613 | /* Calculate position deviation from ranged target */ |
609 | /* Calculate position deviation from ranged target */ |
614 | 610 | ||
615 | // calculate deviation of current position to ranged target position in cm |
611 | // calculate deviation of current position to ranged target position in cm |
616 | if(GPS_CalculateDeviation(&(GPSData.Position), &RangedTargetPosition, &CurrentTargetDeviation)) |
612 | if(GPS_CalculateDeviation(&(GPSData.Position), &RangedTargetPosition, &CurrentTargetDeviation)) |
617 | { // set target reached flag of we once reached the target point |
613 | { // set target reached flag of we once reached the target point |
618 | if(!(NCFlags & NC_FLAG_TARGET_REACHED) && (CurrentTargetDeviation.Distance < GPS_TargetRadius)) |
614 | if(!(NCFlags & NC_FLAG_TARGET_REACHED) && (CurrentTargetDeviation.Distance < GPS_TargetRadius)) |
619 | { |
615 | { |
620 | NCFlags |= NC_FLAG_TARGET_REACHED; // set target reached flag |
616 | NCFlags |= NC_FLAG_TARGET_REACHED; // set target reached flag |
621 | } |
617 | } |
622 | // implement your control code here based |
618 | // implement your control code here based |
623 | // in the info available in the CurrentTargetDeviation, GPSData and FromFlightCtrl.GyroHeading |
619 | // in the info available in the CurrentTargetDeviation, GPSData and FromFlightCtrl.GyroHeading |
624 | GPS_Stick.Nick = 0; |
620 | GPS_Stick.Nick = 0; |
625 | GPS_Stick.Roll = 0; |
621 | GPS_Stick.Roll = 0; |
626 | GPS_Stick.Yaw = 0; |
622 | GPS_Stick.Yaw = 0; |
627 | } |
623 | } |
628 | else // deviation could not be calculated |
624 | else // deviation could not be calculated |
629 | { // do nothing on gps sticks! |
625 | { // do nothing on gps sticks! |
630 | GPS_Neutral(); |
626 | GPS_Neutral(); |
631 | } |
627 | } |
632 | 628 | ||
633 | }// eof if GPSSignal is OK |
629 | }// eof if GPSSignal is OK |
634 | else // GPSSignal not OK |
630 | else // GPSSignal not OK |
635 | { |
631 | { |
636 | GPS_Neutral(); |
632 | GPS_Neutral(); |
637 | // beep if signal is not sufficient |
633 | // beep if signal is not sufficient |
638 | if(GPS_Parameter.FlightMode != GPS_FLIGHT_MODE_FREE) |
634 | if(GPS_Parameter.FlightMode != GPS_FLIGHT_MODE_FREE) |
639 | { |
635 | { |
640 | if(!(GPSData.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100; |
636 | if(!(GPSData.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100; |
641 | else if (GPSData.NumOfSats < GPS_Parameter.MinSat && !(beep_rythm % 5)) BeepTime = 10; |
637 | else if (GPSData.NumOfSats < GPS_Parameter.MinSat && !(beep_rythm % 5)) BeepTime = 10; |
642 | } |
638 | } |
643 | } |
639 | } |
644 | GPSData.Status = PROCESSED; // mark as processed |
640 | GPSData.Status = PROCESSED; // mark as processed |
645 | break; |
641 | break; |
646 | } |
642 | } |
647 | 643 | ||
648 | DebugOut.Analog[6] = NCFlags; |
644 | DebugOut.Analog[6] = NCFlags; |
649 | DebugOut.Analog[27] = (s16)CurrentTargetDeviation.North; |
645 | DebugOut.Analog[27] = (s16)CurrentTargetDeviation.North; |
650 | DebugOut.Analog[28] = (s16)CurrentTargetDeviation.East; |
646 | DebugOut.Analog[28] = (s16)CurrentTargetDeviation.East; |
651 | DebugOut.Analog[29] = GPS_Stick.Nick; |
647 | DebugOut.Analog[29] = GPS_Stick.Nick; |
652 | DebugOut.Analog[30] = GPS_Stick.Roll; |
648 | DebugOut.Analog[30] = GPS_Stick.Roll; |
653 | 649 | ||
654 | // update navi data, send back to ground station |
650 | // update navi data, send back to ground station |
655 | GPS_CopyPosition(&(GPSData.Position), &(NaviData.CurrentPosition)); |
651 | GPS_CopyPosition(&(GPSData.Position), &(NaviData.CurrentPosition)); |
656 | GPS_CopyPosition(&RangedTargetPosition, &(NaviData.TargetPosition)); |
652 | GPS_CopyPosition(&RangedTargetPosition, &(NaviData.TargetPosition)); |
657 | GPS_CopyPosition(&GPS_HomePosition, &(NaviData.HomePosition)); |
653 | GPS_CopyPosition(&GPS_HomePosition, &(NaviData.HomePosition)); |
658 | NaviData.SatsInUse = GPSData.NumOfSats; |
654 | NaviData.SatsInUse = GPSData.NumOfSats; |
659 | NaviData.TargetPositionDeviation.Distance = (u16)CurrentTargetDeviation.Distance/10; // dm |
655 | NaviData.TargetPositionDeviation.Distance = (u16)CurrentTargetDeviation.Distance/10; // dm |
660 | NaviData.TargetPositionDeviation.Bearing = (s16)CurrentTargetDeviation.Bearing; |
656 | NaviData.TargetPositionDeviation.Bearing = (s16)CurrentTargetDeviation.Bearing; |
661 | NaviData.HomePositionDeviation.Distance = (u16)CurrentHomeDeviation.Distance/10; // dm |
657 | NaviData.HomePositionDeviation.Distance = (u16)CurrentHomeDeviation.Distance/10; // dm |
662 | NaviData.HomePositionDeviation.Bearing = (s16)CurrentHomeDeviation.Bearing; |
658 | NaviData.HomePositionDeviation.Bearing = (s16)CurrentHomeDeviation.Bearing; |
663 | NaviData.UBat = FC.UBat; |
659 | NaviData.UBat = FC.UBat; |
664 | NaviData.GroundSpeed = (u16)GPSData.Speed_Ground; |
660 | NaviData.GroundSpeed = (u16)GPSData.Speed_Ground; |
665 | NaviData.Heading = (s16)(GPSData.Heading/100000L); |
661 | NaviData.Heading = (s16)(GPSData.Heading/100000L); |
666 | NaviData.CompassHeading = (s16)FromFlightCtrl.GyroHeading/10; // in deg |
662 | NaviData.CompassHeading = (s16)FromFlightCtrl.GyroHeading/10; // in deg |
667 | NaviData.AngleNick = FromFlightCtrl.AngleNick / 10; // in deg |
663 | NaviData.AngleNick = FromFlightCtrl.AngleNick / 10; // in deg |
668 | NaviData.AngleRoll = FromFlightCtrl.AngleRoll / 10; // in deg |
664 | NaviData.AngleRoll = FromFlightCtrl.AngleRoll / 10; // in deg |
669 | NaviData.RC_Quality = (u8)FC.RC_Quality; |
665 | NaviData.RC_Quality = (u8)FC.RC_Quality; |
670 | NaviData.MKFlags = (u8)FC.MKFlags; |
666 | NaviData.MKFlags = (u8)FC.MKFlags; |
671 | NaviData.NCFlags = NCFlags; |
667 | NaviData.NCFlags = NCFlags; |
672 | NaviData.OperatingRadius = Parameter.NaviOperatingRadius; |
668 | NaviData.OperatingRadius = Parameter.NaviOperatingRadius; |
673 | NaviData.TopSpeed = (s16)GPSData.Speed_Top; // in cm/s |
669 | NaviData.TopSpeed = (s16)GPSData.Speed_Top; // in cm/s |
674 | NaviData.TargetHoldTime = (u8)(GetDelay(WPTime)/1000); // in s |
670 | NaviData.TargetHoldTime = (u8)(GetDelay(WPTime)/1000); // in s |
675 | //+++++++++++++++++++++++++++++++++++++++++++++++++++ |
671 | //+++++++++++++++++++++++++++++++++++++++++++++++++++ |
676 | return; |
672 | return; |
677 | } |
673 | } |
678 | 674 | ||
679 | 675 |