![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: MM2WayRanging/MM2WayRanging.h
- Revision:
- 48:5999e510f154
- Parent:
- 47:b6120c152ad1
- Child:
- 58:b824bdac7cd8
--- a/MM2WayRanging/MM2WayRanging.h Thu Mar 19 12:54:28 2015 +0000 +++ b/MM2WayRanging/MM2WayRanging.h Tue Nov 24 16:41:23 2015 +0000 @@ -1,7 +1,6 @@ -// by Matthias Grob & Manuel Stalder - ETH Zürich - 2015 +// Adapted from Matthias Grob & Manuel Stalder - ETH Zürich - 2015 -#ifndef MM2WAYRANGING_H -#define MM2WAYRANGING_H +#pragma once #include "mbed.h" #include "DW1000.h" @@ -10,6 +9,7 @@ #define US_TO_TIMEUNITS (128*499.2) // conversion between microseconds to the decawave timeunits (ca 15.65ps). #define MMRANGING_2POWER40 1099511627776 // decimal value of 2^40 to correct timeroverflow between timestamps +#define NUM_OF_UWB_ADDRESSES 256 //Predefined delay for the critical answers in the ranging algorithm @@ -22,18 +22,27 @@ public: MM2WayRanging(DW1000& DW); - void requestRanging(uint8_t destination); - void requestRangingAll(); - - + void requestRanging(uint8_t remote_address); //TODO: Better capsulation on those? bool isAnchor; - uint8_t address; // Identifies the nodes as source and destination in rangingframes + uint8_t address; // Identifies the nodes as address and remote_address in rangingframes //TODO: Make those PRIVATE! - float roundtriptimes[10]; // Array containing the round trip times to the anchors or the timeout which occured - float distances[10]; // Array containing the finally calculated Distances to the anchors + float roundtriptimes[NUM_OF_UWB_ADDRESSES]; // Array containing the round trip times to the anchors or the timeout which occured + float distances[NUM_OF_UWB_ADDRESSES]; // Array containing the finally calculated Distances to the anchors + + struct __attribute__((packed, aligned(1))) ReceptionStats { + uint16_t std_noise; + uint16_t preamble_acc_count; + uint16_t first_path_index; + uint16_t first_path_amp_1; + uint16_t first_path_amp_2; + uint16_t first_path_amp_3; + uint16_t channel_impulse_response_power; + uint8_t prf; + }; + ReceptionStats reception_stats[NUM_OF_UWB_ADDRESSES][3]; bool overflow; // TRUE if counter overflows while ranging @@ -45,23 +54,23 @@ void callbackRX(); void callbackTX(); - void sendPingFrame(uint8_t destination); - void sendDelayedAnswer(uint8_t destination, uint8_t type, uint64_t rxTimestamp); - void sendTransferFrame(uint8_t destination, int timestamp); + void sendPingFrame(uint8_t remote_address); + void sendDelayedAnswer(uint8_t remote_address, uint8_t type, uint64_t rxTimestamp); + void sendTransferFrame(uint8_t remote_address, int timestamp); - inline float calibratedDistance(uint8_t destination); + inline float calibratedDistance(uint8_t remote_address); /** * These two functions correct the timestamps if the counter had an overflow between measurements */ - void correctReceiverTimestamps(uint8_t source); - void correctSenderTimestamps(uint8_t source); + void correctReceiverTimestamps(uint8_t address); + void correctSenderTimestamps(uint8_t address); int timediffRec; int timediffSend; enum FrameType{ - PING=1, + PING = 1, ANCHOR_RESPONSE, BEACON_RESPONSE, TRANSFER_FRAME, @@ -71,25 +80,26 @@ //the packed attribute makes sure the types only use their respective size in memory (8 bit for uint8_t), otherwise they would always use 32 bit //IT IS A GCC SPECIFIC DIRECTIVE struct __attribute__((packed, aligned(1))) RangingFrame { - uint8_t source; - uint8_t destination; + uint8_t address; + uint8_t remote_address; uint8_t type; }; struct __attribute__((packed, aligned(1))) ExtendedRangingFrame : RangingFrame{ int signedTime; + ReceptionStats stats1; + ReceptionStats stats2; }; RangingFrame rangingFrame; // buffer in class for sending a frame (not made locally because then we can recall in the interrupt what was sent) ExtendedRangingFrame transferFrame; ExtendedRangingFrame receivedFrame; + uint64_t rxTimestamp; - uint64_t senderTimestamps[10][3]; - uint64_t receiverTimestamps[10][3]; - bool acknowledgement[10]; // flag to indicate if ranging has succeeded - uint32_t tofs[10]; // Array containing time of flights for each node (index is address of node) + uint64_t senderTimestamps[NUM_OF_UWB_ADDRESSES][3]; + uint64_t receiverTimestamps[NUM_OF_UWB_ADDRESSES][3]; + bool acknowledgement[NUM_OF_UWB_ADDRESSES]; // flag to indicate if ranging has succeeded + uint32_t tofs[NUM_OF_UWB_ADDRESSES]; // Array containing time of flights for each node (index is address of node) }; - -#endif