Page 2 of 3

Re: Beginner Question

Posted: Tue Nov 19, 2019 10:17 am
by arnaud
The python code you are writing is not sent to the Crazyflie, it controls the Crazyflie.

It would be much more easier if you could tell us the step at which you are blocked and the exact error message you are getting, otherwise I have to try guessing which might not be so helpful if I happen not guessing right.

So I am guessing you are having connection issues because you are not using the right URI to connect the Crazyflie. When connecting with the client, you can see the current URI of your Crazyflie on the left of the "Connect" button, it should be something like "radio://0/80/2M". You should use the same URI when using the script to connect your Crazyflie. If things works, the LEDs on the Crazyradio should mostly blink Green and the front left (M4) LED on your Crazyflie should light-up.

Re: Beginner Question

Posted: Tue Nov 19, 2019 8:58 pm
by artistofcannae
I apologize the issue was very stupid I had connected the VM to a drone initially then when the battery died I plugged a new one into my other drone (My mistake is glaringly obvious now) and I forgot to reconnect the new one.


Okay, now there is one new issue:

This comes from when I try to set control the drone with the python code this error comes up:


Connecting to radio://0/80/250K
ERROR:cflib.crazyflie:Couldn't load link driver: [Errno 16] Resource busy

Traceback (most recent call last):
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/__init__.py", line 223, in open_link
link_uri, self._link_quality_cb, self._link_error_cb)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/__init__.py", line 91, in get_link_driver
instance.connect(uri, link_quality_callback, link_error_callback)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 163, in connect
address)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 102, in __init__
_RadioManager._radios[self._devid] = _SharedRadio(self._devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 71, in __init__
self.radio = Crazyradio(devid=devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/drivers/crazyradio.py", line 140, in __init__
self.dev.set_configuration(1)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 794, in set_configuration
_check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy

Connection to radio://0/80/250K failed: Couldn't load link driver: [Errno 16] Resource busy

Traceback (most recent call last):
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/__init__.py", line 223, in open_link
link_uri, self._link_quality_cb, self._link_error_cb)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/__init__.py", line 91, in get_link_driver
instance.connect(uri, link_quality_callback, link_error_callback)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 163, in connect
address)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 102, in __init__
_RadioManager._radios[self._devid] = _SharedRadio(self._devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 71, in __init__
self.radio = Crazyradio(devid=devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/drivers/crazyradio.py", line 140, in __init__
self.dev.set_configuration(1)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 794, in set_configuration
_check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy

Traceback (most recent call last):
File "/home/bitcraze/try2.py", line 24, in <module>
with SyncCrazyflie(URI) as scf:
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 67, in __enter__
self.open_link()
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 64, in open_link
raise Exception(self._error_message)
Exception: Couldn't load link driver: [Errno 16] Resource busy

Traceback (most recent call last):
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/__init__.py", line 223, in open_link
link_uri, self._link_quality_cb, self._link_error_cb)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/__init__.py", line 91, in get_link_driver
instance.connect(uri, link_quality_callback, link_error_callback)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 163, in connect
address)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 102, in __init__
_RadioManager._radios[self._devid] = _SharedRadio(self._devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crtp/radiodriver.py", line 71, in __init__
self.radio = Crazyradio(devid=devid)
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/drivers/crazyradio.py", line 140, in __init__
self.dev.set_configuration(1)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 794, in set_configuration
_check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
File "/home/bitcraze/.local/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy

Re: Beginner Question

Posted: Tue Nov 19, 2019 9:00 pm
by artistofcannae
I am running the VM on a computer running linux. I did not think I would need any driver. am I wrong?

Re: Beginner Question

Posted: Thu Nov 21, 2019 7:17 am
by arnaud
No worry, there is no stupid mistakes we are just always learning :-).

Thanks for the log! I think this error might be due to the client currently being connected to the Crazyflie and so using the radio: the radio cannot be used by more than one program at a time so its either the client either your script. You then need to disconnect the client.

As a side note, If your Crazyflie is currently at datarate 250K, I suggest you connect it with the client, go to "connect/configure 2.x" and change the datarate to 2M. The URI will become "radio://0/80/2M" and the radio performance will be better.

Re: Beginner Question

Posted: Fri Nov 22, 2019 9:28 pm
by artistofcannae
Hi,

So I change the datarate to 2M but when I retried to send the python commands it failed.


Connecting to radio://0/80/250K
Connection to radio://0/80/250K failed: Too many packets lost
Traceback (most recent call last):
File "/home/bitcraze/try2.py", line 24, in <module>
with SyncCrazyflie(URI) as scf:
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 67, in __enter__
self.open_link()
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 64, in open_link
raise Exception(self._error_message)
Exception: Too many packets lost

Also as you can see it still has the data rate to 250 even though i set it to 2M.

Re: Beginner Question

Posted: Fri Nov 22, 2019 9:56 pm
by artistofcannae
Also when I connect the crazyflie to the client it recognizes that it's 2M.

Re: Beginner Question

Posted: Sun Nov 24, 2019 3:08 am
by artistofcannae
actually now that I am looking at it in more detail I am realizing that I might not have exactly changed the right thing.

I changed the bandwidth and not the data rate. I will take a look again right now.

Re: Beginner Question

Posted: Sun Nov 24, 2019 3:10 am
by artistofcannae
I am looking at it more and in connect tab under configure 2.x there is no data rate just:

- pitch trim
- roll trim
- radio channel
- radio bandwith
-radio address

am I looking in the wrong place?

Re: Beginner Question

Posted: Mon Nov 25, 2019 1:39 pm
by arnaud
Radio bandwidth is the datarate. It can be 250K, 1M and 2M. 2M is the preferred setting.

Re: Beginner Question

Posted: Mon Nov 25, 2019 2:04 pm
by artistofcannae
okay, but the setting is currently on 2M which is recognized by the client. But when I try with the python program it thinks the radio bandwidth is 250K


Connecting to radio://0/80/250K
Connection to radio://0/80/250K failed: Too many packets lost
Traceback (most recent call last):
File "/home/bitcraze/try2.py", line 24, in <module>
with SyncCrazyflie(URI) as scf:
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 67, in __enter__
self.open_link()
File "/home/bitcraze/.local/lib/python3.6/site-packages/cflib/crazyflie/syncCrazyflie.py", line 64, in open_link
raise Exception(self._error_message)
Exception: Too many packets lost