|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
48 #define UWB_SERIAL_PORT (&((SERIAL_UART).device))
52 #define UWB_SERIAL_COMM_MAX_MESSAGE 20
53 #define UWB_SERIAL_COMM_END_MARKER 255
54 #define UWB_SERIAL_COMM_SPECIAL_BYTE 253
55 #define UWB_SERIAL_COMM_START_MARKER 254
56 #define UWB_SERIAL_COMM_NODE_STATE_SIZE 7
58 #define UWB_SERIAL_COMM_NUM_NODES 3 // How many nodes actually are in the network
59 #define UWB_SERIAL_COMM_DIST_NUM_NODES UWB_SERIAL_COMM_NUM_NODES-1 // How many distant nodes are in the network (one less than the toal number of nodes)
63 #define UWB_SERIAL_COMM_RANGE 0
64 #define UWB_SERIAL_COMM_VX 1
65 #define UWB_SERIAL_COMM_VY 2
66 #define UWB_SERIAL_COMM_Z 3
67 #define UWB_SERIAL_COMM_AX 4
68 #define UWB_SERIAL_COMM_AY 5
69 #define UWB_SERIAL_COMM_YAWR 6
132 static uint8_t receive_buffer[4];
134 uint8_t data_received_count = 0;
135 uint8_t this_address = received_message[1];
136 uint8_t msg_from = received_message[2];
137 uint8_t msg_type = received_message[3];
138 uint8_t nodeIndex = msg_from - 1 - (
uint8_t)(this_address < msg_from);
139 for (
uint8_t i = 4; i < bytes_received - 1; i++) {
141 uint8_t var_byte = received_message[i];
144 var_byte = var_byte + received_message[i];
146 if (data_received_count <= 4) {
147 receive_buffer[data_received_count] = var_byte;
149 data_received_count++;
151 if (data_received_count == 4) {
153 memcpy(&tempfloat, &receive_buffer, 4);
166 uint8_t data_send_count = msg_size;
167 *data_total_send = 0;
168 for (
uint8_t i = 0; i < data_send_count; i++) {
171 (*data_total_send)++;
174 data_send_buffer[*data_total_send] = send_data[i];
176 (*data_total_send)++;
187 static uint8_t data_total_send = 0;
191 memcpy(floatbyte, &data, 4);
197 for (
uint8_t i = 0; i < data_total_send; i++) {
241 static bool in_progress =
false;
249 (*bytes_received) = 0;
255 received_message[*bytes_received] = var_byte;
static void checkStatesUpdated(void)
This function checks if all the states of all the distant nodes have at least once been updated.
static struct nodeState states[UWB_SERIAL_COMM_DIST_NUM_NODES]
static void decodeHighBytes(uint8_t bytes_received, uint8_t *received_message)
Function for decoding the high bytes of received serial data and saving the message.
static void sendFloat(uint8_t msg_type, float data)
Function that will send a float over serial.
void decawave_anchorless_communication_periodic(void)
This function periodically sends state data over the serial (which is received by the arduino)
static void encodeHighBytes(uint8_t *send_data, uint8_t msg_size, uint8_t *data_send_buffer, uint8_t *data_total_send)
Function that encodes the high bytes of the serial data to be sent.
void decawave_anchorless_communication_init(void)
Initialization functio.
static void getSerialData(uint8_t *bytes_received)
Function for receiving serial data.
#define UWB_SERIAL_COMM_SPECIAL_BYTE
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
#define UWB_SERIAL_COMM_AX
void decawave_anchorless_communication_event(void)
Event function currently checks for serial data and whether an update of states is available for a di...
#define UWB_SERIAL_COMM_START_MARKER
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
#define UWB_SERIAL_COMM_END_MARKER
#define UWB_SERIAL_COMM_RANGE
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static void setNodeStatesFalse(uint8_t index)
Helper function that sets the boolean that tells whether a remote drone has a new state update to fal...
#define UWB_SERIAL_COMM_VX
#define UWB_SERIAL_COMM_Z
#define UWB_SERIAL_COMM_AY
#define UWB_SERIAL_COMM_VY
#define UWB_SERIAL_COMM_YAWR
#define UWB_SERIAL_COMM_MAX_MESSAGE
bool state_updated[UWB_SERIAL_COMM_NODE_STATE_SIZE]
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
struct link_device * external_device
#define UWB_SERIAL_COMM_NODE_STATE_SIZE
static void handleNewStateValue(uint8_t nodeIndex, uint8_t msg_type, float value)
Function that is called when over the serial a new state value from a remote node is received.
#define UWB_SERIAL_COMM_DIST_NUM_NODES