Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
common_nav.c File Reference
#include "modules/nav/common_nav.h"
#include "generated/flight_plan.h"
#include "modules/ins/ins.h"
#include "math/pprz_geodetic_float.h"
#include "modules/datalink/downlink.h"
#include "state.h"
#include "modules/gps/gps.h"
Include dependency graph for common_nav.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void compute_dist2_to_home (void)
 Computes squared distance to the HOME waypoint.
float get_time_to_home (void)
 Compute time to home use wind and airspeed when available.
void nav_reset_utm_zone (void)
 Reset the UTM zone to current GPS fix.
void nav_reset_reference (void)
 Reset the geographic reference to the current GPS fix.
void nav_reset_alt (void)
 Reset the altitude reference to the current GPS alt.
void nav_update_waypoints_alt (void)
 Shift altitude of the waypoint according to a new ground altitude.
void common_nav_periodic_task ()
void nav_move_waypoint (uint8_t wp_id, float ux, float uy, float alt)
 Move a waypoint to given UTM coordinates.
void nav_move_waypoint_enu (uint8_t wp_id, float x, float y, float alt)
 Move a waypoint in local frame.
void nav_move_waypoint_point (uint8_t wp_id, struct point *p)
 Move a waypoint from point structure (local frame).
void nav_send_waypoint (uint8_t wp_id)
 Send a waypoint throught default telemetry channel.

Variables

float dist2_to_home
float dist2_to_wp
bool too_far_from_home
const uint8_t nb_waypoint = NB_WAYPOINT
struct point waypoints [NB_WAYPOINT] = WAYPOINTS_UTM
 size == nb_waypoint, waypoint 0 is a dummy waypoint
float ground_alt
 size == nb_waypoint, waypoint 0 is a dummy waypoint
int32_t nav_utm_east0 = NAV_UTM_EAST0
int32_t nav_utm_north0 = NAV_UTM_NORTH0
uint8_t nav_utm_zone0 = NAV_UTM_ZONE0
float max_dist_from_home = MAX_DIST_FROM_HOME
static float previous_ground_alt

Function Documentation

◆ common_nav_periodic_task()

void common_nav_periodic_task ( void )

Definition at line 169 of file common_nav.c.

References block_time, NAVIGATION_FREQUENCY, and stage_time.

Referenced by navigation_task().

Here is the caller graph for this function:

◆ compute_dist2_to_home()

void compute_dist2_to_home ( void )

Computes squared distance to the HOME waypoint.

Computes squared distance to the HOME waypoint potentially sets too_far_from_home.

Updates dist2_to_home and potentially sets too_far_from_home

Definition at line 56 of file common_nav.c.

References dist2_to_home, stateGetPositionEnu_f(), too_far_from_home, waypoints, EnuCoor_f::x, and EnuCoor_f::y.

Here is the call graph for this function:

◆ get_time_to_home()

float get_time_to_home ( void )

Compute time to home use wind and airspeed when available.

Definition at line 71 of file common_nav.c.

References float_vect2_norm(), stateGetAirspeed_f(), stateGetHorizontalWindspeed_f(), stateGetPositionEnu_f(), stateIsAirspeedValid(), stateIsWindspeedValid(), waypoints, EnuCoor_f::x, FloatVect2::x, EnuCoor_f::y, and FloatVect2::y.

Here is the call graph for this function:

◆ nav_move_waypoint()

void nav_move_waypoint ( uint8_t wp_id,
float ux,
float uy,
float alt )

Move a waypoint to given UTM coordinates.

Parameters
[in]wp_idWaypoint ID
[in]uxUTM x (east) coordinate
[in]uyUTM y (north) coordinate
[in]altAltitude above MSL.

Definition at line 180 of file common_nav.c.

References LlaCoor_f::alt, max_dist_from_home, nav_utm_east0, nav_utm_north0, nb_waypoint, and waypoints.

Referenced by nav_parse_MOVE_WP().

Here is the caller graph for this function:

◆ nav_move_waypoint_enu()

void nav_move_waypoint_enu ( uint8_t wp_id,
float x,
float y,
float alt )

Move a waypoint in local frame.

Parameters
[in]wp_idWaypoint ID
[in]uxx (east) coordinate
[in]uyy (north) coordinate
[in]altAltitude above MSL.

Definition at line 200 of file common_nav.c.

References LlaCoor_f::alt, max_dist_from_home, nb_waypoint, and waypoints.

Referenced by nav_lace_run(), nav_move_waypoint_point(), nav_rosette_run(), and nav_trinity_run().

Here is the caller graph for this function:

◆ nav_move_waypoint_point()

void nav_move_waypoint_point ( uint8_t wp_id,
struct point * p )

Move a waypoint from point structure (local frame).

Parameters
[in]wp_idWaypoint ID
[in]pnew point

Definition at line 218 of file common_nav.c.

References nav_move_waypoint_enu(), and p.

Referenced by cloud_sim_move(), and cloud_sim_reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nav_reset_alt()

void nav_reset_alt ( void )

Reset the altitude reference to the current GPS alt.

Definition at line 151 of file common_nav.c.

References ground_alt, INS_RESET_VERTICAL_REF, previous_ground_alt, and stateGetHmslOrigin_f().

Here is the call graph for this function:

◆ nav_reset_reference()

void nav_reset_reference ( void )

Reset the geographic reference to the current GPS fix.

Definition at line 135 of file common_nav.c.

