Rev 489 | Rev 532 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 489 | Rev 491 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | #include "timer1.h" |
74 | #include "timer1.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" |
Line 78... | Line -... | ||
78 | - | ||
79 | - | ||
80 | #define M_PI_180 (M_PI / 180.0f) |
78 | |
- | 79 | #define GPS_UPDATETIME_MS 200 // 200ms is 5 Hz |
|
81 | #define GPS_UPDATETIME_MS 200 // 200ms is 5 Hz |
80 | |
82 | typedef enum |
81 | typedef enum |
83 | { |
82 | { |
84 | GPS_FLIGHT_MODE_UNDEF, |
83 | GPS_FLIGHT_MODE_UNDEF, |
85 | GPS_FLIGHT_MODE_FREE, |
84 | GPS_FLIGHT_MODE_FREE, |
Line 106... | Line 105... | ||
106 | float SpeedCompensation; |
105 | float SpeedCompensation; |
107 | s32 OperatingRadius; |
106 | s32 OperatingRadius; |
108 | GPS_FlightMode_t FlightMode; |
107 | GPS_FlightMode_t FlightMode; |
109 | } __attribute__((packed)) GPS_Parameter_t; |
108 | } __attribute__((packed)) GPS_Parameter_t; |
Line 110... | Line -... | ||
110 | - | ||
111 | typedef struct |
- | |
112 | { |
- | |
113 | u8 Status; // invalid, newdata, processed |
- | |
114 | s32 North; // in cm |
- | |
115 | s32 East; // in cm |
- | |
116 | s32 Bearing; // in deg |
- | |
117 | s32 Distance; // in cm |
- | |
118 | } __attribute__((packed)) GPS_Deviation_t; |
109 | |
119 | GPS_Deviation_t CurrentTargetDeviation; // Deviation from Target |
110 | GPS_Pos_Deviation_t CurrentTargetDeviation; // Deviation from Target |
120 | GPS_Deviation_t CurrentHomeDeviation; // Deviation from Home |
111 | GPS_Pos_Deviation_t CurrentHomeDeviation; // Deviation from Home |
Line 121... | Line 112... | ||
121 | GPS_Deviation_t TargetHomeDeviation; // Deviation from Target to Home |
112 | GPS_Pos_Deviation_t TargetHomeDeviation; // Deviation from Target to Home |
Line 122... | Line 113... | ||
122 | 113 | ||
123 | GPS_Stick_t GPS_Stick; |
114 | GPS_Stick_t GPS_Stick; |
Line 130... | Line 121... | ||
130 | // the gps reference positions |
121 | // the gps reference positions |
131 | GPS_Pos_t GPS_HoldPosition = {0,0,0, INVALID}; // the hold position |
122 | GPS_Pos_t GPS_HoldPosition = {0,0,0, INVALID}; // the hold position |
132 | GPS_Pos_t GPS_HomePosition = {0,0,0, INVALID}; // the home position |
123 | GPS_Pos_t GPS_HomePosition = {0,0,0, INVALID}; // the home position |
133 | GPS_Pos_t * GPS_pTargetPosition = NULL; // pointer to the actual target position |
124 | GPS_Pos_t * GPS_pTargetPosition = NULL; // pointer to the actual target position |
134 | u32 GPS_TargetRadius = 0; // catch radius for target area |
125 | u32 GPS_TargetRadius = 0; // catch radius for target area |
135 | Point_t* GPS_pWaypoint = NULL; // pointer to the actual waypoint |
126 | Point_t* GPS_pWaypoint = NULL; // pointer to the actual waypoint |
Line 136... | Line 127... | ||
136 | 127 | ||
137 | //------------------------------------------------------------- |
128 | //------------------------------------------------------------- |
138 | // Update GPSParamter |
129 | // Update GPSParamter |
139 | void GPS_UpdateParameter(void) |
130 | void GPS_UpdateParameter(void) |
Line 152... | Line 143... | ||
152 | u8 GPS_IsManuallyControlled(void) |
143 | u8 GPS_IsManuallyControlled(void) |
153 | { |
144 | { |
154 | return 0; |
145 | return 0; |
155 | } |
146 | } |
Line 156... | Line -... | ||
156 | - | ||
157 | //------------------------------------------------------------ |
- | |
158 | // copy GPS position from source position to target position |
- | |
159 | u8 GPS_CopyPosition(GPS_Pos_t * pGPSPosSrc, GPS_Pos_t* pGPSPosTgt) |
- | |
160 | { |
- | |
161 | return 0; |
- | |
162 | } |
- | |
163 | - | ||
164 | //------------------------------------------------------------ |
- | |
165 | // clear position data |
- | |
166 | u8 GPS_ClearPosition(GPS_Pos_t * pGPSPos) |
- | |
167 | { |
- | |
168 | return 0; |
- | |
169 | } |
- | |
Line 170... | Line 147... | ||
170 | 147 | ||
171 | 148 | ||
172 | //------------------------------------------------------------ |
149 | //------------------------------------------------------------ |
173 | void GPS_Neutral(void) |
150 | void GPS_Neutral(void) |
Line 178... | Line 155... | ||
178 | void GPS_Init(void) |
155 | void GPS_Init(void) |
179 | { |
156 | { |
180 | } |
157 | } |
Line 181... | Line 158... | ||
181 | 158 | ||
182 | //------------------------------------------------------------ |
- | |
183 | // calculate the bearing to target position from its deviation |
- | |
184 | s32 DirectionToTarget_N_E(float northdev, float eastdev) |
- | |
185 | { |
- | |
186 | return 0; |
- | |
187 | } |
- | |
188 | - | ||
189 | - | ||
190 | //------------------------------------------------------------ |
- | |
191 | // Rescale xy-vector length if length limit is violated |
- | |
192 | // returns vector len after scaling |
- | |
193 | s32 GPS_LimitXY(s32 *x, s32 *y, s32 limit) |
- | |
194 | { |
- | |
195 | return 0; |
- | |
196 | } |
- | |
197 | - | ||
198 | //------------------------------------------------------------ |
- | |
199 | // transform the integer deg into float radians |
- | |
200 | inline double RadiansFromGPS(s32 deg) |
- | |
201 | { |
- | |
202 | return 0.0; |
- | |
203 | } |
- | |
204 | - | ||
205 | //------------------------------------------------------------ |
- | |
206 | // transform the integer deg into float deg |
- | |
207 | inline double DegFromGPS(s32 deg) |
- | |
208 | { |
- | |
209 | return 0.0; |
- | |
210 | } |
- | |
211 | - | ||
212 | //------------------------------------------------------------ |
- | |
213 | // calculate the deviation from the current position to the target position |
- | |
214 | u8 GPS_CalculateDeviation(GPS_Pos_t * pCurrentPos, GPS_Pos_t * pTargetPos, GPS_Deviation_t* pDeviationFromTarget) |
- | |
215 | { |
- | |
216 | return 0; |
- | |
Line 217... | Line 159... | ||
217 | } |
159 | //------------------------------------------------------------ |
218 | 160 | ||
219 | void GPS_Navigation(gps_data_t *pGPS_Data, GPS_Stick_t* pGPS_Stick) |
161 | void GPS_Navigation(gps_data_t *pGPS_Data, GPS_Stick_t* pGPS_Stick) |
220 | { |
162 | { |