Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rotorcraft_datalink.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
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 
29 
30 #include "pprzlink/dl_protocol.h"
31 
32 #ifdef USE_NAVIGATION
34 #include "math/pprz_geodetic_int.h"
35 #endif
36 
38 
40 {
41  uint8_t msg_id = IdOfPprzMsg(dl_buffer);
42 
43  /* parse telemetry messages coming from ground station */
44  switch (msg_id) {
45 
46 #ifdef USE_NAVIGATION
47  case DL_BLOCK : {
48  if (DL_BLOCK_ac_id(dl_buffer) != AC_ID) { break; }
49  nav_goto_block(DL_BLOCK_block_id(dl_buffer));
50  }
51  break;
52 
53  case DL_MOVE_WP : {
54  uint8_t ac_id = DL_MOVE_WP_ac_id(dl_buffer);
55  if (ac_id != AC_ID) { break; }
57  uint8_t wp_id = DL_MOVE_WP_wp_id(dl_buffer);
58  struct LlaCoor_i lla;
59  lla.lat = DL_MOVE_WP_lat(dl_buffer);
60  lla.lon = DL_MOVE_WP_lon(dl_buffer);
61  /* WP_alt from message is alt above MSL in mm
62  * lla.alt is above ellipsoid in mm
63  */
64  lla.alt = DL_MOVE_WP_alt(dl_buffer) - state.ned_origin_i.hmsl +
66  waypoint_move_lla(wp_id, &lla);
67  }
68  }
69  break;
70 #endif /* USE_NAVIGATION */
71 
72  case DL_GUIDED_SETPOINT_NED:
73  if (DL_GUIDED_SETPOINT_NED_ac_id(dl_buffer) != AC_ID) { break; }
74 
75  autopilot_guided_update(DL_GUIDED_SETPOINT_NED_flags(dl_buffer),
76  DL_GUIDED_SETPOINT_NED_x(dl_buffer),
77  DL_GUIDED_SETPOINT_NED_y(dl_buffer),
78  DL_GUIDED_SETPOINT_NED_z(dl_buffer),
79  DL_GUIDED_SETPOINT_NED_yaw(dl_buffer));
80  break;
81 
82  default:
83  break;
84  }
85 }
uint8_t ac_id
Definition: sim_ap.c:46
static bool stateIsLocalCoordinateValid(void)
Test if local coordinates are valid.
Definition: state.h:502
Autopilot modes.
vector in Latitude, Longitude and Altitude
int32_t hmsl
Height above mean sea level in mm.
int32_t alt
in millimeters above WGS84 reference ellipsoid
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:180
struct LlaCoor_i lla
Reference point in lla.
int32_t lon
in degrees*1e7
Paparazzi fixed point math for geodetic calculations.
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:166
unsigned char uint8_t
Definition: types.h:14
void autopilot_guided_update(uint8_t flags, float x, float y, float z, float yaw)
Set guided setpoints using flag mask in GUIDED mode.
Definition: autopilot.c:610
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:64
int32_t lat
in degrees*1e7
void nav_goto_block(uint8_t b)
struct State state
Definition: state.c:36