Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xsens700.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Christophe De Wagter
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 */
22
28#include "xsens700.h"
29
30#include "led.h"
31#include "generated/airframe.h"
32#include "mcu_periph/uart.h"
33
34#if USE_GPS_XSENS
36#endif
37
38
44
48
50
51volatile int xsens_configured = 0;
52
61
70
72{
73 if (xsens_configured > 0) {
74 switch (xsens_configured) {
75 case 25:
76 /* send mode and settings to MT */
78 //XSENS_SetOutputMode(xsens_output_mode);
79 //XSENS_SetOutputSettings(xsens_output_settings);
80 break;
81 case 18:
82 // Give pulses on SyncOut
83 //XSENS_SetSyncOutSettings(0,0x0002);
84 break;
85 case 17:
86
88 xsens_ask_message_rate(0x10, 0x10, 4); // UTC
89 xsens_ask_message_rate(0x20, 0x30, 100); // Attitude Euler
90 xsens_ask_message_rate(0x40, 0x10, 100); // Delta-V
91 xsens_ask_message_rate(0x80, 0x20, 100); // Rate of turn
92 xsens_ask_message_rate(0xE0, 0x20, 50); // Status
93 xsens_ask_message_rate(0x30, 0x10, 50); // Baro Pressure
94 xsens_ask_message_rate(0x88, 0x40, 1); // NavSol
95 xsens_ask_message_rate(0x88, 0xA0, 1); // SV Info
96 xsens_ask_message_rate(0x50, 0x20, 50); // GPS Altitude Ellipsiod
97 xsens_ask_message_rate(0x50, 0x40, 50); // GPS Position
98 xsens_ask_message_rate(0xD0, 0x10, 50); // GPS Speed
100 break;
101 case 2:
102 //XSENS_ReqLeverArmGps();
103 break;
104
105 case 6:
106 //XSENS_ReqMagneticDeclination();
107 break;
108
109 case 13:
110 //#ifdef AHRS_H_X
111 //#pragma message "Sending XSens Magnetic Declination."
112 //xsens_declination = atan2(AHRS_H_Y, AHRS_H_X);
113 //XSENS_SetMagneticDeclination(xsens_declination);
114 //#endif
115 break;
116 case 12:
117#ifdef GPS_IMU_LEVER_ARM_X
118#pragma message "Sending XSens GPS Arm."
120#endif
121 break;
122 case 10: {
123 uint8_t baud = 1;
125 }
126 break;
127
128 case 1:
130 break;
131 default:
132 break;
133 }
135 return;
136 }
137
138}
139
140
142{
143 uint8_t offset = 0;
148 } else if (xsens700.parser.id == XSENS_Error_ID) {
150 } else if (xsens700.parser.id == XSENS_MTData2_ID) {
151 for (offset = 0; offset < xsens700.parser.len;) {
155 offset += 3;
156
157 if (code1 == 0x10) {
158 if (code2 == 0x10) {
159 // UTC
160 } else if (code2 == 0x20) {
161 // Packet Counter
162 }
163 if (code2 == 0x30) {
164 // ITOW
165 }
166 } else if (code1 == 0x20) {
167 if (code2 == 0x30) {
168 // Attitude Euler
172
174 }
175 } else if (code1 == 0x40) {
176 if (code2 == 0x10) {
177 // Delta-V
181 }
182 } else if (code1 == 0x80) {
183 if (code2 == 0x20) {
184 // Rate Of Turn
188 }
189 } else if (code1 == 0x30) {
190 if (code2 == 0x10) {
191 // Baro Pressure
192 }
193 } else if (code1 == 0xE0) {
194 if (code2 == 0x20) {
195 // Status Word
197 //xsens700.gps.tow = xsens_msg_statusword;
198#if USE_GPS_XSENS
201 xsens700.gps.fix = GPS_FIX_3D;
202 } else {
203 xsens700.gps.fix = GPS_FIX_2D;
204 }
205 } else { xsens700.gps.fix = GPS_FIX_NONE; }
206#endif
207 }
208 } else if (code1 == 0x88) {
209 if (code2 == 0x40) {
215 } else if (code2 == 0xA0) {
216 // SVINFO
218
219#if USE_GPS_XSENS
221
222 xsens700.gps.last_3dfix_ticks = sys_time.nb_sec_rem;
223 xsens700.gps.last_3dfix_time = sys_time.nb_sec;
224
225 uint8_t i;
226 // Do not write outside buffer
227 for (i = 0; i < Min(xsens700.gps.nb_channels, GPS_NB_CHANNELS); i++) {
229 if (ch > xsens700.gps.nb_channels) { continue; }
234 }
235#endif
236 }
237 } else if (code1 == 0x50) {
238 if (code2 == 0x10) {
239 //xsens700.gps.hmsl = XSENS_DATA_Altitude_h(xsens700.parser.msg_buf,offset)* 1000.0f;
240 } else if (code2 == 0x20) {
241 // Altitude Elipsoid
242 xsens700.gps.lla_pos.alt = XSENS_DATA_Altitude_h(xsens700.parser.msg_buf, offset) * 1000.0f;
243
244 // Compute geoid (MSL) height
246 xsens700.gps.hmsl = xsens700.gps.lla_pos.alt - (geoid_h * 1000.0f);
247 SetBit(xsens700.gps.valid_fields, GPS_VALID_HMSL_BIT);
248
249 //xsens700.gps.tow = geoid_h * 1000.0f; //xsens700.gps.utm_pos.alt;
250 } else if (code2 == 0x40) {
251 // LatLong
252#ifdef GPS_LED
254#endif
255 xsens700.gps.last_3dfix_ticks = sys_time.nb_sec_rem;
256 xsens700.gps.last_3dfix_time = sys_time.nb_sec;
257 xsens700.gps.week = 0; // FIXME
258
261 }
262 } else if (code1 == 0xD0) {
263 if (code2 == 0x10) {
264 // Velocity
268 xsens700.gps.ned_vel.x = xsens700.vel.x;
269 xsens700.gps.ned_vel.y = xsens700.vel.y;
270 xsens700.gps.ned_vel.z = xsens700.vel.x;
271 SetBit(xsens700.gps.valid_fields, GPS_VALID_VEL_NED_BIT);
272 }
273 }
274
275 if (subpacklen < 0) {
276 subpacklen = 0;
277 }
279 }
280 }
281}
static uint16_t c1
static uint16_t c2
#define LED_TOGGLE(i)
Definition led_hw.h:53
static const float offset[]
#define Min(x, y)
Definition esc_dshot.c:109
#define GPS_VALID_VEL_NED_BIT
Definition gps.h:52
#define GPS_NB_CHANNELS
Definition gps.h:57
#define GPS_FIX_NONE
No GPS fix.
Definition gps.h:42
#define GPS_VALID_HMSL_BIT
Definition gps.h:53
#define GPS_FIX_2D
2D GPS fix
Definition gps.h:43
#define GPS_FIX_3D
3D GPS fix
Definition gps.h:44
float q
in rad/s
float phi
in radians
float p
in rad/s
float r
in rad/s
float theta
in radians
float psi
in radians
static float wgs84_ellipsoid_to_geoid_f(float lat, float lon)
Get WGS84 ellipsoid/geoid separation.
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
float lon
in radians
float lat
in radians
WGS-84 Geoid Heights.
#define UNINIT
Receiving pprz messages.
Definition protocol.c:11
#define TRUE
Definition std.h:4
volatile uint32_t nb_sec
full seconds since startup
Definition sys_time.h:72
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
Definition sys_time.h:73
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
void xsens700_init(void)
Definition xsens700.c:53
float xsens_gps_arm_y
Definition xsens700.c:46
volatile int xsens_configured
Definition xsens700.c:51
uint16_t xsens_time_stamp
Definition xsens700.c:41
uint8_t xsens_errorcode
Definition xsens700.c:39
uint32_t xsens_msg_statusword
Definition xsens700.c:40
float xsens_gps_arm_z
Definition xsens700.c:47
uint32_t xsens_output_settings
Definition xsens700.c:43
uint16_t xsens_output_mode
Definition xsens700.c:42
void parse_xsens700_msg(void)
Definition xsens700.c:141
static void xsens_ask_message_rate(uint8_t c1, uint8_t c2, uint8_t freq)
Definition xsens700.c:62
void xsens700_periodic(void)
Definition xsens700.c:71
struct Xsens xsens700
Definition xsens700.c:49
float xsens_gps_arm_x
Definition xsens700.c:45
Parser for the Xsens protocol.
struct FloatVect3 accel
Definition xsens.h:57
struct LlaCoor_f lla_f
Definition xsens.h:60
struct XsensParser parser
Definition xsens.h:66
struct FloatEulers euler
Definition xsens.h:64
struct FloatVect3 vel
NED velocity in m/s.
Definition xsens.h:61
struct FloatRates gyro
Definition xsens.h:56
volatile bool new_attitude
Definition xsens.h:67
Definition xsens.h:52
uint8_t status
#define XsensHeader(msg_id, len)
#define XsensTrailer()
uint8_t msg_buf[XSENS_MAX_PAYLOAD]
uint8_t len
#define XsensSend1ByAddr(x)