References UtmCoor_f::east, ground_alt, INS_RESET_REF, nav_utm_east0, nav_utm_north0, nav_utm_zone0, UtmCoor_f::north, previous_ground_alt, stateGetHmslOrigin_f(), stateGetUtmOrigin_f(), and UtmCoor_f::zone.

Here is the call graph for this function:

◆ nav_reset_utm_zone()

void nav_reset_utm_zone ( void )

Reset the UTM zone to current GPS fix.

Definition at line 107 of file common_nav.c.

References UtmCoor_f::alt, UtmCoor_f::east, gps, GPS_VALID_POS_UTM_BIT, ground_alt, lla_of_utm_f(), nav_utm_east0, nav_utm_north0, nav_utm_zone0, UtmCoor_f::north, stateSetLocalUtmOrigin_f(), utm_of_lla_f(), and UtmCoor_f::zone.

Here is the call graph for this function:

◆ nav_send_waypoint()

void nav_send_waypoint ( uint8_t wp_id)

Send a waypoint throught default telemetry channel.

Parameters
[in]wp_idWaypoint ID

Definition at line 226 of file common_nav.c.

References UtmCoor_f::alt, DefaultChannel, DefaultDevice, UtmCoor_f::east, nav_utm_east0, nav_utm_north0, nav_utm_zone0, nb_waypoint, UtmCoor_f::north, waypoints, and UtmCoor_f::zone.

Referenced by cloud_sim_move(), cloud_sim_reset(), nav_lace_run(), nav_rosette_run(), and nav_trinity_run().

Here is the caller graph for this function:

◆ nav_update_waypoints_alt()

void nav_update_waypoints_alt ( void )

Shift altitude of the waypoint according to a new ground altitude.

Definition at line 161 of file common_nav.c.

References ground_alt, previous_ground_alt, and waypoints.

Variable Documentation

◆ dist2_to_home

float dist2_to_home

Definition at line 38 of file common_nav.c.

Referenced by compute_dist2_to_home(), monitor_task(), and nav_home().

◆ dist2_to_wp

float dist2_to_wp

◆ ground_alt

◆ max_dist_from_home

float max_dist_from_home = MAX_DIST_FROM_HOME

Definition at line 51 of file common_nav.c.

◆ nav_utm_east0

◆ nav_utm_north0

◆ nav_utm_zone0

◆ nb_waypoint

◆ previous_ground_alt

float previous_ground_alt
static

Definition at line 104 of file common_nav.c.

Referenced by nav_reset_alt(), nav_reset_reference(), and nav_update_waypoints_alt().

◆ too_far_from_home

bool too_far_from_home

Definition at line 41 of file common_nav.c.

Referenced by autopilot_failsafe_checks(), and compute_dist2_to_home().

◆ waypoints

struct point waypoints[NB_WAYPOINT] = WAYPOINTS_UTM

size == nb_waypoint, waypoint 0 is a dummy waypoint

Definition at line 44 of file common_nav.c.

Referenced by cloud_sim_move(), collective_tracking_waypoint(), compute_dist2_to_home(), copilot_parse_move_wp_dl(), distance_to_wp(), distributed_circular(), DownlinkSendWp(), draw_osd(), follow_me_periodic(), follow_me_set_wp(), get_dist2_to_waypoint(), get_time_to_home(), get_two_intersects(), gvf_get_two_intersects(), mission_point_of_lla(), nav_compute_baseleg(), nav_compute_final_from_glide(), nav_cube_run(), nav_cube_setup(), nav_eight(), nav_flower_run(), nav_glide(), nav_gvf_survey_polygon_setup(), nav_home(), nav_init(), nav_land_run(), nav_line_border_run(), nav_line_osam_run(), nav_line_run(), nav_move_waypoint(), nav_move_waypoint_enu(), nav_oval(), nav_parse_MOVE_WP(), nav_send_waypoint(), nav_skid_landing_glide(), nav_skid_landing_run(), nav_skid_landing_setup(), nav_spiral_setup(), nav_survey_disc_run(), nav_survey_poly_osam_run(), nav_survey_poly_osam_setup(), nav_survey_poly_osam_setup_towards(), nav_survey_poly_run(), nav_survey_poly_setup(), nav_survey_poly_setup_towards(), nav_survey_polygon_setup(), nav_survey_rectangle(), nav_survey_rectangle_rotorcraft_run(), nav_survey_rectangle_rotorcraft_setup(), nav_survey_zamboni_setup(), nav_update_waypoints_alt(), nav_vertical_raster_run(), NavApproaching(), NavApproachingFrom(), NavCircleWaypoint(), NavGotoWaypoint(), NavSegment(), Oval(), parachute_compute_approach(), put_lat_lon_home(), rotorcraft_cam_periodic(), rotwing_state_choose_circle_direction(), rotwing_state_choose_state_by_dist(), send_wp_moved(), send_wp_moved(), update_waypoint(), waypoint_clear_global_flag(), waypoint_copy(), waypoint_get_alt(), waypoint_get_enu_f(), waypoint_get_enu_i(), waypoint_get_lat_deg(), waypoint_get_lla(), waypoint_get_lla_alt(), waypoint_get_lon_deg(), waypoint_get_x(), waypoint_get_y(), waypoint_globalize(), waypoint_is_global(), waypoint_localize(), waypoint_move_here_2d(), waypoint_move_lla(), waypoint_move_xy_i(), waypoint_position_copy(), waypoint_set_alt(), waypoint_set_alt_i(), waypoint_set_enu(), waypoint_set_enu_i(), waypoint_set_global_flag(), waypoint_set_latlon(), waypoint_set_lla(), waypoint_set_xy_i(), and waypoints_init().