bitcraze / crazyflie-firmware

The main firmware for the Crazyflie Nano Quadcopter, Crazyflie Bolt Quadcopter and Roadrunner Positioning Tag.
GNU General Public License v3.0
1.15k stars 1.04k forks source link

Velocity setpoints do not work with the Lighthouse #462

Closed krichardsson closed 5 years ago

krichardsson commented 5 years ago

There seems to be some sort of problem when using velocity setpoints together with the lighthouse positioning system.

The behaviour is fairly random and it seems to drift in any direction.

When using position hold in the python client (that uses velocity setpoints), the CF takes off in some direction.

krichardsson commented 5 years ago

It turned out that I had messed up my firmware and it seems to work as expected with latest from master.

@NicksonYap can you reproduce this problem?

NicksonYap commented 5 years ago

@krichardsson

Is this the same issue as when using Xbox 360 and CFclient to control the CF in position hold mode using lighthouse?

Or is just plainly using python lib to do a velocity set point

krichardsson commented 5 years ago

@NicksonYap When flying in position hold mode in the CF client, we send velocity setpoints to the CF, so it should be pretty much the same thing. This is the same issue as In bitcraze/crazyflie-firmware-experimental#2, you used the client + Xbox 360 so try that.

NicksonYap commented 5 years ago

Actually the CF will flip when using Xbox360 controller only when using the ICRA2019 firmware

It did not flip when using master, in fact it worked very well

It's probably due to initializations in app.c

Soon I'll try to remove some stuff in app.c to narrow down the cause, will report here

ataffanel commented 5 years ago

It is most likely due to the controller: position hold will only work with the PID controller and I think in ICRA2019 we used the Mellinger controller.

NicksonYap commented 5 years ago

Yes, agreed

I'll comment and uncomment that and see how it goes

Currently setting up my BS in a different area

NicksonYap commented 5 years ago

It's confirmed that it's due to Mellinger controller.

disabled in app.c and it can be controlled using Xbox360 controller

ataffanel commented 5 years ago

Ok good, I guess I can close this ticket then since it is not a problem with the Lighthouse system.

NicksonYap commented 5 years ago

Not that using mellinger controller for velocity setpoints is a must, but to better understand the situation

Is it just that velocity set points are not implemented in mellinger controller Or is it theoretically impossible/difficult?

ataffanel commented 5 years ago

My understanding is that using simple velocity setpoint with the Mellinger controller would be hard. The Mellinger controller expects real-time continuous setpoints in position/velocity/acceleration/jerk. The Crazyflie contains code to 'play' 7 degrees polynomials in realtime to generate the right setpoint, it is currently the only practical way to use the Mellinger controller.

The goto high-level controller command generates an play a polynomial. I think a generator could be created to emulate velocity control and generate correct setpoint, but I have no idea how hard it would be to make it.

NicksonYap commented 5 years ago

To make sure I understand it right:

Mellinger controller requires a playback of a 7 degree polynomial, regardless the type of command (eg: goto or velocity)

The GoTo command has already been implemented for Mellenger controller by generating a 7th degree polynomial in runtime

Similarly, Velocity setpoint command is not yet implemented but will still also require generating a 7th degree polynomial in runtime

ataffanel commented 5 years ago

Not really, the Mellinger controller requires continious setpoints and the way to generate them today is by using these 7-degree polynomials.

One way to implement a velocity setpoint command is to generate a 7th degree polynomial but one could imagine making a function that generates the required next setpoint as well. I have no idea what method would be the best.