Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "decawave_anchorless_communication.h"
#include "subsystems/datalink/telemetry.h"
#include "subsystems/radio_control.h"
#include "state.h"
#include "mcu_periph/uart.h"
#include "subsystems/abi.h"
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | nodeState |
Macros | |
#define | UWB_SERIAL_PORT (&((SERIAL_UART).device)) |
#define | UWB_SERIAL_COMM_MAX_MESSAGE 20 |
#define | UWB_SERIAL_COMM_END_MARKER 255 |
#define | UWB_SERIAL_COMM_SPECIAL_BYTE 253 |
#define | UWB_SERIAL_COMM_START_MARKER 254 |
#define | UWB_SERIAL_COMM_NODE_STATE_SIZE 7 |
#define | UWB_SERIAL_COMM_NUM_NODES 3 |
#define | UWB_SERIAL_COMM_DIST_NUM_NODES UWB_SERIAL_COMM_NUM_NODES-1 |
#define | UWB_SERIAL_COMM_RANGE 0 |
#define | UWB_SERIAL_COMM_VX 1 |
#define | UWB_SERIAL_COMM_VY 2 |
#define | UWB_SERIAL_COMM_Z 3 |
#define | UWB_SERIAL_COMM_AX 4 |
#define | UWB_SERIAL_COMM_AY 5 |
#define | UWB_SERIAL_COMM_YAWR 6 |
Functions | |
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. More... | |
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. More... | |
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. More... | |
static void | sendFloat (uint8_t msg_type, float data) |
Function that will send a float over serial. More... | |
static void | setNodeStatesFalse (uint8_t index) |
Helper function that sets the boolean that tells whether a remote drone has a new state update to false. More... | |
static void | checkStatesUpdated (void) |
This function checks if all the states of all the distant nodes have at least once been updated. More... | |
static void | getSerialData (uint8_t *bytes_received) |
Function for receiving serial data. More... | |
void | decawave_anchorless_communication_init (void) |
Initialization functio. More... | |
void | decawave_anchorless_communication_periodic (void) |
This function periodically sends state data over the serial (which is received by the arduino) More... | |
void | decawave_anchorless_communication_event (void) |
Event function currently checks for serial data and whether an update of states is available for a distant drone. More... | |
Variables | |
struct link_device * | external_device = UWB_SERIAL_PORT |
static struct nodeState | states [UWB_SERIAL_COMM_DIST_NUM_NODES] |
struct nodeState |
Definition at line 71 of file decawave_anchorless_communication.c.
Data Fields | ||
---|---|---|
float | ax | |
float | ay | |
uint8_t | nodeAddress | |
float | r | |
bool | state_updated[UWB_SERIAL_COMM_NODE_STATE_SIZE] | |
float | vx | |
float | vy | |
float | yawr | |
float | z |
#define UWB_SERIAL_COMM_AX 4 |
Definition at line 67 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_AY 5 |
Definition at line 68 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_DIST_NUM_NODES UWB_SERIAL_COMM_NUM_NODES-1 |
Definition at line 59 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_END_MARKER 255 |
Definition at line 53 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_MAX_MESSAGE 20 |
Definition at line 52 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_NODE_STATE_SIZE 7 |
Definition at line 56 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_NUM_NODES 3 |
Definition at line 58 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_RANGE 0 |
Definition at line 63 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_SPECIAL_BYTE 253 |
Definition at line 54 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_START_MARKER 254 |
Definition at line 55 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_VX 1 |
Definition at line 64 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_VY 2 |
Definition at line 65 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_YAWR 6 |
Definition at line 69 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_COMM_Z 3 |
Definition at line 66 of file decawave_anchorless_communication.c.
#define UWB_SERIAL_PORT (&((SERIAL_UART).device)) |
Definition at line 48 of file decawave_anchorless_communication.c.
|
static |
This function checks if all the states of all the distant nodes have at least once been updated.
If all the states are updated, then do something with it! AKA CALLBACK TO MARIO
Definition at line 218 of file decawave_anchorless_communication.c.
References nodeState::ax, nodeState::ay, nodeState::r, setNodeStatesFalse(), nodeState::state_updated, states, UWB_COMM_ID, UWB_SERIAL_COMM_DIST_NUM_NODES, UWB_SERIAL_COMM_NODE_STATE_SIZE, nodeState::vx, nodeState::vy, nodeState::yawr, and nodeState::z.
Referenced by decawave_anchorless_communication_event().
void decawave_anchorless_communication_event | ( | void | ) |
Event function currently checks for serial data and whether an update of states is available for a distant drone.
If these cases are true, then actions are taken.
Definition at line 298 of file decawave_anchorless_communication.c.
References checkStatesUpdated(), and getSerialData().
void decawave_anchorless_communication_init | ( | void | ) |
Initialization functio.
Definition at line 272 of file decawave_anchorless_communication.c.
References setNodeStatesFalse(), and UWB_SERIAL_COMM_DIST_NUM_NODES.
void decawave_anchorless_communication_periodic | ( | void | ) |
This function periodically sends state data over the serial (which is received by the arduino)
Definition at line 283 of file decawave_anchorless_communication.c.
References nodeState::r, sendFloat(), stateGetAccelNed_f(), stateGetBodyRates_f(), stateGetPositionEnu_f(), stateGetSpeedEnu_f(), UWB_SERIAL_COMM_AX, UWB_SERIAL_COMM_AY, UWB_SERIAL_COMM_VX, UWB_SERIAL_COMM_VY, UWB_SERIAL_COMM_YAWR, UWB_SERIAL_COMM_Z, and nodeState::z.
Function for decoding the high bytes of received serial data and saving the message.
Since the start and end marker could also be regular payload bytes (since they are simply the values 254 and 255, which could also be payload data) the payload values 254 and 255 have been encoded as byte pairs 253 1 and 253 2 respectively. Value 253 itself is encoded as 253 0. This function will decode these back into values the original payload values.
Definition at line 130 of file decawave_anchorless_communication.c.
References handleNewStateValue(), and UWB_SERIAL_COMM_SPECIAL_BYTE.
Referenced by getSerialData().
|
static |
Function that encodes the high bytes of the serial data to be sent.
Start and end markers are reserved values 254 and 255. In order to be able to send these values, the payload values 253, 254, and 255 are encoded as 2 bytes, respectively 253 0, 253 1, and 253 2.
Definition at line 164 of file decawave_anchorless_communication.c.
References UWB_SERIAL_COMM_SPECIAL_BYTE.
Referenced by sendFloat().
|
static |
Function for receiving serial data.
Only receives serial data that is between the start and end markers. Discards all other data. Stores the received data in received_message, and after decodes the high bytes and copies the final message to the corresponding message in _messages.
Definition at line 239 of file decawave_anchorless_communication.c.
References decodeHighBytes(), external_device, UWB_SERIAL_COMM_END_MARKER, UWB_SERIAL_COMM_MAX_MESSAGE, UWB_SERIAL_COMM_START_MARKER, and UWB_SERIAL_PORT.
Referenced by decawave_anchorless_communication_event().
Function that is called when over the serial a new state value from a remote node is received.
Definition at line 88 of file decawave_anchorless_communication.c.
References nodeState::ax, nodeState::ay, nodeState::r, nodeState::state_updated, states, UWB_SERIAL_COMM_AX, UWB_SERIAL_COMM_AY, UWB_SERIAL_COMM_RANGE, UWB_SERIAL_COMM_VX, UWB_SERIAL_COMM_VY, UWB_SERIAL_COMM_YAWR, UWB_SERIAL_COMM_Z, nodeState::vx, nodeState::vy, nodeState::yawr, and nodeState::z.
Referenced by decodeHighBytes().
|
static |
Function that will send a float over serial.
The actual message that will be sent will have a start marker, the message type, 4 bytes for the float, and the end marker.
Definition at line 184 of file decawave_anchorless_communication.c.
References encodeHighBytes(), UWB_SERIAL_COMM_END_MARKER, UWB_SERIAL_COMM_MAX_MESSAGE, UWB_SERIAL_COMM_START_MARKER, and UWB_SERIAL_PORT.
Referenced by decawave_anchorless_communication_periodic().
|
static |
Helper function that sets the boolean that tells whether a remote drone has a new state update to false.
Definition at line 207 of file decawave_anchorless_communication.c.
References nodeState::state_updated, states, and UWB_SERIAL_COMM_NODE_STATE_SIZE.
Referenced by checkStatesUpdated(), and decawave_anchorless_communication_init().
struct link_device* external_device = UWB_SERIAL_PORT |
Definition at line 49 of file decawave_anchorless_communication.c.
Referenced by getSerialData().
|
static |
Definition at line 83 of file decawave_anchorless_communication.c.
Referenced by checkStatesUpdated(), handleNewStateValue(), send_ahrs_bias(), and setNodeStatesFalse().