saffae / javadrone

Automatically exported from code.google.com/p/javadrone
0 stars 0 forks source link

Multicast video reader #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The current video implementation uses unicast and does not allow reading the 
video while another application is controlling the drone and displaying the 
video. The attached file implements a multicast video reader for ardrone. Maybe 
its helpful for somebody.

Cheers,
Normen Hansen

Original issue reported on code.google.com by normen667 on 14 May 2011 at 11:17

Attachments:

GoogleCodeExporter commented 8 years ago
Normen, 

Is it an undocumented AR Drone feature to send multicast packets? I could not 
find it anywhere in the documentation? Very interesting!

Original comment by kroko...@gmail.com on 15 May 2011 at 3:09

GoogleCodeExporter commented 8 years ago
It has been added in the latest firmware and is done by default now, on address 
224.1.1.1 with the same ports as unicast. See this post: 
https://projects.ardrone.org/boards/1/topics/show/2565
I use this listener to view the video on a laptop while controlling the drone 
from an iPhone and it works nicely, see the test attached to this post.

Original comment by normen667 on 15 May 2011 at 10:20

Attachments:

GoogleCodeExporter commented 8 years ago
I saw that the api has changed a bit since I created the files and I updated 
them to the latest changes. At the same time I changed the handling of the 
BufferedImages a bit so that there is no unnecessary flow of BuffereImages 
through the garbage collector. The synchronization happens on the Reader object 
which is maybe not ideal, I think the VideoListener callback could maybe just 
deliver the BufferedVideoImage so that the listener can write to its own 
BufferedImage and do the synchronization by itself.

Cheers,
Normen

Original comment by normen667 on 15 May 2011 at 11:32

Attachments:

GoogleCodeExporter commented 8 years ago
Normen, I think we should add multicast support to the project. It looks like 
that 99% of the code is same as unicast, with exception of socket 
initialization. What do you think about adding boolean flag to class 
VideoReader constructor 'use_multicast'. If true, multicast will be used. If 
false, unicast will be used.

If you agree with this approach I think this is a way to go. I will appreciate 
the patch for this, but if you do not want to do it, perhaps I can do this 
change myself in day or two.

Thanks!

Original comment by kroko...@gmail.com on 16 May 2011 at 2:46

GoogleCodeExporter commented 8 years ago
The thing is I don't use the application to control the drone but only to 
display the image.. Thats why my callback does not have an ARDrone object 
reference.. The current API does not really account for this case and I could 
not use the DroneVideoListener for it (thats why I started a new class in the 
first place). Apparently the drone now supports multicast also for navdata, 
maybe the java API could be made more flexible in that one could use "readers" 
for both kinds of data separate or they get instantiated by an ARDrone object 
like now (mainly its about wrapping calls to the ARDrone in an interface I 
guess).

Original comment by normen667 on 16 May 2011 at 8:05

GoogleCodeExporter commented 8 years ago
I think we should add "passive" mode to our ARDrone API when it listens for 
navdata and video stream on multicast sockets without actually sending any 
commands. User can create ARDrone object passing 'passive' flag to constructor 
and register callbacks to receive navdata events and video stream.

We are working on simple Java UI to show status, and it will also work in 
passive mode.

Original comment by kroko...@gmail.com on 19 May 2011 at 12:13

GoogleCodeExporter commented 8 years ago
That sounds good. I am not really sure how you plan to implement getting 
information from the drone as theres no listener queue for navigation data (it 
basically is only available inside the ARDrone class) but if you plan to 
instantiate everything via the ARDrone class instead of having listeners that 
can be used outside of it then this sounds like the best idea, yeah. I also dig 
the latest moving to queues for I/O stuff, the mutexes seemed to grow to a 
dangerous level ;) I still have problems with the PS3 controller sometimes 
sending no data even though it got inited.. Maybe a threading issue too.. When 
I find out more I'll post another issue.

Original comment by normen667 on 20 May 2011 at 12:36

GoogleCodeExporter commented 8 years ago
Thanks for patches. I will review them and incorporate!

Original comment by kroko...@gmail.com on 22 May 2011 at 2:44

GoogleCodeExporter commented 8 years ago
I tried to use multicastvideoreader for displaying video but I didn't succeed. 
It seems to me, that multicast is not activated by default. Am I missing 
something?

Original comment by kaiplue...@googlemail.com on 17 Jun 2011 at 12:58

GoogleCodeExporter commented 8 years ago
I never get around trying multicast myself. Perhaps original patch submitter 
can help ;)

Original comment by kroko...@gmail.com on 18 Jun 2011 at 4:25

GoogleCodeExporter commented 8 years ago
I am running Miru's RC mod that lets me control the drone by RC controller and 
it works great. When I try to connect with a 3rd party software including 
javadrone, the drone does a force landing. I am on firmware 1.7.11. I just want 
to monitor the video by itself and I think this bit of code is perfect for this.

I tried to compile this java program (I am a c/c++ guy, not a java guy) using 
javac in windows command prompt and I have gotten this far.

C:\Users\X\Downloads\ardrone>"C:\Program Files\Java\jdk1.7.0_02\bin\javac.exe" T
est.java
Test.java:28: error: Test is not abstract and does not override abstract method
frameReceived(int,int,int,int,int[],int,int) in DroneVideoListener
public class Test extends javax.swing.JFrame implements DroneVideoListener {
       ^
Test.java:71: error: method does not override or implement a method from a super
type
    @Override
    ^
C:\Users\X\Downloads\ardrone\src\com\codeminders\ardrone\MulticastVideoReader.ja
va:59: error: method frameReceived in interface DroneVideoListener cannot be app
lied to given types;
                    drone.frameReceived(videoImage);
                         ^
  required: int,int,int,int,int[],int,int
  found: BufferedImage
  reason: actual and formal argument lists differ in length
C:\Users\X\Downloads\ardrone\src\com\codeminders\ardrone\MulticastVideoReader.ja
va:83: error: method frameReceived in interface DroneVideoListener cannot be app
lied to given types;
        drone.frameReceived(errorImage);
             ^
  required: int,int,int,int,int[],int,int
  found: BufferedImage
  reason: actual and formal argument lists differ in length
4 errors

I would greatly appreciate is someone could give me a jar file or tell my why 
this isnt meshing well (java version?)

I just want to be able to see video, and record it if possible, while my RC mod 
does all the controlling. 

Original comment by andrew.f...@gmail.com on 13 Jan 2012 at 2:16

GoogleCodeExporter commented 8 years ago
Hi everyone I've been playing around writing a scala app to fly the drone with 
wiimotes and I was trying to get multicast video to work.  Is this still 
working for anyone?  I've seen some folks talking about multicast issues with 
the latest firmware but I had never tried it on the previous firmware.  I don't 
see any code in the posted example that tells the drone to start sending video.

Does multicast only work if another unicast video consumer has been started?

Original comment by Matt.Sel...@gmail.com on 18 Feb 2012 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by kroko...@gmail.com on 19 Jul 2012 at 6:00

GoogleCodeExporter commented 8 years ago

Original comment by kroko...@gmail.com on 26 Jul 2012 at 5:21