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

Guidance Vector Field #1919

Merged
merged 13 commits into from Nov 3, 2016
Merged

Guidance Vector Field #1919

merged 13 commits into from Nov 3, 2016

Conversation

noether
Copy link
Member

@noether noether commented Oct 29, 2016

A guidance module based on vector fields: https://wiki.paparazziuav.org/wiki/Module/guidance_vector_field (wiki entry still to be improved)

After polishing (and hopefully merging) this commit I will work on the integration of the module in the GCS , right now it can only draw circles using the CIRCLE msg.

So far it only works with fixedwings. The extension to rotorcrafts should be easy to implement, but I have not looked at pprz's rotorcrafts code yet...

Copy link
Member

@gautierhattenberger gautierhattenberger left a comment

Choose a reason for hiding this comment

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

indent in C files seems wrong at some places, you can use the fix_code_style.sh script

#include "std.h"

// Control
extern float gvf_error;

Choose a reason for hiding this comment

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

This variables could be in a gvf structure

*/

#ifndef GVF_ELLIPSE_H
#define GVF_ELLIPSE

Choose a reason for hiding this comment

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

it should be GVF_ELLIPSE_H


#include "../gvf.h"

extern float gvf_ellipse_a;

Choose a reason for hiding this comment

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

maybe make a gvf_ellipse structure

*/

#ifndef GVF_LINE_H
#define GVF_LINE

Choose a reason for hiding this comment

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

it should be GVF_LINE_H

*/

#ifndef GVF_SIN_H
#define GVF_SIN

Choose a reason for hiding this comment

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

GVF_SIN_H

// 1 - Ellipse
// 2 - Sin

extern uint8_t gvf_traj_type;

Choose a reason for hiding this comment

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

I suggest to make an enum for the list of possible types

#include <math.h>
#include "std.h"

#include "gvf.h"

Choose a reason for hiding this comment

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

usually, we have "global" path (from airborne code folder), so would be modules/guidance/gvf/gvf.h, and the others accordingly.


<header>
<file name="gvf.h"/>
<file name="trajectories/gvf_line.h"/>

Choose a reason for hiding this comment

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

fix indent (no tabs)

@@ -0,0 +1,18 @@
<!DOCTYPE settings SYSTEM "../settings.dtd">

<settings>

Choose a reason for hiding this comment

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

settings should be included in the module

@noether
Copy link
Member Author

noether commented Oct 30, 2016

yep, I will apply these changes. The structs that you suggest make sense.

I will also split the settings. The essential ones in the module (the gains and direction) and optional ones (parameters of the trajectories) in the current file at /conf/settings

@gautierhattenberger
Copy link
Member

Actually, you can have several settings in the same module that you can then choose to enable separately. See https://github.com/paparazzi/paparazzi/blob/master/conf/modules/cam_point.xml for an example. You just need to give a name to each settings section.

@noether
Copy link
Member Author

noether commented Oct 31, 2016

btw shall I add a gvf_demo.xml flight plan? so people can play with the settings from the GCS, etc.

< !DOCTYPE module SYSTEM "module.dtd" >

<module name = "gvf" dir = "guidance/gvf">
<doc>
Copy link
Member

Choose a reason for hiding this comment

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

something went wrong with formatting here...

Copy link
Member Author

Choose a reason for hiding this comment

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

haha, I see that the script for fixing the style messed the .xml up :P .

float alpha = gvf_trajectory.p[4];

// Phi(x,y)
float xel = (px - wx) * cosf(alpha) - (py - wy) * sinf(alpha);
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to make two local variables so that cos(alpha) and sin(alpha) are computed only once. Same for the sin guidance function.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, I can do it.

However (not 100% sure about it) I would say that the compiler takes care of such optimizations with the flag -O2 right? It checks how many times the same operation is done in the same scope and then make the corresponding optimization.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe we discussed that already. It still hurts a bit to see so many trig functions ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

haha yep. No worries, it does not take any effort to make this change. I will do it within tomorrow :P.

@flixr
Copy link
Member

flixr commented Nov 2, 2016

Shouldn't we prefix the module name and the "nav" functions that are supposed to be called from the flightplan with nav_ like with the other nav modules?

@flixr
Copy link
Member

flixr commented Nov 2, 2016

The defines that the user is supposed to (optionally) add to the airframe file should be documented in the module xml file. A bit more detailed description in the module xml (maybe with link to the the wiki page) would also be nice.

@noether
Copy link
Member Author

noether commented Nov 2, 2016

True, I have forgotten to add the #defines in the .xml. I will add also an extra description there tomorrow. I also have to add the condition/check 'only for fixedwing' (for the moment).

I am not sure about the prefix nav_ . Maybe this is another discussion and for sure you know better than me how to proceed. Instead of having nav_circle, nav_gvf_ellipse, nav_foo_circle.... is there any plan for how to organize/call different algorithms for the same purpose? e.g. to follow a circle? what do you think?

@gautierhattenberger
Copy link
Member

Regarding the nav_ prefix, this is actually a mix of nav and guidance. Initially we wanted to make a switch to choose between the CARROT guidance and GVF. But I finally agreed with Hector that the best way for now was to integrate as a module.
I think, the main issue comes (again) from the crappy navigation API.

@gautierhattenberger gautierhattenberger merged commit 2257a88 into paparazzi:master Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants