Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
ctc_target.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Hector Garcia de Marina
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 */
22
23#include <math.h>
24#include <std.h>
25#include <stdio.h>
26
30#include "autopilot.h"
31
33#ifndef CTC_MAX_AC
34#define CTC_MAX_AC 4
35#endif
36
38
40{
41 for (int i = 0; i < CTC_MAX_AC; i++) {
42 tableNei[i][0] = -1;
43 }
44}
45
47{
48 struct EnuCoor_f *v = stateGetSpeedEnu_f();
50
51 float vx = v->x;
52 float vy = v->y;
53 float px = p->x;
54 float py = p->y;
55
56 struct pprzlink_msg msg;
57
58 for (int i = 0; i < CTC_MAX_AC; i++)
59 if (tableNei[i][0] != -1) {
60 msg.trans = &(DefaultChannel).trans_tx;
61 msg.dev = &(DefaultDevice).device;
62 msg.sender_id = AC_ID;
63 msg.receiver_id = tableNei[i][0];
64 msg.component_id = 0;
65 pprzlink_msg_send_CTC_INFO_FROM_TARGET(&msg, &px, &py, &vx, &vy);
66 }
67}
68
70{
72 if (ac_id == AC_ID) {
74 for (int i = 0; i < CTC_MAX_AC; i++)
75 if (tableNei[i][0] == -1) {
76 tableNei[i][0] = (int16_t)nei_id;
77 return;
78 }
79 }
80}
81
83{
85 if (ac_id == AC_ID)
86 for (int i = 0; i < CTC_MAX_AC; i++) {
87 tableNei[i][0] = -1;
88 }
89}
90
Core autopilot interface common to all firmwares.
void ctc_target_send_info_to_nei(void)
Definition ctc_target.c:46
void parse_ctc_target_RegTable(uint8_t *buf)
Definition ctc_target.c:69
void ctc_target_init(void)
Definition ctc_target.c:39
void parse_ctc_target_CleanTable(uint8_t *buf)
Definition ctc_target.c:82
#define CTC_MAX_AC
Definition ctc_target.c:34
int16_t tableNei[CTC_MAX_AC][6]
Definition ctc_target.c:37
Collective Tracking Control (module for the target to be tracked)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition state.h:1058
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
static float p[2][2]
uint16_t foo
Definition main_demo5.c:58
float y
in meters
float x
in meters
vector in East North Up coordinates Units: meters
Rotorcraft navigation functions.
Periodic telemetry system header (includes downlink utility and generated code).
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.