Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaw rate reference in firmware PID controller #48

Open
matthew-william-lock opened this issue Sep 28, 2023 · 8 comments
Open

Yaw rate reference in firmware PID controller #48

matthew-william-lock opened this issue Sep 28, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@matthew-william-lock
Copy link

Hey!

I am attempting to use the crazyflie_controller_py_firmware_pid controller for simulating the crazyflie onboard controllers.

Unfortunately, I am struggling a little bit with Yaw/Yaw rate regulation and have noticed that in the example, the desired yaw rate is set:

yawDesired = 8
...
degrees(yawDesired)

Is there a reason one has to give such a large setpoint? This makes absolute yaw tracking a little tricky...

@knmcguire
Copy link
Member

yeah, that is probably due that the python bindings have a bit of a timing issue. Perhaps if you noticed, we fix the ticks now to a 100

tick = 100 #this value makes sure that the position controller and attitude controller are always always initiated

But this is not the same as the actual rate of the simulator. However, if we uses the real time of the simulator, the crazyflie is hardly able to fly.

There are currently quite some timing and intergration issues with the python bindings that we need to fix. However this needs to be on the crazyflie firmware side of things. We don't have time to quickly have a fix for this but I've made an issue so that we are reminded to look at this once we have more time bitcraze/crazyflie-firmware#1320

@matthew-william-lock
Copy link
Author

@knmcguire
Copy link
Member

Yeah probably everything is affected by it that is depended on that rate control 😅 . It is not ideal for now. The control works pretty good okay but then you can't really call it software in the loop anymore, which is the initial purpose of it.

Anyway, hopefully we will have some time to look at it in the future.

@matthew-william-lock
Copy link
Author

Could I potentially create a timer to call the controller at the same rate it would be called on the Crazyflie itself ?

If so, then I would have two follow-up questions:

  1. Where could I find what rate the controller is called in hardware?
  2. In the Crazyswarm2 package, I can see that the sim backend calls the controller with a timer similar to what I am suggesting. Although I can see by default that max_dt = 0.0. What would the actual execution rate of the timer then be?

Thanks!

@matthew-william-lock
Copy link
Author

Could I potentially create a timer to call the controller at the same rate it would be called on the Crazyflie itself ?

If so, then I would have two follow-up questions:

  1. Where could I find what rate the controller is called in hardware?
  2. In the Crazyswarm2 package, I can see that the sim backend calls the controller with a timer similar to what I am suggesting. Although I can see by default that max_dt = 0.0. What would the actual execution rate of the timer then be?

Thanks!

I can see in the firmware how the tick is increased when calling the controller https://github.com/bitcraze/crazyflie-firmware/blob/cd3f3dfb668261f4461f972be8116d996aa7256e/src/modules/src/stabilizer.c#L342, but it isn't clear the rate at which this loop runs

@knmcguire
Copy link
Member

ahhh... yeah it should be at a 1000 hz I think. but this is perhaps a bit dangerous as there are many factors that might delay that rate in the stabilizer loop these days, so it might not be as true anymore as it used to.... I feel that a revamping might be necessary 😓. I'll mention this in the previous issue I started, since there are a lot of assumptions placed on this very simple increase I think. If this is the case, we will need to make the controller and estimators not rely on this tick anymore but on the actual time and that is not a change in the Python bindings but an actual change in the firmware.

The timer thingy in crazyswarm2, you should start a discussion at their discussion page: https://github.com/IMRCLab/crazyswarm2/discussions. I am a co-maintainer there but I didn't implement this part of the code.

@matthew-william-lock
Copy link
Author

I see 🙈 I tried my hand at setting the simulation rate of Webots to 1 ms (the fastest rate possible) and incrementing the tick of the controller with the simulation tick, but the behaviour seems to be a little unstable...

@knmcguire
Copy link
Member

yeah that is not working indeed.

I see that you posted a question on crazyswarm2 about webots: IMRCLab/crazyswarm2#290

Just mind, that the python bindings timing issue is completely unrelated to the simulator ;) this is not a webots issue

@knmcguire knmcguire added the bug Something isn't working label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants