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

opticflow module #1062

Merged
merged 52 commits into from
Feb 5, 2015
Merged

opticflow module #1062

merged 52 commits into from
Feb 5, 2015

Conversation

dewagter
Copy link
Member

@dewagter dewagter commented Jan 7, 2015

todo

  • investigate the changes of @gautierhattenberger and use the best approach
  • move conf
  • remove submodule

@flixr flixr added the Module label Jan 7, 2015
<define name="USE_ARDRONE_VIDEO" />
<raw>

include $(PAPARAZZI_HOME)/sw/ext/ardrone2_vision/Makefile.paths
Copy link
Member

Choose a reason for hiding this comment

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

should be PAPARAZZI_SRC not PAPARAZZI_HOME

@dewagter
Copy link
Member Author

how about this... anyone wants to make the code look better?

@@ -36,13 +36,13 @@ inline void resize_uyuv(struct img_struct *input, struct img_struct *output, int
*dest++ = *source++; // U
*dest++ = *source++; // Y
// now skip 3 pixels
if (pixelskip) { source += (pixelskip + 1) * 2; }
source += (pixelskip + 1) * 2;

Choose a reason for hiding this comment

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

I would like to keep my version, otherwise it doesn't work with downsample=1 (which makes a copy of the image)

@gautierhattenberger
Copy link
Member

Thanks. Just one thing missing: in sw/ground_segment/tmtc/server_globals.ml:7 and sw/ground_segment/cockpit/livel.ml:1268 you should add the new mode name (or short name, MOD)

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2008-2009 Antoine Drouin <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

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

Could you please correctly put your name in here?

@flixr
Copy link
Member

flixr commented Jan 28, 2015

There are also some other potential issues, like calling my_plugin_run from the computervision thread.
Access to state interface is not thread safe!

flixr added 2 commits January 28, 2015 22:35
to get the scale when computing velocity from flow
<periodic fun="opticflow_module_run()" freq="60" start="opticflow_module_start()" stop="opticflow_module_stop()" autorun="TRUE"/>
<makefile target="ap">
<define name="ARDRONE_VIDEO_PORT" value="2002" />
<define name="USE_ARDRONE_VIDEO" />
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 this supposed to be good for, seems unused to me...

@flixr
Copy link
Member

flixr commented Jan 28, 2015

Tried to cleanup some more stuff and added a subscriber for AGL (to use for scale in velocity computation)...
Before we merge this, it should really be tested...

Accessing the state interface from a thread is probably not a good idea, you can be lucky and it works, but there is no guarantee that you don't try to read it while it is currently updated...

@gautierhattenberger
Copy link
Member

AP_MODE_MODULE is not the best, but good enough I guess until we can generate modes

@dewagter
Copy link
Member Author

@flixr thank for the updates.

This multithread design initially used UDP to send data from one program to the next: https://github.com/tudelft/ardrone2_vision/blob/master/modules/ObstacleAvoidSkySegmentation/sky_seg_avoid_gst.c#L82

I don't know at which point in time this got lost...

static void agl_cb(uint8_t sender_id __attribute__((unused)), const float *distance)
{
if (distance > 0) {
estimator_agl = *distance;

Choose a reason for hiding this comment

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

In this particular case, the data is read only and the copy is atomic, so it will be thread safe.
But testing the pointer is not correct ;)

if (*distance > 0) {

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for catching this!
And yes, this one is thread safe, otherwise I wouldn't have added it ;-)

@flixr
Copy link
Member

flixr commented Jan 29, 2015

And sending telemetry messages via DOWNLINK_SEND_x or pprz_msg_send_x is also not thread safe...
So I would suggest to move the downlink of OF_HOVER to somewhere else and also compute V_body in hover_stabilization which is the only other place that actually uses this.

@dewagter
Copy link
Member Author

I would prefer to make it 100% safe again: define 1 struct that goes from
pprz->thread and 1 struct that goes from thread->pprz and have all
navigation (fetching state) and messages in the module.

(this was the setup from the start, but after 3 people worked on it, it
changed along the road...)

Any better idea than UDP transfer? (this also makes it possible to run a
separate program instead of a thread)

-Christophe

On Thu, Jan 29, 2015 at 1:03 PM, Felix Ruess [email protected]
wrote:

And sending telemetry messages via DOWNLINK_SEND_x or pprz_msg_send_x is
also not thread safe...
So I would suggest to move the downlink of OF_HOVER to somewhere else and
also compute V_body in hover_stabilization which is the only other place
that actually uses this.


Reply to this email directly or view it on GitHub
#1062 (comment).

@flixr
Copy link
Member

flixr commented Jan 30, 2015

At least use a unix domain socket instead of a udp socket...
Ideally we would just send it via ABI and it would handle that in the background...

@flixr
Copy link
Member

flixr commented Feb 2, 2015

@dewagter see my opticflow_socket branch with a dummy example on how you could use unix domain sockets to pass results from the thread, specifically flixr@dfa33e4

flixr added a commit that referenced this pull request Feb 5, 2015
Add cv_opticflow.xml module.
Used to for hover stabilization on an ARDrone2.

Also adds AP_MODE_MODULE to make it easier to add extra "external" control loops.
@flixr flixr merged commit 17b200a into master Feb 5, 2015
@flixr flixr deleted the opticflow branch February 5, 2015 21:04
@flixr flixr added this to the v5.6 milestone Feb 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants