[SOLVED] Fully disconnect CrazyFlie after link has been released.

Post here to get support
Post Reply
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

[SOLVED] Fully disconnect CrazyFlie after link has been released.

Post by aesreal »

Hi all,

I'm having a timeout issue here where my crazyflie does not seem to be fully disconnected if I were to link to it via: self.cf.open_link(uri). This is in a class and self.cf = Crazyflie(rw_cache='./cache').

This happens when I'm using ROS after Python commands.

This issue mainly occurs when mixing up both crazyflie-lib and crazyflie-ros, to control the crazyflie. Why mixed? Because there are some commands that is available in one package, but not the other. I am not yet at the level where I know how to add in new functions either.

The following describes the scenarios:

1) I start out by using crazyflie-ros commands such as:

Code: Select all

rosrun crazyflie_tools reboot --uri uri
rosrun crazyflie_tools battery --uri uri
These can run multiple times, no problems. Afterwards, Python commands would be run instead, such as establishing a connection with the crazyflie.

Code: Select all

self.cf.open_link(uri)
self.cf.param.set_value('full_param_path', 'value_for_param')
self.cf.close_link()
These can all also be carried out, no problems. The crazyflie gets updated with the new parameters too.

2) Now the problem comes when after scenario 1 is done, and I get the callback from the script saying that the crazyflie has been disconnected via self.cf.close_link(), I try running ros commands again, such as

Code: Select all

rosrun crazyflie_tools reboot --uri uri
rosrun crazyflie_tools battery --uri uri
I would only get a 'timeout' for both commands.

Here, I tried
-Unplugging the crazyradio and replugging, result: same issue
-Running a script which resets the crazyradio usb via bus and device number, result: same issue
-Restarting the crazyflie manually, result: issue resolved.

3) If I were to run the Python commands:

Code: Select all

self.cf.open_link(uri)
self.cf.param.set_value('full_param_path', 'value_for_param')
self.cf.close_link()
And afterwards, I run the above same commands again, everything works fine, no problems here too.

So the only issue comes in scenario 2.

Can anyone help me with this? I suspect that the crazyflie does not fully disconnect when self.cf.close_link() is run, and is instead on some sort of a 'standby' mode?
Last edited by aesreal on Fri Jun 29, 2018 3:34 am, edited 2 times in total.
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by whoenig »

I think this might be related to a bug I recently fixed in crazyflie_cpp. Essentially, the python-lib enables a mode called "safelink" but crazyflie_ros wasn't using this mode so far. Once you use the python-lib "safelink" is activated, which causes the ROS-mode to not work. During boot-up the CF resets to not use "safelink", this is why it works after a reboot.

To fix it, you need to update crazyflie_cpp, to include at least this commit. In crazyflie_ros, you can simply go to the crazyflie_cpp folder and do a git pull to achieve that.
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by aesreal »

Thanks Wolfgang!

Only thing extra I had to do is to cd into the folder and do a "git pull origin master" before remaking the workspace

The newest commit did the trick for most commands, but for "sysOff" and "reboot" they are still not working. Battery, version, flash (stm and nrf) are all confirmed working well!
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by whoenig »

Great - thanks for the feedback!

For "sysOff" and "reboot" is that related to this issue, i.e. does it just not work for you if you use the python client in between? Or is that a general issue with the new version?
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by aesreal »

It is not related to the issue. They were originally working fine, but after the new version they just stopped working for me. Now I can't mass restart or switch off the CFs.
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by whoenig »

I was able to reproduce that issue. I do have a workaround, but I believe a proper fix will need to go into the NRF51 firmware. This is related to viewtopic.php?f=2&t=3061.

Edit: PR is here. This fixes the issue for crazyflie_ros without any additional changes in crazyflie_cpp.
aesreal
Beginner
Posts: 22
Joined: Thu Mar 08, 2018 6:34 am

Re: Fully disconnect CrazyFlie after link has been released.

Post by aesreal »

Thank you! The new firmware fixes the issues. Reboot and sysOff are now working again.
Post Reply