afq984 / pyardrone

Parrot AR.Drone client library for Python 3
http://afq984.github.io/pyardrone/
MIT License
32 stars 5 forks source link

Unable to get the example work #18

Closed KranthiGV closed 7 years ago

KranthiGV commented 7 years ago

Hello, I'm trying to run it control a Parrot AR Drone on a tum simulator (using ROS) on Ubuntu 14.04. The method _drone.navdataready.wait() is not returning and takeoff and land methods are not affecting the drone in the simulator as well.

The following commands seem to work though from the terminal rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}

Thank you!

PING: @afg984

KranthiGV commented 7 years ago

I believe this is because of the host and port number misconfigurations. Any suggestions on where to find the info would be helpful. I am not able to see anything in the log. LOG FILE:

    [rospy.client][INFO] 2017-05-20 16:33:16,973: init_node, name[/spawn_robot], pid[13482]
[xmlrpc][INFO] 2017-05-20 16:33:16,973: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2017-05-20 16:33:16,974: Started XML-RPC server [http://bismithblac:42844/]
[rospy.init][INFO] 2017-05-20 16:33:16,974: ROS Slave URI: [http://bismithblac:42844/]
[rospy.impl.masterslave][INFO] 2017-05-20 16:33:16,974: _ready: http://bismithblac:42844/
[rospy.registration][INFO] 2017-05-20 16:33:16,975: Registering with master node http://localhost:11311
[xmlrpc][INFO] 2017-05-20 16:33:16,975: xml rpc node: starting XML-RPC server
[rospy.init][INFO] 2017-05-20 16:33:17,074: registered with master
[rospy.rosout][INFO] 2017-05-20 16:33:17,075: initializing /rosout core topic
[rospy.rosout][INFO] 2017-05-20 16:33:17,079: connected to core topic /rosout
[rospy.simtime][INFO] 2017-05-20 16:33:17,082: initializing /clock core topic
[rospy.simtime][INFO] 2017-05-20 16:33:17,085: connected to core topic /clock
[rosout][INFO] 2017-05-20 16:33:17,090: Loading model xml from ros parameter
[rosout][INFO] 2017-05-20 16:33:17,095: Waiting for service /gazebo/spawn_urdf_model
[rospy.internal][INFO] 2017-05-20 16:33:17,216: topic[/rosout] adding connection to [/rosout], count 0
[rospy.internal][INFO] 2017-05-20 16:33:17,555: topic[/clock] adding connection to [http://bismithblac:36270/], count 0
[rosout][INFO] 2017-05-20 16:33:17,700: Calling service /gazebo/spawn_urdf_model
[rosout][INFO] 2017-05-20 16:33:17,706: Spawn status: SpawnModel: Model pushed to spawn queue, but spawn service timed out waiting for model to appear in simulation under the name quadrotor
[rospy.core][INFO] 2017-05-20 16:33:17,707: signal_shutdown [atexit]
[rospy.internal][INFO] 2017-05-20 16:33:17,710: topic[/rosout] removing connection to /rosout
[rospy.internal][INFO] 2017-05-20 16:33:17,710: topic[/clock] removing connection to http://bismithblac:36270/
[rospy.impl.masterslave][INFO] 2017-05-20 16:33:17,710: atexit
afq984 commented 7 years ago

In pyardrone, the host and ports of ARDrone can be configured from ARDrone.__init__.

However, by looking the illustration here, I don't think the simulator supports controlling from a network connection. image

KranthiGV commented 7 years ago

I see.. I'll try to see if there's a way around. I'll update you with the same, if I find any. Thanks for your prompt reply.

UPDATE: Can we see simulator support from you anytime soon? :smile:

KranthiGV commented 7 years ago

It worked amazingly on the drone. However I'm not able to receive video feed. The method client.video_ready.wait() returned but client.frame yielded an error

INFO:pyardrone.video:Selected free udp port 49176
INFO:pyardrone.video:initiated VideoCapture at port 49176
INFO:pyardrone.video:Connected to video port 192.168.1.1
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/travis/miniconda/conda-bld/conda_1485299292920/work/opencv-3.2.0/modules/highgui/src/window.cpp, line 304
Traceback (most recent call last):
  File "video_client.py", line 17, in <module>
    cv2.imshow('im', client.frame)
cv2.error: /home/travis/miniconda/conda-bld/conda_1485299292920/work/opencv-3.2.0/modules/highgui/src/window.cpp:304: error: (-215) size.width>0 && size.height>0 in function imshow

PING: @afg984

afq984 commented 7 years ago

I don't think controlling simulator is possible unless the simulator implements the network protocol that ARDrone uses.

For the video issue, try to use ffmpeg to play the video directly from:

And see if the issue resides on the library or the drone.

cas2406 commented 7 years ago

I think the issue is that the parrot ar switched to tcp instead of udp for the video link. And the library still uses udp for the video link, see line 112 'udp://localhost:{port}'.format(port=self.redirect_port)

KranthiGV commented 7 years ago

Thank you, @afg984 and @cas2406. I'll test both of them today and update you with the results. :smile:

afq984 commented 7 years ago

My bad, pyardrone actually uses TCP to connect to the drone, but uses udp as internal connection (see https://github.com/afg984/pyardrone/blob/master/pyardrone/video.py#L97)

The data flows as: parrot Ardrine =TCP=> pyardrone =UDP=> opencv

The purpose to add an additional layer here is to remove the headers that ARDrone adds in the video stream.

Hope this clears things up

KranthiGV commented 7 years ago

@afg984 I have identified the issue. My installation of OpenCV doesn't support FFMPEG. That is the issue. It would work fine if I compile it WITH_FFMPEG flag of OpenCV ON. Thank you so much for assisting me patiently. I'm closing the issue now.