[SOLVED] Trouble Running Basiclog.py

Post here to get support
Post Reply
youngbin1130
Beginner
Posts: 26
Joined: Thu Dec 12, 2019 4:28 am

[SOLVED] Trouble Running Basiclog.py

Post by youngbin1130 » Wed Apr 29, 2020 7:36 am

Hello all,

I wanted to log the real time location of the Crazyflie while running an example code (specifically the motioncommander.py) so I thought looking at the Basiclog.py would be the best way to go about doing it.

However, I've having trouble executing example\Basiclog.py. I've attached the output here.

Code: Select all

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

Loading personal and system profiles took 870ms.
(base) PS D:\DSO-AISwarm\crazyflie-lib> & C:/Users/young/.virtualenvs/DSO-AISwarm-bEK4_JDG/Scripts/Activate.ps1
(base) (DSO-AISwarm) PS D:\DSO-AISwarm\crazyflie-lib> & C:/Users/young/.virtualenvs/DSO-AISwarm-bEK4_JDG/Scripts/python.exe d:/DSO-AISwarm/crazyflie-lib/examples/basiclog.py
Scanning interfaces for Crazyflies...
Crazyflies found:
No Crazyflies found, cannot run example
Traceback (most recent call last):
  File "d:/DSO-AISwarm/crazyflie-lib/examples/basiclog.py", line 142, in <module>
    while le.is_connected:
NameError: name 'le' is not defined
(base) (DSO-AISwarm) PS D:\DSO-AISwarm\crazyflie-lib> & C:/Users/young/.virtualenvs/DSO-AISwarm-bEK4_JDG/Scripts/python.exe d:/DSO-AISwarm/crazyflie-lib/examples/basiclog.py
Scanning interfaces for Crazyflies...
Crazyflies found:
radio://0/80/2M
Connecting to radio://0/80/2M
ERROR:cflib.crazyflie:Couldn't load link driver: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Traceback (most recent call last):
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crazyflie\__init__.py", line 223, in open_link
    link_uri, self._link_quality_cb, self._link_error_cb)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\__init__.py", line 91, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 163, in connect
    address)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 102, in __init__
    _RadioManager._radios[self._devid] = _SharedRadio(self._devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 71, in __init__
    self.radio = Crazyradio(devid=devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\drivers\crazyradio.py", line 140, in __init__
    self.dev.set_configuration(1)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
    _check(_lib.usb_set_configuration(dev_handle, config_value))
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Connection to radio://0/80/2M failed: Couldn't load link driver: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Traceback (most recent call last):
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crazyflie\__init__.py", line 223, in open_link
    link_uri, self._link_quality_cb, self._link_error_cb)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\__init__.py", line 91, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 163, in connect
    address)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 102, in __init__
    _RadioManager._radios[self._devid] = _SharedRadio(self._devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 71, in __init__
    self.radio = Crazyradio(devid=devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\drivers\crazyradio.py", line 140, in __init__
    self.dev.set_configuration(1)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
    _check(_lib.usb_set_configuration(dev_handle, config_value))
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'
This seems really strange because other examples (motion_commander_demo.py, position_commander_demo.py) all work perfectly fine but when I run Basiclog.py and BasiclogSync.py, they both show the same error. I assumed it was the libusb problem and python version problem (from a previous post) so I've reinstalled the libusb with zadig but that didn't fix the problem I'm having.

Another question would be to actually get the positions of the Crazyflie after the kalman filter. I understand that I can log using the Crazyflie Client by adding my own variable (which I wouldn't need to because the client already shows the kalman.stateX,Y,Z). Is there any way for me to bring these variables inside a motion_commander_demo.py?
Last edited by youngbin1130 on Mon May 11, 2020 4:31 am, edited 1 time in total.



kimberly
Bitcraze
Posts: 323
Joined: Fri Jul 06, 2018 11:13 am

Re: Trouble Running Basiclog.py

Post by kimberly » Wed Apr 29, 2020 3:08 pm

Hi!

It seems its not able to find your crazyflie. Which operating system are you running this script on?

If you know the full address of the crazyflie, you can also try to substitute this part of the basiclog.py with

Code: Select all

le = LoggingExample('radio://0/80/2M/E7E7E7E7E7')
(Replace the uri if your address is different)

If this works for you, then maybe the scanning function of the lib is broken in the latest release. So please let us know if this works for you.

youngbin1130
Beginner
Posts: 26
Joined: Thu Dec 12, 2019 4:28 am

Re: Trouble Running Basiclog.py

Post by youngbin1130 » Mon May 04, 2020 7:15 am

Hey Kimberly,

I'm running on Windows 10 currently.

I've tried to replace that line as you suggested but it gives me the same(?) error. I've attache the error here as well.

Code: Select all

Windows PowerShell
Try the new cross-platform PowerShell https://aka.ms/pscore6

Loading personal and system profiles took 558ms.
(base) PS D:\DSO-AISwarm\crazyflie-lib> & C:/Users/young/.virtualenvs/DSO-AISwarm-bEK4_JDG/Scripts/Activate.ps1
(base) (DSO-AISwarm) PS D:\DSO-AISwarm\crazyflie-lib> & C:/Users/young/.virtualenvs/DSO-AISwarm-bEK4_JDG/Scripts/python.exe d:/DSO-AISwarm/crazyflie-lib/examples/basiclog.py
Scanning interfaces for Crazyflies...
Crazyflies found:
radio://0/80/2M
Connecting to radio://0/80/2M/E7E7E7E7E7
ERROR:cflib.crazyflie:Couldn't load link driver: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Traceback (most recent call last):
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crazyflie\__init__.py", line 223, in open_link
    link_uri, self._link_quality_cb, self._link_error_cb)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\__init__.py", line 91, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 163, in connect
    address)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 102, in __init__
    _RadioManager._radios[self._devid] = _SharedRadio(self._devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 71, in __init__
    self.radio = Crazyradio(devid=devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\drivers\crazyradio.py", line 140, in __init__
    self.dev.set_configuration(1)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
    _check(_lib.usb_set_configuration(dev_handle, config_value))
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Connection to radio://0/80/2M/E7E7E7E7E7 failed: Couldn't load link driver: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

Traceback (most recent call last):
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crazyflie\__init__.py", line 223, in open_link
    link_uri, self._link_quality_cb, self._link_error_cb)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\__init__.py", line 91, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 163, in connect
    address)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 102, in __init__
    _RadioManager._radios[self._devid] = _SharedRadio(self._devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\crtp\radiodriver.py", line 71, in __init__
    self.radio = Crazyradio(devid=devid)
  File "d:\dso-aiswarm\crazyflie-lib\cflib\drivers\crazyradio.py", line 140, in __init__
    self.dev.set_configuration(1)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 869, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
    _check(_lib.usb_set_configuration(dev_handle, config_value))
  File "C:\Users\young\.virtualenvs\DSO-AISwarm-bEK4_JDG\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'

kimberly
Bitcraze
Posts: 323
Joined: Fri Jul 06, 2018 11:13 am

Re: Trouble Running Basiclog.py

Post by kimberly » Mon May 04, 2020 9:59 am

I tried this myself on windows 10, and basicLog.py works for me. Currently I'm using cflib version 1.10. Could you check your version with 'pip freeze' and let us know here in this thread?

This is how you can add a logger in motion commander:

Before logging start:

Code: Select all

        
log_config = LogConfig(name='test log', period_in_ms=10)
log_config.add_variable('stateEstimate.x', 'float')
When you want logging to happen:

Code: Select all

        
with SyncLogger(self.cf, log_config) as logger:
    for log_entry in logger:
        data = log_entry[1]
        save_value =data['stateEstimate.x'])
        break

The forloop keeps on looping, so you can also replace the break with an if statement, like this one.

Code: Select all

    if ((time.time() - past_time) > TIME_THRESHOLD):
        break
More doc about this can be found here: https://www.bitcraze.io/documentation/r ... ython_api/

Let us know if you know more about your version of cflib.

youngbin1130
Beginner
Posts: 26
Joined: Thu Dec 12, 2019 4:28 am

Re: Trouble Running Basiclog.py

Post by youngbin1130 » Mon May 04, 2020 10:35 am

Thank you for your reply!

I've used 'pip freeze' but I'm unable to see the version number of cflib. I've attached the result of the result of the command here.

Code: Select all

Microsoft Windows [Version 10.0.18363.778]
(c) 2019 Microsoft Corporation. All rights reserved.

D:\DSO-AISwarm>pip freeze
appdirs==1.4.3
asn1crypto==1.2.0
certifi==2019.9.11
cffi==1.13.0
-e git+https://github.com/youngbin-song/DSO-AISwarm@cc370507460768930fcef837795a94083e6ecc4e#egg=cflib&subdirectory=crazyflie-lib
chardet==3.0.4
conda==4.7.12
conda-package-handling==1.6.0
cryptography==2.8
cx-freeze==6.1
idna==2.8
libusb==1.0.22b8
-e git+https://github.com/bitcraze/lps-tools.git@2aad0d4f8f2d044594e118d7efb19cbbbe14201e#egg=lpstools
menuinst==1.4.16
numpy==1.18.0
pipenv==2018.11.26
pycosat==0.6.3
pycparser==2.19
pyOpenSSL==19.0.0
pypi==2.1
PyQt5==5.10
pyqtgraph==0.10.0
PySDL2==0.9.6
pyserial==3.4
PySocks==1.7.1
pyusb==1.0.2
pywin32==223
PyYAML==5.1.2
pyzmq==18.1.0
qtm==2.0.3
Quamash==0.6.1
requests==2.22.0
ruamel-yaml==0.15.46
sip==4.19.8
six==1.12.0
tqdm==4.36.1
urllib3==1.24.2
vboxapi==1.0
virtualenv==16.7.8
virtualenv-clone==0.5.3
win-inet-pton==1.1.0

kimberly
Bitcraze
Posts: 323
Joined: Fri Jul 06, 2018 11:13 am

Re: Trouble Running Basiclog.py

Post by kimberly » Mon May 04, 2020 10:40 am

It seems that your cflib version comes from this line:

-e git+https://github.com/youngbin-song/DSO-AI ... zyflie-lib

It makes it difficult to figure out what th cflib version is... I don't have access to that link but maybe you can check? It could be that you are working with an old cflib version. In that case it might be better to just go ahead and remove that one and install it the proper way as explained on the readme of https://github.com/bitcraze/crazyflie-lib-python

youngbin1130
Beginner
Posts: 26
Joined: Thu Dec 12, 2019 4:28 am

Re: Trouble Running Basiclog.py

Post by youngbin1130 » Mon May 11, 2020 4:31 am

Hi Kimberly,

That seems to have fixed the issue. Thanks for your help!

Post Reply