29 #include "generated/modules.h"
30 #include "generated/flight_plan.h"
33 #ifndef FOLLOW_ME_DISTANCE
34 #define FOLLOW_ME_DISTANCE 45
38 #ifndef FOLLOW_ME_HEIGHT
39 #define FOLLOW_ME_HEIGHT 60
43 #ifndef FOLLOW_ME_GPS_TIMEOUT
44 #define FOLLOW_ME_GPS_TIMEOUT 5000
48 #ifndef FOLLOW_ME_GROUND_TIMEOUT
49 #define FOLLOW_ME_GROUND_TIMEOUT 5000
53 #ifndef FOLLOW_ME_FILT
54 #define FOLLOW_ME_FILT 0.9
58 #ifndef FOLLOW_ME_MOVING_WPS
59 #define FOLLOW_ME_MOVING_WPS
103 struct EnuCoor_f cur_targetpos, diff_targetpos;
104 float cur_targetpos_heading, diff_targetpos_heading;
126 wp_new_enu.
x = wp_enu->
x + diff_targetpos.
x;
127 wp_new_enu.
y = wp_enu->
y + diff_targetpos.
y;
128 wp_new_enu.
z = wp_enu->
z;
131 float cos_heading = cosf(diff_targetpos_heading/180.*M_PI);
132 float sin_heading = sinf(diff_targetpos_heading/180.*M_PI);
133 wp_new_enu.
x = ((wp_new_enu.
x - cur_targetpos.
x) * cos_heading) + ((wp_new_enu.
y - cur_targetpos.
y) * sin_heading) + cur_targetpos.
x;
134 wp_new_enu.
y = (-(wp_new_enu.
x - cur_targetpos.
x) * sin_heading) + ((wp_new_enu.
y - cur_targetpos.
y) * cos_heading) + cur_targetpos.
y;
149 if(DL_TARGET_POS_ac_id(buf) != AC_ID)
172 bool target_valid =
true;
174 float diff_time_ms = 0;
200 target_pos.
x = target_pos_cm.
x / 100.;
201 target_pos.
y = target_pos_cm.
y / 100.;
202 target_pos.
z = target_pos_cm.
z / 100.;
209 target_valid =
false;
212 static float gc_cos_filt = 0, gc_sin_filt = 0;
222 target_pos.
x += int_dist_m * gc_cos_filt;
223 target_pos.
y += int_dist_m * gc_sin_filt;
229 static float fmh_cos_filt = 0, fmh_sin_filt = 0;
234 if(last_time_ms != 0 && speed != 0) {
236 dist -= speed * time_diff;
237 height -= speed * time_diff;
243 else if(speed == 0) {
253 target_pos.
x += dist * fmh_cos_filt;
254 target_pos.
y += dist * fmh_sin_filt;
255 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
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.
void follow_me_periodic(void)
periodic function
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 uint8_t moving_wps_cnt
static uint32_t ground_time_msec
static uint8_t moving_wps[]
static float ground_speed
void follow_me_init(void)
init function
#define FOLLOW_ME_MOVING_WPS
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
static struct EnuCoor_f last_targetpos
static bool last_targetpos_valid
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 last_targetpos_heading
static float ground_heading
static float ground_climb
float follow_me_filt
Follow me course sin/cos filter value (higher is harder filter)
#define VECT3_COPY(_a, _b)
#define VECT3_DIFF(_c, _a, _b)
#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.
void enu_of_lla_point_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct LlaCoor_i *lla)
Convert a point from LLA to local ENU.
#define VECT3_FLOAT_OF_CM(_o, _i)
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
vector in North East Down coordinates
bool ned_initialized_i
true if local int coordinate frame is initialsed
static struct LtpDef_i * stateGetNedOrigin_i(void)
Get the coordinate NED frame origin (int)
struct EnuCoor_f * waypoint_get_enu_f(uint8_t wp_id)
Get ENU 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
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.