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

Pullrequest relative localization filter #2262

Conversation

coppolam
Copy link
Contributor

@coppolam coppolam commented May 8, 2018

This is a pull request for a relative localization filter that uses Ultra Wide Band (or any range sensor) to compute the relative location of other MAVs. The code has been tested to work with decawave_anchorless_communication.c (with the changes included).

This pull request is accompanied by a pull request in pprzlink to add the message RLFILTER

<module name="relative_localization_filter" dir="relative_localization_filter">
<doc>
<description>
Relative Localization Filter based on UWB range measurements + Communication between drones.
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 update spacing here to be similar to other projects?


// Q Matrix
MAKE_MATRIX_PTR(_Q, filter->Q, EKF_N);
float_mat_identity_scal(_Q, pow(0.3, 2.0), EKF_N);
Copy link
Member

Choose a reason for hiding this comment

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

For float constants like this, we prefer 2.f to 2.0 (the latter is a double by default).

#define EKF_N 7
#define EKF_M 6

typedef struct discrete_ekf {
Copy link
Member

Choose a reason for hiding this comment

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

We don't use type defs in paparazzi. Please remove and use 'struct discrete_ekf'.


#include "discrete_ekf.h"

extern discrete_ekf ekf_rl[RL_NUAVS - 1];
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 defined here? Is this parameter used outside of the relative_localization_filter source file? Only include things needed by other files in the header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is that, if desired, this can be directly read out from other modules so that they can do something with the info. I could also change to an ABI message though, if that's preferred in paparazzi.

@coppolam coppolam force-pushed the pullrequest_relative_localization_filter branch from df5041a to fc3424d Compare May 9, 2018 15:59
@kirkscheper
Copy link
Member

Yup!

@@ -673,6 +673,18 @@ static inline void float_mat_transpose(float **a, int n)
}
}


/** transpose non-square matrix */
static inline void float_mat_transpose_general(float **o, float **a, int n, int m)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like it would be better to have float_mat_transpose and float_mat_transpose_square. That would require you to update all uses of this function but it seems better.

* b: [n x l]
* o: [m x l]
*/
static inline void float_mat_vect_mul(float *o, float **a, float *b, int m, int n)
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 update the comments to be 1 instead of l? You also need to set o[i] to zero before the second for loop.

@@ -734,15 +763,14 @@ static inline void float_mat_col(float *o, float **a, int m, int c)
}

/** Make an n x n identity matrix (for matrix passed as array) */
static inline void float_mat_identity(float **o, int n)
static inline void float_mat_identity_scal(float **o, float v, int n)
Copy link
Member

Choose a reason for hiding this comment

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

This is not an identity matrix if the values are non-zero...

You can either use float_mat_identity and float_mat_vect_mul or make a new function e.g. float_mat_diagonal_scal. But given that you only use non-one values in a function initialization it's probably not strictly necessary, up to you.

@@ -32,7 +32,7 @@
on-board values with each-other (for purposes such as relative localization, co-ordination, or collision avoidance).
This module must be used together with the Decawave DWM1000 running the appropriate Serial Communication code, which can be flashed on the Arduino board.
The arduino library can be found at:
https://github.com/StevenH2812/arduino-dw1000/tree/UWB_localization_v1.0
https://github.com/StevenH2812/arduino-dw1000/tree/UWB_onboard
Copy link
Member

Choose a reason for hiding this comment

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

its probably a good idea to get a copy of this on the tudelft repo or have Steven transfer ownership and use that repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is on the to-do list, at which point we can change the link

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed a pull request will be created for all the fixes and addition to the original repo here https://github.com/thotro

Note that this is separate from this pull request, this one can, after fixes suggested by @kirkscheper as reviewer are implemented) Which as of 20180530 they are as understood from @coppolam

Copy link
Contributor

Choose a reason for hiding this comment

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

note that this s only a remark line where one could find the arduino-dw1000 UWB_onboard code, and so far a valid one... so no blocker for a pull since there is no other URL atm, as soon as the pull and merge with trhe originating repo is availabe, feel free to adjust the remark to another url...

uint8_t number_filters;
struct discrete_ekf ekf_rl[RL_NUAVS - 1];
float range_array[RL_NUAVS - 1];
uint8_t pprzmsg_cnt;
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 add a short description for these global variables?


