39 #if PERIODIC_TELEMETRY
40 static void send_ctc(
struct transport_tx *trans,
struct link_device *
dev)
51 #endif // PERIODIC TELEMETRY
56 #define CTC_GAIN_K1 0.001
59 #define CTC_GAIN_K2 0.001
61 #ifndef CTC_GAIN_ALPHA
62 #define CTC_GAIN_ALPHA 0.01
66 #define CTC_TIMEOUT 1500
70 #define CTC_OMEGA 0.25
73 #ifndef CTC_TIME_BROAD
74 #define CTC_TIME_BROAD 100
78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
CTC_OMEGA,
CTC_TIME_BROAD
103 #if PERIODIC_TELEMETRY
175 float dt = (now -
before) / 1000.0;
178 int num_neighbors = 0;
180 int num_neighbors = 0;
185 if (timeout > ctc_control.
timeout) {
190 float vx_nei =
tableNei[i][1] / 100.0;
191 float vy_nei =
tableNei[i][2] / 100.0;
192 float px_nei =
tableNei[i][3] / 100.0;
193 float py_nei =
tableNei[i][4] / 100.0;
204 int num_neighbors = 0;
209 if (timeout > ctc_control.
timeout) {
214 float vx_nei =
tableNei[i][1] / 100.0;
215 float vy_nei =
tableNei[i][2] / 100.0;
216 float px_nei =
tableNei[i][3] / 100.0;
217 float py_nei =
tableNei[i][4] / 100.0;
228 if (num_neighbors != 0) {
239 if(num_neighbors != 0){
250 float distance_target_ref = sqrtf(error_target_ref_x*error_target_ref_x + error_target_ref_y*error_target_ref_y);
251 if(distance_target_ref < 0.1)
252 distance_target_ref = 0.1;
253 float aux = (1-expf(-ctc_control.
alpha*distance_target_ref)) / distance_target_ref;
254 float v_ref_x = ctc_control.
target_vx + aux*(error_target_x);
255 float v_ref_y = ctc_control.
target_vy + aux*(error_target_y);
257 ctc_control.
ref_px += v_ref_x*dt;
258 ctc_control.
ref_py += v_ref_y*dt;
262 u_vel = -ctc_control.
k1*(-error_v_x*vy + error_v_y*vx);
265 float error_ref_x = px - ctc_control.
ref_px;
266 float error_ref_y = py - ctc_control.
ref_py;
267 u_spa = ctc_control.
omega*(1 + ctc_control.
k2*(error_ref_x*vx + error_ref_y*vy));
270 float u = u_vel + u_spa;
274 -atanf(u * (sqrtf(vx * vx + vy * vy)) / 9.8 / cosf(att->
theta));
288 struct pprzlink_msg msg;
294 msg.sender_id = AC_ID;
296 msg.component_id = 0;
297 pprzlink_msg_send_CTC_INFO_TO_NEI(&msg, &ctc_control.
vx, &ctc_control.
vy, &ctc_control.
px, &ctc_control.
py);
304 if (ac_id == AC_ID) {
305 uint8_t nei_id = DL_CTC_REG_TABLE_nei_id(buf);
bool collective_tracking_vehicle()
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Periodic telemetry system header (includes downlink utility and generated code).
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
int16_t tableNei[CTC_MAX_AC][6]
vector in East North Up coordinates Units: meters
bool collective_tracking_point(float x, float y)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
void parse_ctc_RegTable(uint8_t *buf)
uint32_t last_transmision
void ctc_send_info_to_nei(void)
Fixed wing horizontal control.
static void send_ctc(struct transport_tx *trans, struct link_device *dev)
Collective Tracking Control.
uint32_t last_info[CTC_MAX_AC]
#define DefaultPeriodic
Set default periodic telemetry.
float h_ctl_roll_max_setpoint
static const struct usb_device_descriptor dev
Core autopilot interface common to all firmwares.
#define LATERAL_MODE_ROLL
float h_ctl_roll_setpoint
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
struct point waypoints[NB_WAYPOINT]
size == nb_waypoint, waypoint 0 is a dummy waypoint
static void send_ctc_control(struct transport_tx *trans, struct link_device *dev)
void collective_tracking_control()
void parse_ctc_CleanTable(uint8_t *buf)
bool collective_tracking_waypoint(uint8_t wp)
void parse_ctc_NeiInfoTable(uint8_t *buf)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
uint8_t autopilot_get_mode(void)
get autopilot mode
void parse_ctc_TargetInfo(uint8_t *buf)