Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module to Read and Broadcast Decawave Serial Communication within Paparazzi #2154

Conversation

coppolam
Copy link
Contributor

The module works with Decawave DWM1000 modules on Arduino, allowing multiple modules to communicate velocity and height from paparazzi with each-other, on top of measuring inter-antenna range. The link to the library and Arduino build file is provided in the module description. An ABI message with the received information is then broadcasted.

@gautierhattenberger
Copy link
Member

How is this module different from http://docs.paparazziuav.org/latest/module__dw1000_arduino.html ? Can we merge the two functionality if not exactly the same ?

@gautierhattenberger gautierhattenberger added Airborne Duplicate Add the label if the issue looks exactly like on reported already Module labels Nov 1, 2017
@coppolam
Copy link
Contributor Author

coppolam commented Nov 1, 2017

The module differs in that it is made for anchorless networks where UWB does not function as a trilateriation technology, but as a ranging/communication technology between MAVs. The module enables communication paparazzi on-board variables between MAVs (in this case VX, VY, Z). The agents need to communicate these values in order to achieve anchorless relative localization. From my understanding, this is a different functionality than dw1000_arduino and hence could be kept separate.

Copy link
Member

@kirkscheper kirkscheper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you added opencv_bebop and pprzlink changes

};

static uint8_t _bytesRecvd = 0;
static uint8_t _dataRecvCount = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this global? It is only used in the decode function.


static uint8_t _tempBuffer[UWB_SERIAL_COMM_MAX_MESSAGE];
static uint8_t _tempBuffer2[UWB_SERIAL_COMM_MAX_MESSAGE];
static uint8_t _recvBuffer[UWB_SERIAL_COMM_FLOAT_SIZE];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

* the payload values 253, 254, and 255 are encoded as 2 bytes, respectively 253 0, 253 1, and 253 2.
*/
static void encodeHighBytes(uint8_t* sendData, uint8_t msgSize){
_dataSendCount = msgSize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this used at all, why not just loop over msgSize?

static uint8_t _dataRecvCount = 0;

static uint8_t _tempBuffer[UWB_SERIAL_COMM_MAX_MESSAGE];
static uint8_t _tempBuffer2[UWB_SERIAL_COMM_MAX_MESSAGE];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use more descriptive naming here. _tempBuffer seems to be a receive buffer and 2 seems to be a send buffer so e.g. receive_data_buffer send_data_buffer

_dataRecvCount++;
}
if(_dataRecvCount==UWB_SERIAL_COMM_FLOAT_SIZE){
memcpy(&tempfloat,&_recvBuffer,UWB_SERIAL_COMM_FLOAT_SIZE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right.

#define UWB_SERIAL_COMM_VX 0
#define UWB_SERIAL_COMM_VY 1
#define UWB_SERIAL_COMM_Z 2
#define UWB_SERIAL_COMM_RANGE 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these defines in the header? Who else would want to use these?

conf/abi.xml Outdated
<message name="UWB_COMMUNICATION" id="19">
<field name="id" type="uint8_t"/>
<field name="range" type="float" unit="m"/>
<field name="vx" type="float" unit="m/s^2"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this acceleration or speed ? Unit and name are not matching

<event fun="decawave_serial_communication_event()"/>
<makefile target="ap">
<file name="decawave_serial_communication.c" />
<configure name="SERIAL_UART" default="uart2" case="upper|lower" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SERIAL_* is a bit too generic, it should be at least prefixed by something in relation with the module name

#define SERIAL_PORT (&((SERIAL_UART).device))
struct link_device *xdev = SERIAL_PORT;

#define SerialGetch() SERIAL_PORT ->get_byte(SERIAL_PORT->periph)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure these macros are a big help. Sometimes you use SERIAL_PORT, sometimes xdev (which is not a very explicit name). Would be better to be consistent.


static struct nodeState _states[UWB_SERIAL_COMM_DIST_NUM_NODES];
float range_float = 0.0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, you are using here a lot of global variables that could be gathered in a single structure with the buffers, status flags, indexes, uart device pointer, ...

}
_dataRecvCount++;
}
if(_dataRecvCount==UWB_SERIAL_COMM_FLOAT_SIZE){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you're done, don't forget to run the fix_code_style.sh script on your files

@coppolam coppolam force-pushed the pullrequest_decawave_serial_communication branch from 68dcd24 to 951d9ab Compare November 1, 2017 14:49
#include "subsystems/radio_control.h"
#include "state.h"
#include "pprzlink/messages.h"
#include "subsystems/datalink/downlink.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is those includes (downlink.h, messages.h) really needed ?

@gautierhattenberger
Copy link
Member

Mostly okay. It seems that your files don't have a endline character at the end.
Also, the default baudrate is only 9600 bauds. It looks a bit slow for an application that potentially require a high update rate. Don't you think it could be higher ?

@StevenH2812
Copy link

@gautierhattenberger It has been tested and working with 9600 baud rate. The lower baud rate ensures that the decawave side will function also with slower microprocessors. For the basic functionality of the module 9600 baud rate is enough since the communication is kept minimal. (6 byte messages, 4 messages back and forth, 20-30 Hz update frequency = 3840-5760 bit/s). If you have a faster microprocessor then by all means you should increase it to ensure you always have the latest data available, but people can always do so if they do decide to use this module. I noticed with an 8 MHz Atmega328 that 57600 was the limit baud rate, higher baud rates started giving erroneous communication.

That being said, the default can be set higher to say 19200 as well. I think whoever uses this module should tune this value to whatever works well with the microprocessor used on the decawave side anyways, so it's quite arbitrary.

@gautierhattenberger gautierhattenberger merged commit b5a4f89 into paparazzi:master Nov 2, 2017
@coppolam coppolam deleted the pullrequest_decawave_serial_communication branch November 3, 2017 13:38
podhrmic pushed a commit that referenced this pull request Nov 4, 2017
…arazzi (#2154)

* added decawave_serial_communication module files

* added reference to arduino library in module comments

* added abi message

* fixing abi send

* added abi

* compiles

* tested on bebop2 drones with decawave modules

* improved module description

* cleanup

* fixed code-style

* pprzlink same as master

* updated subrepos opencv_bebop

* temp

* temp

* temp

* addressed define and global variable comments

* Addressed comments on define macros and abi.xml

* making functions more general

* fix up

* tested!

* removing last global variables

* renamed temp variables

* must have messed up the message decoding/sending

* successfully tested

* clean-up

* changed variable names as necessary

* float size define removed

* last changes + tests

* removed test module

* removed unnecessary includes and added endline characters
biancabndris pushed a commit to biancabndris/paparazzi that referenced this pull request Aug 29, 2018
…arazzi (paparazzi#2154)

* added decawave_serial_communication module files

* added reference to arduino library in module comments

* added abi message

* fixing abi send

* added abi

* compiles

* tested on bebop2 drones with decawave modules

* improved module description

* cleanup

* fixed code-style

* pprzlink same as master

* updated subrepos opencv_bebop

* temp

* temp

* temp

* addressed define and global variable comments

* Addressed comments on define macros and abi.xml

* making functions more general

* fix up

* tested!

* removing last global variables

* renamed temp variables

* must have messed up the message decoding/sending

* successfully tested

* clean-up

* changed variable names as necessary

* float size define removed

* last changes + tests

* removed test module

* removed unnecessary includes and added endline characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Airborne Duplicate Add the label if the issue looks exactly like on reported already Module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants