Giter Site home page Giter Site logo

simondlevy / ardroneautopylot Goto Github PK

View Code? Open in Web Editor NEW
43.0 43.0 29.0 55 MB

Auto-Pilot the Parrot AR.Drone from Python (or Matlab or C)

Home Page: http://home.wlu.edu/~levys/software/ardrone_autopylot/

License: GNU Lesser General Public License v3.0

C 72.25% MATLAB 0.01% Python 0.02% Makefile 17.13% C++ 0.54% Shell 0.21% Perl 0.10% Assembly 3.46% Objective-C 6.12% Verilog 0.01% CSS 0.03% HTML 0.14%

ardroneautopylot's People

Contributors

simondlevy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ardroneautopylot's Issues

Failure when trying to integrate the code with ROS

Hi!

I am trying to publish camera frames into a ROStopic, so I modified autopylot_agent.py as you can see below:

import numpy as np
import cv2
import rospy
from sensor_msgs.msg import Image
import cv_bridge

rospy.init_node('dron_camera')
pub = rospy.Publisher('frame', Image,queue=10)
bridge = cv_bridge.CVBridge()

def action(img_bytes, img_width, img_height, is_belly, \
    ctrl_state, vbat_flying_percentage, theta, phi, psi, altitude, vx, vy):

    # Report navigation data
    print('ctrl state=%6d battery=%2d%% theta=%+f phi=%+f psi=%+f altitude=%+3d vx=%f vy=%+f' % \
                          (ctrl_state, vbat_flying_percentage, theta, phi, psi, altitude, vx, vy))

    # Create full-color image from bytes
    image_cv = np.frombuffer(img_bytes, np.uint8)
    image_cv = np.ndarray.reshape(image_cv, (img_height, img_width, 3))
    image_ros = bridge.cv2_to_msgimg(image_cv)
    pub.publish(image_ros)
    

    #cv2.imshow('frame', image_cv)
    #cv2.waitKey(3)

    # Set up commands for a clockwise turn
    zap = 0
    phi = 0 
    theta = 0 
    gaz = 0 
    yaw = 1

    return (zap, phi, theta, gaz, yaw)

And got this error:

dave@dave:~/catkin_ws/ARDroneAutoPylot$ ./ardrone_autopylot
Setting locale to en_GB.UTF-8
===================+> 192.168.1.1
Input device Sony PLAYSTATION(R)3 Controller found
Input device js2 added
Starting thread video_stage
Set IP_TOS ok
Starting thread navdata_update
Starting thread ardrone_control
PA : MEMORY SPACE ALLOWED : 40 MB
Start thread thread_academy_upload
Start thread thread_academy
Start thread thread_academy_download 
Academy download stage resumed
Thread navdata_update in progress...

video stage thread initialisation

Video multisocket : init 2 sockets
Video multisocket : connecting socket 0 on port 5555 UDP
Video multisocket : connecting socket 1 on port 5555 TCP
Traceback (most recent call last):
  File "/home/dave/catkin_ws/ARDroneAutoPylot/autopylot_agent.py", line 24, in <module>
    import rospy
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/__init__.py", line 49, in <module>
    from .client import spin, myargv, init_node, \
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/client.py", line 54, in <module>
    import rospy.core
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/core.py", line 71, in <module>
    from rospy.names import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/names.py", line 86, in <module>
    _mappings = load_mappings(sys.argv)
AttributeError: 'module' object has no attribute 'argv'

I tried to fix it adding PySys_SetArgv(argc, argv); in autopylot_python_agent.c just before Py_Initialize(); also I have also added int argc, char **argv as arguements of the fuction agent init

void agent_init(int argc, char **argv)
{
		
	PySys_SetArgv(argc, argv);

	Py_Initialize();
	
	PyObject * pName = PyString_FromString(AGENT_MODULE_NAME);
	
	pModule = PyImport_Import(pName);
	
	Py_DECREF(pName);

but that did not solve the problem:


dave@dave:~/catkin_ws/ARDroneAutoPylot$ ./ardrone_autopylot
Setting locale to en_GB.UTF-8
===================+> 192.168.1.1
Input device Sony PLAYSTATION(R)3 Controller found
Input device js2 added
Starting thread video_stage
Set IP_TOS ok
Starting thread navdata_update
Starting thread ardrone_control
PA : MEMORY SPACE ALLOWED : 40 MB
Start thread thread_academy_upload
Start thread thread_academy
Start thread thread_academy_download 
Academy download stage resumed
Thread navdata_update in progress...

video stage thread initialisation

Video multisocket : init 2 sockets
Video multisocket : connecting socket 0 on port 5555 UDP
Video multisocket : connecting socket 1 on port 5555 TCP
Segmentation fault (core dumped)

Could you help me with that? Have you tried this before? I do not know what that arguments (argc and argv) are. Any comment/idea is more than welcome.

Thanks in advance for your help,

David

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.