Page 1 of 1

[Solved] Raspberry Pi and PS2 Controller

Posted: Wed Mar 26, 2014 4:31 am
by dboyle
Hey guys,

I've been working on setting up a base station with the raspberry pi, based on all the instructions posted by the community on the website, and this forum. I've successfully been running off battery power, and am using peripherals using a hub. I think I am very close to being able to fly.

I am encountering a problem when I start up the software. Here is the status script that prints to the raspberry pi screen:

Code: Select all

pi@raspberrypi ~ $ python ~/crazyflie-pc-client/bin/cfheadless -i PS_#1 -c 0
Info: Using config path: /home/pi/crazyflie-pc-client/lib/../conf
Info: sys.path= ['/home/pi/crazyflie-pc-client/lib', '/home/pi/crazyflie-pc-client/lib/../conf', '/home/pi/crazyflie-pc-client/bin', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
Disabling standard output for libraries!
INFO:cfclient.utils.config:Dist config read from /home/pi/crazyflie-pc-client/lib/cfclient/configs/config.json
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_2.json]
INFO:cfclient.utils.config_manager:Parsing [xbox360_mode1.json]
INFO:cfclient.utils.config_manager:Parsing [PS_#1.json]
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_3.json]
INFO:cfclient.utils.config_manager:Parsing [Generic_OS_X.json]
INFO:cfclient.utils.config_manager:Parsing [xbox360_mode1_linux.json]
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_1.json]
Will use [Twin USB Joystick] for input
INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/10/250K]
INFO:cflib.crazyflie:We are connected[radio://0/10/250K], request connection setup
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
INFO:cflib.crazyflie:Callback->Connected to [radio://0/10/250K]
ERROR:cflib.crazyflie.toc:Got packet that was not on TOC channel, TOC fetch will probably not succeed
INFO:cflib.crazyflie.toc:TOC for port [5] found in cache
INFO:cflib.crazyflie:Log TOC finished updating
INFO:cflib.crazyflie.toc:TOC for port [2] found in cache
INFO:cflib.crazyflie:Param TOC finished updating
INFO:cflib.crazyflie:Callback->Connection setup finished [radio://0/10/250K]
I believe that I am having a problem with the controller I am using. I'm using a playstation 2 controller, connected to the system using a PS2 to USB converter. For some background, I pilot the crazyflie successfully from my computer, using my own own json file. However, when I first began, I found that my computer recognized two playstation controllers in the device manager. In order to fly the crazyflie, I had to disable the second PS2 controller that my computer was recognizing. I believe my raspberry pi problem is somehow analogous to the problem I had on my computer. That is my best guess. I have done research on how to disable devices recognized by the pi; however they did not produce any significant leads. I might also add, that my controller is recognized by the "joystick" program that I downloaded. All the buttons produce change in numbers when I run "jstest".

I look forward to any suggestions.

Re: Raspberry Pi and PS2 Controller

Posted: Mon Mar 31, 2014 9:17 am
by marcus
Hi,

I've pushed a changeset that enables support for two or more input-devices with the same name. Could you try it and see if it fixes the issue? You will have to change to the Git repo or download our new version of the Raspberry Pi image.

You should also update the firmware to the latest release if you haven't done so already.

/Marcus

Re: Raspberry Pi and PS2 Controller

Posted: Mon Apr 07, 2014 5:08 am
by dboyle
Marcus,

Thanks so much for your help.

I've followed your directions by doing the following:
1. Updated the crazyflie's firmware (on 4/6/2014), by using the PC client on my desktop computer. I successfully booted the new firmware, and tested that the crazyflie flies using my desktop computer.

2. Removed the crazyflie-pc-client folder on my raspberry pi.

3. Executed the following commands in raspberry pi:

Code: Select all

hg clone https://bitbucket.org/bitcraze/crazyflie-pc-client
cd crazyflie-pc-client
hg up dev-headless
I believe this re-installed the crazyflie raspberry pi client.

4. I checked my new crazyflie Raspberry Pi folder, to find the new change you added. I located "mypygamereader.pyc" in the util folder (but leafpad would not open it correctly). Is is supposed to be ".pyc" instead of ".py"?

5. I ran the command to boot up the headless client:

Code: Select all

pi@raspberrypi ~ $ python ~/crazyflie-pc-client/bin/cfheadless -u radio://0/10/250K -i PS_#1
Info: Using config path:  /home/pi/crazyflie-pc-client/lib/../conf
Info: sys.path= ['/home/pi/crazyflie-pc-client/lib', '/home/pi/crazyflie-pc-client/lib/../conf', '/home/pi/crazyflie-pc-client/bin', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
Disabling standard output for libraries!
INFO:cfclient.utils.config:Dist config read from /home/pi/crazyflie-pc-client/lib/cfclient/configs/config.json
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_2.json]
INFO:cfclient.utils.config_manager:Parsing [xbox360_mode1.json]
INFO:cfclient.utils.config_manager:Parsing [PS_#1.json]
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_3.json]
INFO:cfclient.utils.config_manager:Parsing [Generic_OS_X.json]
INFO:cfclient.utils.config_manager:Parsing [xbox360_mode1_linux.json]
INFO:cfclient.utils.config_manager:Parsing [PS3_Mode_1.json]
Will use [Twin USB Joystick] for input
INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/10/250K]
INFO:cflib.crazyflie:We are connected[radio://0/10/250K], request connection setup
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
WARNING:cflib.crazyflie:ExpectAnswer: ERROR! Older timer whas running while scheduling new one on [5]
INFO:cflib.crazyflie:Callback->Connected to [radio://0/10/250K]
ERROR:cflib.crazyflie.toc:Got packet that was not on TOC channel, TOC fetch will probably not succeed
INFO:cflib.crazyflie.toc:TOC for port [5] found in cache
INFO:cflib.crazyflie:Log TOC finished updating
INFO:cflib.crazyflie.toc:TOC for port [2] found in cache
INFO:cflib.crazyflie:Param TOC finished updating
INFO:cflib.crazyflie:Callback->Connection setup finished [radio://0/10/250K]
It appears that I am having the same problem. Perhaps you could explain what the new pygame file is performing? Please let me know if I missed a step in my procedure.

Thanks again for your help,

Dylan

Re: Raspberry Pi and PS2 Controller

Posted: Mon Apr 07, 2014 8:30 am
by marcus
Hi Dylan,

We have moved our code from BitBucket to GitHub, the BitBucket repos are just acting as a read-only reference for old forum-posts etc, so they do not contain this change. Could you try pulling the client that's on GitHub instead using the following commands:

Code: Select all

git clone https://github.com/bitcraze/crazyflie-clients-python.git
cd crazyflie-clients-python

Re: Raspberry Pi and PS2 Controller

Posted: Tue Apr 08, 2014 3:22 am
by dboyle
Hi Marcus,

Thanks so much! This worked! I now have my base station fully operational :)

I'm able to fly using the raspberry pi, running off a usb battery pack and a usb hub.

I'm going to begin experimenting with ways to initialize the radio link without connecting the pi to a monitor.

Dylan