Page 1 of 1

[Solved] Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Fri Dec 20, 2019 3:25 pm
by kitz
Hey guys,
So we have a problem where our Crazyflie 2.1 keeps suddenly rotating frantically and subsequently crashing every time it reaches a certain accumulated Yaw-Angle, we were able to pinpoint that this happens at about one and a half full rotations or 3*Pi.
We made the Crazyflie fly the exact same path both with Bezier-Trajectories as well as go_to-commands from the high level commander, happens in both cases.
We're using the Lighthouse positioning System and sending commands to the Crazyflie via CrazyRadio-Dongle from python-scripts.
Our specific use case requires our Crazyflies to travel around in a square or circle around a center-point, all the while facing the center. This only works, as far as we were able to understand, if we continuously increase the yaw-angle. If the yaw-angle is at 2*Pi + Pi/4 (405 Degrees), which would be facing the same direction as Pi/4 (45 Degrees), and we'd set it to Pi/4 the Crazyflie would do a full left-rotation to "get back" to that same angle, so we can't really do that.
We were thinking that maybe some variable in the cflib or firmware is overflowing but it seems weird that this would happen after only one and a half full rotations...
Does anybody have an idea?

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Mon Dec 23, 2019 10:50 am
by kimberly
Hi,

Could you let us know which versions of the cflib and crazyflie-firmware you are using?

(btw, due to the holidays we might be slower to respond to your post. )

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Wed Dec 25, 2019 1:02 pm
by kitz
Hi kimberly,

The firmware was installed by someone else, who is currently on vacation. I've written to him, but don't expect an answer. Is there a way to take one of the 6 Crazyflies I have in possession with me now and check which version was installed?

The version of cflib I am using is 0.1.8.

Please confirm this was the correct way of checking:

$ pip3 list
Package Version Location
----------------- ----------- --------------------------------------
cflib 0.1.8 /usr/local/lib/python3.7/site-packages

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Fri Dec 27, 2019 11:08 am
by kimberly
It seems that the cflib is already the newest version. You can check the version of the crazyflie firmware if you connect to one and look at the console tab at the output. You can copy past it here if you are not sure.

About tje bezier curves, it quite a new functionality so it might be that you have hit a corner case that we haven't touched before. I will also ask the @kristoffer to look at this problem.

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Fri Dec 27, 2019 11:24 am
by kristoffer
Not sure what happens. We can compare to the spiral that we fly in the ICRA/IROS demos where we yaw all the time without problems.
We made the Crazyflie fly the exact same path both with Bezier-Trajectories as well as go_to-commands from the high level commander, happens in both cases.
Makes sense since the goto function simply generates short trajectories that are played in the same way as the bezier-trajectories.

Have you tried to yaw the other direction to see if you get the same problem?

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Tue Jan 07, 2020 10:09 am
by kitz
Here is the information about the firmware I was able to extract from console tab while connected to my Crazyflie 2.1 (Drone 04):

SYS: Crazyflie 2.1 is up and running!
SYS: Build 77:7d344cde570 (2019.09 +77) MODIFIED
SYS: I am 0x20373357594B5008002E0024 and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
DECK_CORE: 1 deck(s) found
DECK_CORE: Calling INIT on driver bcLighthouse4 for deck 0
IMU: BMI088 Gyro I2C connection [OK].
IMU: BMI088 Accel I2C connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Kalman (2) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
EEPROM: I2C connection [OK].
STAB: Wait for sensor calibration...
SYS: Free heap: 6616 bytes
LH: Lighthouse bootloader version: 2
STAB: Ready to fly.
LH: Firmware version 2 verified, booting deck!
LH: Synchronized!
Got calibration from 0080B76D
phase0: 0.006618
phase1: 0.006195
Got calibration from 187CFC03
phase0: 0.008850
phase1: -0.053009

I assume it says "modified" because of the Lighthouse updates.

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Wed Jan 08, 2020 12:41 pm
by kristoffer
Is it possible for you to provide a python script that reproduces the problem? Preferably as simple as possible :-)

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Sat Jan 11, 2020 5:33 pm
by kitz
Alright, so we found and fixed the problem.
kristoffer wrote:
Fri Dec 27, 2019 11:24 am
Have you tried to yaw the other direction to see if you get the same problem?
We took an older version of the autonomous_sequence_high_level.py script and had the drone fly counter-clockwise around the center and had the drone yaw counter-clockwise and it worked! (In December, we were having problems doing the mirror version of this: flying clockwise around the center and simultaneously yawing clockwise, so that the head was always facing the center.)

Then we compared the script which worked to the script in December which did not work and we looked for other differences besides the clockwise/counter-clockwise flight and besides the clockwise/counter-clockwise yawing.

We found three differences and ran tests:
  • The Height:

    Code: Select all

         commander.takeoff(1.0, 2.0)
    versus

    Code: Select all

         commander.takeoff(0.3, 2.0)
    The altitude of 30cm versus 1m had no effect, as expected.
  • The Order:
    In one script, commands were called in one order:

    Code: Select all

            activate_mellinger_controller(cf)
            reset_estimator(cf)
    
    while in the other script, these two commands were called in the reverse order:

    Code: Select all

            reset_estimator(cf)
            activate_mellinger_controller(cf)
    
    We ran tests with only this change and the order of these commands being called also seemed to have no effect on success or failure.
  • However,:

    Code: Select all

         cf.param.set_value('stabilizer.controller', '1')
    versus

    Code: Select all

         cf.param.set_value('stabilizer.controller', '2')
    definitely revealed a difference in behavior in regards to the YAW.

    When set to '2', the Crazyflie has no problem yawing infinitely (or at least up to 10 rounds) in either direction. But when set to '1', the PID-Controller is activated instead of the Mellinger Controller and that's when we see the Crazyflie behaving oddly after 1.5 yaw rotations.
There is a second part to the problem that we have not yet figured out. The drones seem to try and "unwind" from their accumulated large yaw angle when they land at the end of our routine. This means they still rotate frantically and crash-land, but at least the crash now happens at the very end.

Do you want a video and the accompanying python script?

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Wed Jan 15, 2020 10:45 am
by kristoffer
It seems as you have hit two issues at the same time.

The unwinding part is a feature of the high level commander, it is designed to rotate to yaw=0 at take off and landing. This is maybe a behaviour that we want to change and I created an issue for it https://github.com/bitcraze/crazyflie-f ... issues/532

As you have noted, there also seems to be a problem with the PID controller when you go to yaw > 2 * pi. I created an issue for this as well https://github.com/bitcraze/crazyflie-f ... issues/533

Thanks!

Re: Crazyflie 2.1 rotating frantically and crashing at specific Yaw-Angle

Posted: Thu Jan 23, 2020 3:02 pm
by kristoffer
This should now be fixed. You need to update the Crazyflie firmware as well as the python lib to make it work.

I have added an optional yaw parameter in the takeoff() and land() methods. If set it to an angle (in radians), the Crazyflie will yaw to that angle during takeoff/land. If set to None, it will use the current yaw of the Crazyflie. If not set at all it will use the old behaviour, yaw=0

The changes are implemented in:
https://github.com/bitcraze/crazyflie-f ... issues/532
https://github.com/bitcraze/crazyflie-l ... issues/134
https://github.com/bitcraze/crazyflie-f ... issues/533