29 #include "generated/modules.h"
32 #ifndef FOLLOW_ME_DISTANCE
33 #define FOLLOW_ME_DISTANCE 45
37 #ifndef FOLLOW_ME_HEIGHT
38 #define FOLLOW_ME_HEIGHT 75
42 #ifndef FOLLOW_ME_MIN_SPEED
43 #define FOLLOW_ME_MIN_SPEED 1.0f
47 #ifndef FOLLOW_ME_GPS_TIMEOUT
48 #define FOLLOW_ME_GPS_TIMEOUT 5000
52 #ifndef FOLLOW_ME_GROUND_TIMEOUT
53 #define FOLLOW_ME_GROUND_TIMEOUT 5000
57 #ifndef FOLLOW_ME_FILT
58 #define FOLLOW_ME_FILT 0.9
88 if(DL_TARGET_POS_ac_id(buf) != AC_ID)
110 bool target_valid =
true;
112 float diff_time_ms = 0;
117 static uint32_t last_relpos_tow = 0;
120 if(last_relpos_tow <
gps.relpos_tow) {
122 last_relpos_tow =
gps.relpos_tow;
126 target_pos.
x = cur_pos.
x -
gps.relpos_ned.x / 100.0f;
127 target_pos.
y = cur_pos.
y -
gps.relpos_ned.y / 100.0f;
128 target_pos.
z = cur_pos.
z -
gps.relpos_ned.z / 100.0f;
132 if(diff_time_ms < 0) diff_time_ms += (1000*60*60*24*7);
138 target_pos.
x = target_pos_cm.
x / 100.;
139 target_pos.
y = target_pos_cm.
y / 100.;
140 target_pos.
z = target_pos_cm.
z / 100.;
147 target_valid =
false;
150 static float gc_cos_filt = 0, gc_sin_filt = 0;
160 target_pos.
x += int_dist_m * gc_cos_filt;
161 target_pos.
y += int_dist_m * gc_sin_filt;
167 static float fmh_cos_filt = 0, fmh_sin_filt = 0;
172 if(last_time_ms != 0 && speed != 0) {
174 dist -= speed * time_diff;
175 height -= speed * time_diff;
181 else if(speed == 0) {
191 target_pos.
x += dist * fmh_cos_filt;
192 target_pos.
y += dist * fmh_sin_filt;
193 target_pos.
z -= height;
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
static float ground_course
float follow_me_min_speed
minimum speed in m/s which the ground needs to have in order to update the heading
void follow_me_parse_target_pos(uint8_t *buf)
on receiving a TARGET_POS message
float follow_me_min_height
Follow me minimum height in meters when approaching with a speed.
float follow_me_min_dist
Follow me minimum distance in meters when trying to approach with a certain speed.
float follow_me_height
height from the ground gps
static struct LlaCoor_i ground_lla
float follow_me_distance
distance from the ground gps
float follow_me_heading
heading direction in which to hover from (automatically set if ground is exceeding speed)
void follow_me_set_wp(uint8_t wp_id, float speed)
run function
float follow_me_gps_delay
Follow me GPS delay from the relative positionb packet (in ms)
static uint32_t ground_time_msec
static float ground_speed
void follow_me_init(void)
init function
float follow_me_advance_ms
Follow me waypoint advance time in ms (multiplied by the ground speed)
#define FOLLOW_ME_DISTANCE
#define FOLLOW_ME_GROUND_TIMEOUT
#define FOLLOW_ME_MIN_SPEED
float follow_me_datalink_delay
Follow me datalink delay from the ground GPS packet (in ms)
float follow_me_diag_speed
Diagonal speed for follow me.
static float ground_climb
float follow_me_filt
Follow me course sin/cos filter value (higher is harder filter)
#define FOLLOW_ME_GPS_TIMEOUT
struct GpsState gps
global GPS state
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
#define ENU_OF_TO_NED(_po, _pi)
int32_t lat
in degrees*1e7
int32_t alt
in millimeters above WGS84 reference ellipsoid
int32_t lon
in degrees*1e7
void ned_of_lla_point_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct LlaCoor_i *lla)
Convert a point from LLA to local NED.
vector in Latitude, Longitude and Altitude
vector in North East Down coordinates
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
bool ned_initialized_i
true if local int coordinate frame is initialsed
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu)
Set local ENU waypoint coordinates.
vector in East North Up coordinates Units: meters
vector in North East Down coordinates Units: meters
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
Periodic telemetry system header (includes downlink utility and generated code).
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.