iNav: RTH with land mission

This video was taken last weekend during tests of latest changes implemented in iNav, as well as new GPS module Beitian BN-880 I shortly described here.
Mission plan:

  • Take off in Angle mode,
  • Engage 3D Position Hold
  • Fly away 100m
  • Return to Position Hold
  • Engage Return To Home mode

Summary:

  • Beitian BN-880 performed well. Quadcopter returned home with 1m accuracy. Constant fix on 15 sats all the time and HDOP at 1.2
  • No problems with magnetometer inside GPS module
  • No bigger problems during whole mission. I still have to work on yaw behavior. At the moment FP-PID and linear mixer from Betaflight can cause some strange yaw behavior on bigger quads. Fix should be available soon

iNav: Return To Home with land

New release of iNav is at the doors. Today I took testing version for a spin and tried few navigation scenarios. For example, transition for Position Hold to Return To Home with landing. It looked like this:

It behaved fantastically: nice accuracy, precise landing. There were few wobbles on descend, but that was caused not yet tuned FP-PID of Angle mode and hard flying conditions: gusty wind up to 15m/s.

New PID controller for iNav

If anybody keeps track of my posts about iNav flight controller software, he or she should notice that I like it very much. Guy nicknamed DigitalEntity did excellent job improving Cleanflight’s navigation modes. Maybe it is still not the same level as Pixhawk or Naza, but with this improvement speed those two are within reach for sure. When few days ago I noticed that he started to work on new PID controller called FP-PID, I’ve decided to take a look at.

Question. What is the worse flaw of all MultiWii inherited PID controllers? No, not the fact that they are using integer math. It might not make much sense on FPU equippent CPU like STM32F3, but it is fine. The biggest problem with them is that they are not based on proven scientific methods. If you read the code, it will look like this: divide this by Y, multiply X, make a strange assumption, instead of running other control loop make another strange assumption. At the end, they work. But hmm… in a magical way… The only PID controller that was written according to “rules” is LuxFloat.

And since I’m not an expert on control theory, I’ve decided to ask DigitalEntity why FP-PID is developed and what new will it bring. Here are the most important fragments of his reply.

I believe that the only real reason to have lots of PID controllers if that some/most/all of them are flawed in some way (from calculus point of view). So instead of having 2-3-4-5 controllers based on coding voodoo I would prefer to have one controller that is based on solid math and well-known numeric methods. The only PID controller in Cleanflight with clear and simple design […] is LuxFloat. That’s the reason to take it as a base for future improvement.

Comparing to LuxFloat, it is designed to improve the following:

  • Better integral anti-windup prevention. Instead of hard-limiting integral part […] the FP-PID implements so-called ‘backtracking’ algorithm to keep the PID controller output within limits. Next step […] PID will be aware when the motors are at their limit
  • Improved D-term calculation. All fuss around D-term is about noise. D-term tends to amplify high-frequency noise (usually vibration from props/motors) making the quad jitter. Current designs calculate D-term from current and previous readings and implement low-pass filtering and averaging to prevent D from amplifying noise, while allowing it to do it’s job. They all fight the consequence, not the cause – they try to fight already amplified defivative of the noise instead of filtering the noise itself. My D-term code is based on Pavel Holoborodko’s method of noise-robust derivative calculation […]. I also kept BiQuad filter from Betaflight to filter out the remainder of the noise.
  • Modifier self-leveling logic. Current approach with self-leveling is to take angle error and feed it to gyro-based controller as if it was pilot’s input in acro mode. However, roll/pitch angles are calculated from the same gyro data, leading to the phenomenon similar to D-term noise amplification – the faster the quad is rotating the bigger is PID response in self-leveling compared to rate mode. What I did is made the self-leveling code behave like human pilot. Human pilot does not correct for each and every slight attitude change, instead he corrects for bigger and slower changes. This is by definition the low-pass filter which is what I did in the code. This change makes self-leveling less jittery which is very evident when doing FPV flights in ANGLE or HORIZON modes.

The way I see it, it sounds super intresting. If time and weather will allow, I will give it a try next weekend on my 250 build. Just for fun.

iNav: Cleanflight learned how to do missions

In my recent post I mentioned that iNav flight controller software (fork of Cleanflight) introduced missions. Missions are preprogrammed waypoints that drone will fly to in specified order and/or do specified action at each of them. For example, if pilot wants to make a video on specified route, he does not have to pilot his drone all the time. He enters waypoints and lets machine do everything else. In this entry I will show how to configure iNav to do missions.

Requirements

  • iNav compatible drone flight controller flashed with iNav software. Currently supported boards are: Naze32, Flip32, CC3D, SPracingF3, Sparky, RDMO
  • GPS module connected to flight controller board. This example shows how to do it for Flip32, but it will work for all other boards, only UART pins might be different
  • Magnetometer connected and properly calibrated
  • Barometer connected
  • EZ-GUI Ground Station Android application that will act as Mission Planner. Official Cleanflight Configurator does not support this function yet
  • Bluetooth telemetry. Some time ago I have written how to do it for Flip32, but it will work almost the same for all other flight controllers, only UART pins might be different

Continue reading iNav: Cleanflight learned how to do missions

Better GPS for Cleanflight: iNav

Cleanflight is an awesome piece of software for STM32 based flight controllers. But Cleanflight has one very serious flaw that makes its usage on bigger drones at least problematic. Cleanflight sucks in GPS and barometer support. Sucks a lot. It can handle Position Hold (somehow), Return To Home (barely) and Altitude Hold (oh man, up and down, up and down) but if you at least one tried that, you should know that is not only not reliable, but also not precise and hard to tune. Personally I gave up after few tires. It was not worth it. Comparing to Pixhawk (not talking even about Naza) it might as well not exists at all. But it has changed recently…. Continue reading Better GPS for Cleanflight: iNav

Multiple flight modes for Cleanflight with Taranis

FrSky X9D Plus Taranis or cheaper FrSky Taranis Q X7 or even more expensive X10S Horus, are incredible radios. But also can be intimidation when migrating from simpler radios. A great example is mixing multiple switches into 1 channel to pass flight mode to the flight controller. Yes, you can do it, but it can be a pain in the ass on a Mixer level. I've lost a lot of time trying to understand the logic behind mixer weight and offset only to discover possibility to replace channel value, not add. And everything was simple again. So, here what I wanted, and what I did.

What I wanted

When I fly bigger FPV quadcopter, I want to use 7 different flight modes:

  • Angle without Altitude Hold (no BARO),
  • Horizon without Altitude Hold (no BARO),
  • Acro/Rate without Altitude Hold,
  • Angle with Altitude Hold (BARO),
  • Horizon with Altitude Hold (BARO),
  • Position Hold with Altitude Hold (BARO),
  • Return To Home with Altitude Hold (BARO)
    And I've figured out, that 3 switches should be used to enable all the flight modes: SC, SD, and SG. SC toggles Angle/Horizon/Acro. SD switches PosHold and RTH (as well as BARO and overrides SC and SG). SG enables Altitude Hold but only when SC is in up or middle position. 3 switches, 7 modes. I could do it with 3 radio channels, but that would have few flaws: would use 3 channels instead of one, and would allow for mistakes like no BARO with POSHOLD. So, advanced mixes and logical switches that is. Continue reading Multiple flight modes for Cleanflight with Taranis