-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Turtle mode optimization #6863
Turtle mode optimization #6863
Conversation
@kernel-machine With the current #6845 fix. Does this new PR have a fix for this ? Thanks |
@Jetrell i've had not notice this issue in #6845, but in this PR it not happens, as you can see in the attached video, starting from the left, the first switch is the turtle mode, the second is for arming and when i've turned off the arming switchthe turtle mode was still actives, all was worked fine. |
@kernel-machine Thanks for the reply. I looked into it more. |
Ok @Jetrell, i will do some tests in the afternoon |
With this branch the problem said by @Jetrell doesn't appears |
Wouldn't it make sense to activate the turtle mode with a small time delay ~ 0.5s? This would create a possibility to put arming and turtle mode on one switch. Each switch has 2 contacts for on and off but also a zero point, even if this has no grid position (-1, 0, 1 or 1000, 1500, 2000). If arm mode and turtle mode are set to this zero point and to on position is set only the arm mode , nothing would change for arming in the case of a delayed turtle mode, but turtle mode can simply be activated using the same switch is held in the middle until the quad is correctly positioned again. It already works like this, but the switch has to be toggled very quickly so that the turtle mode is not also active in the switch on position. |
Hey man @Odin263, this thing happen only if you disable first the turtle mode and then disarm the motors or even if you first disarm and then disable the turtle mode? |
I've tried differently. It's not always like that, but mostly. I couldn't find a connection. The engine selection also appears to be random. |
Hi @kernel-machine, apparently that wasn't the solution after all. The error now only occurs very rarely, but it is not completely gone. I do not understand why the rotation change always works when activating the turtle mode, but after exiting the mode it can sometimes fail? Before activating the turtle mode, there are never any problems with the direction of rotation. |
@Odin263 I don't know if you know, when the firmware sends a DShot command to the ESC, it will be send 10 times (it's required by the dshot protocol). You could try to add these delays also if it's strange that the motors always reverse the direction and the problem is always when they go back to the original direction. |
@kernel-machine thank you very much for your support! I had already tried the slower dshot protocol before, but without any visible success (dshot300 and dshot150). I will try to copy this delay from BetaFlight. Maybe I have this problem because my ESC only supports BLHeli_S and not BLHeli_32. If I manage to integrate this delay into the repetitions and get the problem completely solved with that or with other means, I will give you feedback here. |
@kernel-machine I am not sure if I positioned the delay correctly because I am not familiar with programming, but it apparently worked. After about 100 attempts the error did not appear. |
@Odin263 In these flight controller firmware you never should put an instruction that blocks the execution flow, for example that line blocks the whole iNav firmware for 10 ms while you should block only the dshot commands.
In this way a new command will be put in Another comment: you have write 10 000 us while betaflight uses 1 000 us. |
@kernel-machine, |
micors() returns the amount of microseconds since the flight controller was started |
@kernel-machine |
Sorry for the multiple PRs for the turtle mode.
With this PRs i've did:
With the previous PR (Turtle mode issue fix #6845) i've fixed the issue that if the switch of turtle mode is accidentally triggered during the flight, the turtle mode will enter, motors are stopped and the quad will crash, but with the previous PR the turtle mode enters only if the quad is leveled., so useless :)
Some users (included @DzikuVx) said me that the stick response it too much sensitive (they are right), this was caused by an error in the motor output calculation, now the response is more "soft" and i have tuned the power factor in order to have the right power for my quad to avoid double flip.
The original code has two dead band one on the stick and another one on the motor output (they are borrowed from BF), i've removed that on the motors, i think that the one of the stick is enough and with both of them there was to much dead band.
I've renamed all the code functions and variables related to the turtle mode from flipOverAfterCrashMode to turtleMode, we call this feature in this way in all the parts of iNav so i think that it has not to much sense to call it in another way in the code.
Now the response is something like this, so at the maximum stick deflection the max power is guaranteed, the power factor changes only the curve response and not the maximum power.
![immagine](https://user-images.githubusercontent.com/40276199/115556317-da93df80-a2b0-11eb-99ca-216a04a321e3.png)
video_2021-04-21_16-46-45.mp4