|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
30 #include "generated/airframe.h"
36 #define Sign(_x) ((_x) > 0 ? 1 : (-1))
37 #define Norm2Pi(x) ({ uint8_t _i=1; float _x = x; while (_i && _x < 0.) { _i++;_x += 2*M_PI; } while (_i && _x > 2*M_PI) { _i++; _x -= 2*M_PI; } _x; })
52 radius = fabs(radius);
66 float desired_u_x = cos(M_PI_2 - desired_course_rad);
67 float desired_u_y = sin(M_PI_2 - desired_course_rad);
68 a_radius =
Sign(desired_u_x * da_y - desired_u_y * da_x) * radius;
76 u_x = wp_ca.x - wp_cd.x;
77 u_y = wp_ca.y - wp_cd.y;
78 float cd_ca = sqrt(u_x * u_x + u_y * u_y);
85 u_x = wp_ca.x - wp_cd.x;
86 u_y = wp_ca.y - wp_cd.y;
87 cd_ca = sqrt(u_x * u_x + u_y * u_y);
104 float alpha = atan2(u_y, u_x) + acos(
d_radius / (cd_ca / 2));
111 qdr_td = M_PI_2 - atan2(wp_td.y - wp_cd.y, wp_td.x - wp_cd.x);
151 #define ANGLE_STEP (2.*M_PI/NB_ANGLES)
169 float c = wind_north * wind_north + wind_east * wind_east - airspeed * airspeed;
172 float scal = wind_east * cos(
alpha) + wind_north * sin(
alpha);
173 float delta = 4 * (scal * scal -
c);
177 Bound(
ground_speeds[i], NOMINAL_AIRSPEED / 4, 2 * NOMINAL_AIRSPEED);
185 nominal_radius = fabs(nominal_radius);
193 if (airspeed < NOMINAL_AIRSPEED / 2. ||
194 airspeed > 2.* NOMINAL_AIRSPEED) {
195 airspeed = NOMINAL_AIRSPEED;
209 float nominal_time = 0.;
212 float ground_speed = NOMINAL_AIRSPEED;
217 nominal_time +=
ANGLE_STEP * nominal_radius / ground_speed;
220 nominal_time -= (
a - remaining_angle) * nominal_radius / ground_speed;
223 float radius = remaining_time / nominal_time * nominal_radius;
224 if (radius > 2. * nominal_radius) {
225 radius = nominal_radius;
237 return (remaining_time > 0);
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
static float ground_speed_of_course(float x)
static bool compute_ground_speed(float airspeed, float wind_east, float wind_north)
uint32_t tow
GPS time of week in ms.
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
void nav_circle_XY(float x, float y, float radius)
Navigates around (x, y).
#define NavQdrCloseTo(x)
True if x (in degrees) is close to the current QDR (less than 10 degrees)
bool snav_init(uint8_t a, float desired_course_rad, float radius)
#define NavVerticalAutoThrottleMode(_pitch)
Set the climb control to auto-throttle with the specified pitch pre-command.
#define CARROT
default approaching_time for a wp
static float ground_speeds[NB_ANGLES]
void nav_route_xy(float last_wp_x, float last_wp_y, float wp_x, float wp_y)
Computes the carrot position along the desired segment.
Device independent GPS code (interface)
static float stateGetAirspeed_f(void)
Get airspeed (float).
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
#define WaypointAlt(_wp)
waypoint altitude in m above MSL
static struct point wp_cd wp_td wp_ca wp_ta
bool nav_approaching_xy(float x, float y, float from_x, float from_y, float approaching_time)
Decide if the UAV is approaching the current waypoint.
static uint8_t ground_speed_timer
struct GpsState gps
global GPS state
#define NavVerticalAltitudeMode(_alt, _pre_climb)
Set the vertical mode to altitude control with the specified altitude setpoint and climb pre-command.
bool snav_on_time(float nominal_radius)