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
common_nav.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007-2009 ENAC, Pascal Brisset, Antoine Drouin
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
27#ifndef COMMON_NAV_H
28#define COMMON_NAV_H
29
30#include "std.h"
31#include "state.h"
33
34extern float max_dist_from_home;
35extern float dist2_to_home;
36extern float dist2_to_wp;
37extern bool too_far_from_home;
38
39struct point {
40 float x;
41 float y;
42 float a;
43};
44
45#define WaypointX(_wp) (waypoints[_wp].x)
46#define WaypointY(_wp) (waypoints[_wp].y)
48#define WaypointAlt(_wp) (waypoints[_wp].a)
49#define Height(_h) (_h + ground_alt)
50
51extern void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt);
52extern void nav_move_waypoint_enu(uint8_t wp_id, float x, float y, float alt);
53extern void nav_move_waypoint_point(uint8_t wp_id, struct point *p);
54extern void nav_send_waypoint(uint8_t wp_id);
55
56extern const uint8_t nb_waypoint;
57extern struct point waypoints[];
61extern float ground_alt;
62
63extern int32_t nav_utm_east0; /* m */
64extern int32_t nav_utm_north0; /* m */
66
67
68extern void compute_dist2_to_home(void);
69extern void nav_reset_utm_zone(void);
70extern void nav_reset_reference(void) __attribute__((unused));
71extern void nav_reset_alt(void) __attribute__((unused));
72extern void nav_update_waypoints_alt(void) __attribute__((unused));
73extern void common_nav_periodic_task(void);
74extern float get_time_to_home(void); /* estimated time to home point in seconds */
75
76
77#define NavSetGroundReferenceHere() ({ nav_reset_reference(); nav_update_waypoints_alt(); false; })
78
79#define NavSetAltitudeReferenceHere() ({ nav_reset_alt(); nav_update_waypoints_alt(); false; })
80
81#define NavSetWaypointHere(_wp) ({ \
82 waypoints[_wp].x = stateGetPositionEnu_f()->x; \
83 waypoints[_wp].y = stateGetPositionEnu_f()->y; \
84 false; \
85 })
86
87#define NavSetWaypointPosAndAltHere(_wp) ({ \
88 waypoints[_wp].x = stateGetPositionEnu_f()->x; \
89 waypoints[_wp].y = stateGetPositionEnu_f()->y; \
90 waypoints[_wp].a = stateGetPositionEnu_f()->z + ground_alt; \
91 false; \
92 })
93
94#endif /* COMMON_NAV_H */
Common flight_plan functions shared between fixedwing and rotorcraft.
float get_time_to_home(void)
Compute time to home use wind and airspeed when available.
Definition common_nav.c:71
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
Definition navigation.c:234
void nav_send_waypoint(uint8_t wp_id)
Send a waypoint throught default telemetry channel.
Definition common_nav.c:226
float max_dist_from_home
Definition navigation.c:53
float dist2_to_wp
Definition common_nav.c:39
void nav_reset_alt(void)
Reset the altitude reference to the current GPS alt.
Definition navigation.c:241
int32_t nav_utm_east0
Definition common_nav.c:48
bool too_far_from_home
Definition common_nav.c:41
void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt)
Move a waypoint to given UTM coordinates.
Definition common_nav.c:180
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
Definition navigation.c:326
void nav_move_waypoint_point(uint8_t wp_id, struct point *p)
Move a waypoint from point structure (local frame).
Definition common_nav.c:218
float y
Definition common_nav.h:41
uint8_t nav_utm_zone0
Definition common_nav.c:50
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition common_nav.c:46
float a
Definition common_nav.h:42
void nav_move_waypoint_enu(uint8_t wp_id, float x, float y, float alt)
Move a waypoint in local frame.
Definition common_nav.c:200
struct point waypoints[]
Definition common_nav.c:44
float x
Definition common_nav.h:40
void nav_reset_utm_zone(void)
Reset the UTM zone to current GPS fix.
Definition common_nav.c:107
float dist2_to_home
Definition common_nav.c:38
const uint8_t nb_waypoint
Definition common_nav.c:43
int32_t nav_utm_north0
Definition common_nav.c:49
void common_nav_periodic_task(void)
Definition common_nav.c:169
void nav_update_waypoints_alt(void)
Shift altitude of the waypoint according to a new ground altitude.
Definition common_nav.c:161
static float p[2][2]
uint16_t foo
Definition main_demo5.c:58
API to get/set the generic vehicle states.
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.