Getting started with python scripting

Discussions about quadcopters/multi-rotors
Post Reply
DaGuRu
Beginner
Posts: 15
Joined: Thu Jan 14, 2016 8:25 pm

Getting started with python scripting

Post by DaGuRu »

Hey everyone,

I am trying to get started on a project for the crazyflie 2.0 that I got not to long ago, involving simple python scripts that will control the crazyflie (just a very simple, take off fly forward a bit and land type deal) but I am finding some of the getting started documentation a little confusing. https://wiki.bitcraze.io/doc:crazyflie:dev:env:python this page suggests that I install the client and python dependencies, and once I am done all that I will be able to run the client from the command line, I am assuming I will also be able to run my python scripts for controlling the crazyflie as well ? I made a very quick attempt at trying to get this ramp.py script working from this link(I downloaded the entire project not just the python script) https://github.com/bitcraze/crazyflie-clients-python but I cannot seem to get the ramp.py to run. I was just wondering if anyone out there got this script to run properly/ if anyone can help me get it working.

any tips or advice on how to get started with scripting would really be appreciated !
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Getting started with python scripting

Post by chad »

Hi DaGuRu,

What exactly are you seeing when you try to run the ramp.py script and how exactly are you trying to run it. Specifics on these two points will help to troubleshoot.
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
DaGuRu
Beginner
Posts: 15
Joined: Thu Jan 14, 2016 8:25 pm

Re: Getting started with python scripting

Post by DaGuRu »

After looking into it a little bit more it seems that I am missing some module called usb

File "../src/cflib\cflib\drivers\crazyradio.py", line 34, in <module>
import usb
ImportError: No module named usb

Looking through the project file that I downloaded I can not find any python module called usb, although I do see that there is a cfusb module in the the folder, renaiming that to usb gives a similar error elsewhere

File "../src/cflib\cflib\crtp\radiodriver.py", line 49, in <module>
from usb import USBError
ImportError: No module named usb

it seems like either the "usb" modules were all renamed throughout the project as there is "usbdriver" module in the crtp folder although I am not certain if I am just missing the usb module that is being refereed to/ if pointing the import usb to usbdriver instead is the appropriate fix. I will keep digging and post an update if I figure it out.

edit * I am definitely missing the module "usb" although I am not sure if it is a module that should have been included with the development project from github, or if it is something from the client that I do not have in the proper location.
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Getting started with python scripting

Post by chad »

The missing usb module is likely the dependency pyusb. What OS are you on? I sounds like your dependencies are not fully installed.

Did you use this Read Me to install the dependencies?
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
DaGuRu
Beginner
Posts: 15
Joined: Thu Jan 14, 2016 8:25 pm

Re: Getting started with python scripting

Post by DaGuRu »

I'm working on Windows 10, Going through the process of reinstalling the dependencies to see if i can get it working. Does it matter where I put the source folder? Like for the pip instruction to work does the cf source folder need to be in C:\users\bitcraze for the command C:\Users\bitcraze>\Python34\python.exe -m pip install pyusb==1.0.0b2 pyzmq pysdl2 pyqtgraph to work correctly ?
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Getting started with python scripting

Post by chad »

DaGuRu wrote:I'm working on Windows 10, Going through the process of reinstalling the dependencies to see if i can get it working. Does it matter where I put the source folder? Like for the pip instruction to work does the cf source folder need to be in C:\users\bitcraze for the command C:\Users\bitcraze>\Python34\python.exe -m pip install pyusb==1.0.0b2 pyzmq pysdl2 pyqtgraph to work correctly ?
The pip install is a function of Python. It has nothing to do with the cfclient. It will work correctly regardless of where cfclient is installed or indeed if cfclient doesn't even exist on your machine.
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
DaGuRu
Beginner
Posts: 15
Joined: Thu Jan 14, 2016 8:25 pm

Re: Getting started with python scripting

Post by DaGuRu »

Awsome, seems like I've got things working :) Thanks a tonne Chad you've been super helpful (although i feel a lot of my issues just ended up being stupidity/ rushing through things :P)

A last point I should mention, once i finally installed all the dependencies correctly I still had an issued with the Radio dongle driver not being found by pyusb, switching to libUSBK driver fixed that last issue, now to start flying !
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Getting started with python scripting

Post by chad »

Great to hear you've got things going and I'm to have helped! There is a learning curve and software/hardware interaction can be very complex so don't worry that it took a bit to understand it. There's a lot more to understand too and learning is half the fun!

Good luck and post back when you're doing cool things!
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

Re: Getting started with python scripting

Post by Mitteau »

Hi everybody
I completely agree.
Python-Qt4 is much more involved than C++. And GUI interactions with signals a fascinating domain!
Regards
Jean-Claude
Post Reply