void relative_localization_filter_init(void)
{
int32_vect_set_value(ID_array, 5, RL_NUAVS - 1);
Copy link
Member

Choose a reason for hiding this comment

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

What is 5 here? Not clear what happening or why. I guess this should be RL_NUAVS.

#include "discrete_ekf.h"

// This can be used elsewhere to directly read out the result of the ekf
extern struct discrete_ekf ekf_rl[RL_NUAVS - 1];
Copy link
Member

Choose a reason for hiding this comment

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

Please replace this with abi messages if you want to share this data with other modules.

Like this, any code which reads out the data will be dependent on this module and not work with any other module. If you utilize the abi messaging structure, any modules which use this relative localization estimation could use other estimation methods as well (e.g adsb). This makes the module structure more flexible and useful.

#include <stdio.h>
#include <stdlib.h>

int32_t ID_array[RL_NUAVS - 1];
Copy link
Member

Choose a reason for hiding this comment

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

Why id in caps?

#define RELATIVE_LOCALIZATION_FILTER_H

#ifndef RL_NUAVS
#define RL_NUAVS 5 // Maximum expected number of UAVs
Copy link
Member

Choose a reason for hiding this comment

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

why not define this as the maximum number of expected 'other' UAVs, then you don't have to constantly have RL_NUAVS - 1.

@@ -262,6 +285,10 @@ void decawave_anchorless_communication_periodic(void)
sendFloat(UWB_SERIAL_COMM_VX, stateGetSpeedEnu_f()->y);
sendFloat(UWB_SERIAL_COMM_VY, stateGetSpeedEnu_f()->x);
sendFloat(UWB_SERIAL_COMM_Z, stateGetPositionEnu_f()->z);
sendFloat(UWB_SERIAL_COMM_AX, 0.);
sendFloat(UWB_SERIAL_COMM_AY, 0.);
sendFloat(UWB_SERIAL_COMM_YAWR, 0.);
Copy link
Member

Choose a reason for hiding this comment

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

Interesting. Is this some functionality that will be added later?

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.

Almost there!

pprzmsg_cnt++;
if (pprzmsg_cnt >= number_filters) {
pprzmsg_cnt = 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

sorry to nag here but what if number_filters=0? Won't this message will contain gibberish.

// send id, x, y, z, vx, vy
AbiSendMsgRELATIVE_LOCALIZATION_EKF(RL_EKF_ID, id_array[i], ekf_rl[i].X[0], ekf_rl[i].X[1], ekf_rl[i].X[6], ekf_rl[i].X[4], ekf_rl[i].X[5]);
}
};
Copy link
Member

Choose a reason for hiding this comment

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

add new line here.

@OpenUAS OpenUAS self-requested a review May 30, 2018 16:35
@OpenUAS OpenUAS added this to the v5.14 milestone May 30, 2018
Copy link
Contributor

@OpenUAS OpenUAS left a comment

Choose a reason for hiding this comment

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

All code changes requested are no implemented, nice..

conf/abi.xml Outdated
@@ -156,6 +156,15 @@
<field name="accel_sp" type="struct FloatVect3 *" unit="m/s^2"/>
</message>

<message name="RELATIVE_LOCALIZATION_EKF" id="24">

Choose a reason for hiding this comment

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

Who is using this message ? There is no bind for it apparently.

Also, it would be nicer to have this more generic. Several options:

  • remove "_EKF"
  • add "vz" even if not used in this case
  • replace this by a combination of POSITION_ESTIMATE and VELOCITY_ESTIMATE (which means that an extra ID field might be required)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, this message is not used anywhere at the moment. It was created so that it can be used by other modules that wish to do something with the relative localization data.

@coppolam coppolam force-pushed the pullrequest_relative_localization_filter branch from 151a406 to 9df6c55 Compare May 31, 2018 08:54
@coppolam coppolam force-pushed the pullrequest_relative_localization_filter branch from 9df6c55 to 2d40650 Compare May 31, 2018 09:07
@gautierhattenberger
Copy link
Member

I have merged the corresponding message in pprzlink, please update the reference accordingly.

@gautierhattenberger gautierhattenberger merged commit a733997 into paparazzi:master Jun 10, 2018
@coppolam coppolam deleted the pullrequest_relative_localization_filter branch June 11, 2018 08:06
biancabndris pushed a commit to biancabndris/paparazzi that referenced this pull request Aug 29, 2018
* added files (tested)

* fixed code style

* removed RLFILTER from default_rotorcraft.xml

* fixed xml file, changed 2.0 to .f for floats, removed typedef + checked that it builds

* fixed float_mat_transpose --> float_mat_transpose_square and float_mat_transpose_general --> float_mat_transpose

* pprz_algebra_float set o[i]=0 at line 717

* [relative_localization_filter] RL_NUAVS changed from all to just other observed

* [relative_localization_filter] ID_array -> id_array

* [decawave_anchorless_communication] added acceleration and yaw rates readings to uwb message

* [relative_localization_filter] line 91, changed 5 to RL_NUAVS+1 and added explanation

* [relative_localization_filter] added comments to global variables

* [relative_localization_filter] moved ekf_rl to c file

* [relative_localization_filter] added abi message

* [relative_localization_filter] fixed abi message + check build

* [relative_localization_filter] added line end + added if guard too pprz message + changed float_mat_identity_scal to float_mat_diag_scal

* [relative_localization_filter] updated ABI name + added vz to ABI message + added a few comments + tested

* update pprzlink reference to include RLFILTER message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Airborne Enhancement Improve upon exiting functionality Module TestingRequired
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants