[SOLVED] Cannot connect in ramp.py example.

Post here to get support
Post Reply
Bumbolt
Beginner
Posts: 16
Joined: Tue Feb 18, 2014 10:53 pm

[SOLVED] Cannot connect in ramp.py example.

Post by Bumbolt »

I'm trying to run the ramp.py example code from the github page. I get the following errors (script prints error to so traceback is double)

Code: Select all

C:\python27_x64\python.exe "C:/Users/Recl/Dropbox/KaHo/Erasmus+/Courses FHD/Projektarbeit/Crazyflie API/crazyflie-clients-python/examples/ramp.py"
Scanning interfaces for Crazyflies...
Crazyflies found:
radio://0/10/250K
ERROR:cflib.crazyflie:Couldn't load link driver: Cannot find a Crazyradio Dongle

Traceback (most recent call last):
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crazyflie\__init__.py", line 206, in open_link
    self._link_error_cb)
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crtp\__init__.py", line 89, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crtp\radiodriver.py", line 106, in connect
    self.cradio = Crazyradio(devid=int(uri_data.group(1)))
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\drivers\crazyradio.py", line 116, in __init__
    raise Exception("Cannot find a Crazyradio Dongle")
Exception: Cannot find a Crazyradio Dongle

Connection to radio://0/10/250K failed: Couldn't load link driver: Cannot find a Crazyradio Dongle

Traceback (most recent call last):
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crazyflie\__init__.py", line 206, in open_link
    self._link_error_cb)
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crtp\__init__.py", line 89, in get_link_driver
    instance.connect(uri, link_quality_callback, link_error_callback)
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\crtp\radiodriver.py", line 106, in connect
    self.cradio = Crazyradio(devid=int(uri_data.group(1)))
  File "C:\Users\Recl\Dropbox\KaHo\Erasmus+\Courses FHD\Projektarbeit\Crazyflie API\crazyflie-clients-python\lib\cflib\drivers\crazyradio.py", line 116, in __init__
    raise Exception("Cannot find a Crazyradio Dongle")
Exception: Cannot find a Crazyradio Dongle

Connecting to radio://0/10/250K

Process finished with exit code 0
So he says he can't find the driver so I tried reinstalling the driver without result. The weird think is that I can connect with the crazyflie client and read the gyro so the driver must be working.

Also the code detect the crazyflie and when I power off the crazyflie the code says 'no crazyflies found'. All proof that the crazyflie is working.

I'm using win7 with libusb0 (libusb-win32 installed with zadig).
Last edited by Bumbolt on Fri Oct 03, 2014 9:03 am, edited 1 time in total.
Bumbolt
Beginner
Posts: 16
Joined: Tue Feb 18, 2014 10:53 pm

Re: Cannot connect in ramp.py example.

Post by Bumbolt »

UPDATE:

I'm using pycharm as an IDE. I added a breakpoint on init of the crazyradio. By then stepping trough the ramp.py example I was able to let the crazyflie ramp up.

Hanging on to this idea what happens is that the crazyradio init doesn't wait long enough for the response of the devices scan. Then I modified the code of crazyradio.py:

Code: Select all

def __init__(self, device=None, devid=0):
        """ Create object and scan for USB dongle if no device is supplied """
        if device is None:
            try:
                time.sleep(0.25)
                device = _find_devices()[devid]
            except Exception:
                raise Exception("Cannot find a Crazyradio Dongle")

        self.dev = device
...
I played around a little with the duration of the delay and it seems that 250ms is a good delay to go by for my system.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: [SOLVED] Cannot connect in ramp.py example.

Post by tobias »

That is a bit strange and nothing we seen before. Some USB timing issue maybe?
MikeWise1618
Beginner
Posts: 6
Joined: Sun May 22, 2016 9:02 am

Re: [SOLVED] Cannot connect in ramp.py example.

Post by MikeWise1618 »

I had this problem but didn't want to mod the cflib. So inspired by the above I found adding a sleep after scan_interfaces in ramp.py fixed this for me without cflib modificat. Added another sleep after the test to keep it from failing if I start it again too soon.

Like this:

Code: Select all

    
    
if __name__ == '__main__':
    # Initialize the low-level drivers (don't list the debug drivers)
    cflib.crtp.init_drivers(enable_debug_driver=False)
    # Scan for Crazyflies and use the first one found

    print('Scanning interfaces for Crazyflies...')
    available = cflib.crtp.scan_interfaces()
    time.sleep(0.25)
    print('Crazyflies found:')   
    for i in available:
        print(i[0])
    if len(available) > 0:
        le = MotorRampExample(available[0][0])
        time.sleep(0.25)
    else:
        print('No Crazyflies found, cannot run example')
    
    
ricardo.halfeld
Beginner
Posts: 24
Joined: Tue May 22, 2018 1:40 pm

Re: Cannot connect in ramp.py example.

Post by ricardo.halfeld »

Bumbolt wrote: Thu Oct 02, 2014 8:09 pm I played around a little with the duration of the delay and it seems that 250ms is a good delay to go by for my system.
I had the same issue with https://github.com/bitcraze/crazyflie-l ... logSync.py and applied the same solution successfully. I used the same delay. Thanks!
Post Reply