Code Monkey home page Code Monkey logo

rotorflight-firmware's Introduction

Rotorflight

Rotorflight is a Flight Control software suite designed for single-rotor helicopters. It consists of:

  • Rotorflight Flight Controller Firmware (this repository)
  • Rotorflight Configurator, for flashing and configuring the flight controller
  • Rotorflight Blackbox Explorer, for analyzing blackbox flight logs
  • Rotorflight LUA Scripts, for configuring the flight controller using a transmitter

Built on Betaflight 4.3, Rotorflight incorporates numerous advanced features specifically tailored for helicopters. It's important to note that Rotorflight does not support multi-rotor crafts or airplanes; it's exclusively designed for RC helicopters.

This version of Rotorflight is also known as Rotorflight 2 or RF2.

Information

Tutorials, documentation, and flight videos can be found on the Rotorflight website.

Features

Rotorflight has many features:

  • Many receiver protocols: CRSF, S.BUS, F.Port, DSM, IBUS, XBUS, EXBUS, GHOST, CPPM
  • Support for various telemetry protocols: CSRF, S.Port, HoTT, etc.
  • ESC telemetry protocols: BLHeli32, Hobbywing, Scorpion, Kontronik, OMP Hobby, ZTW, APD, YGE
  • Advanced PID control tuned for helicopters
  • Stabilisation modes (6D)
  • Rotor speed governor
  • Motorised tail support with Tail Torque Assist (TTA, also known as TALY)
  • Remote configuration and tuning with the transmitter
    • With knobs / switches assigned to functions
    • With LUA scripts on EdgeTX, OpenTX and Ethos
  • Extra servo/motor outputs for AUX functions
  • Fully customisable servo/motor mixer
  • Sensors for battery voltage, current, BEC, etc.
  • Advanced gyro filtering
    • Dynamic RPM based notch filters
    • Dynamic notch filters based on FFT
    • Dynamic LPF
  • High-speed Blackbox logging

Plus lots of features inherited from Betaflight:

  • Configuration profiles for changing various tuning parameters
  • Rates profiles for changing the stick feel and agility
  • Multiple ESC protocols: PWM, DSHOT, Multishot, etc.
  • Configurable buzzer sounds
  • Multi-color RGB LEDs
  • GPS support

And many more...

Hardware support

The best hardware for Rotorflight is any Flight Controller especially designed for it. See What board is suitable?

Otherwise, Rotorflight supports all flight controller boards that are supported by Betaflight 4.3, assuming that the board has enough suitable I/O pins for connecting all the servos and motors required.

Also, the Betaflight boards are labeled for multi-rotor use - thus the user needs to understand how these functions can be used for a different purpose with helicopters. Usually this is just about using the motor outputs for servos, but in some cases a more advanced remapping may be needed.

Rotorflight supports STM32G4, STM32F4, STM32F7 and STM32H7 MCUs from ST.

It's highly recommended to use an STM32F7 based flight controller for Rotorflight. It's the way to go since it can take full advantage of the latest control and filtering algorithms, plus other cool features that really put the CPU to work.

An absolute minimum is an STM32G4 based board, but it probably won't be able to run all the new features later on. The older STM32F411 should be avoided if possible.

Installation

Download and flash the Rotorflight firmware with the Rotorflight Configurator.

Flashing the Rotorflight firmware with any other flashing tools is not recommended.

Visit the website for more details on setting up and using Rotorflight.

Contributing

Rotorflight is an open-source community project. Anybody can join in and help to make it better by:

  • helping other users on Rotorflight Discord or other online forums
  • reporting bugs and issues, and suggesting improvements
  • testing new software versions, new features and fixes; and providing feedback
  • participating in discussions on new features
  • create or update content on the Website
  • contributing to the software development - fixing bugs, implementing new features and improvements
  • translating Rotorflight Configurator into a new language, or helping to maintain an existing translation

Origins

Rotorflight is software that is open source and is available free of charge without warranty.

Rotorflight is forked from Betaflight, which in turn is forked from Cleanflight. Rotorflight borrows ideas and code also from HeliFlight3D, another Betaflight fork for helicopters.

Big thanks to everyone who has contributed along the journey!

Contact

Team Rotorflight can be contacted by email at [email protected].

rotorflight-firmware's People

Contributors

andershoglund avatar basdelfos avatar blckmn avatar borisbstyle avatar ctzsnooze avatar dannixon avatar diehertz avatar etracer65 avatar ezshinoda avatar hydra avatar illusionfpv avatar jflyper avatar joelucid avatar kiteanton avatar klutvott123 avatar ledvinap avatar martinbudden avatar mcgivergim avatar mikeller avatar mj666 avatar nathantsoi avatar pmattila avatar sambas avatar savaga avatar stevecevans avatar thenickdude avatar tonyblitworks avatar treymarc avatar trollcop avatar wind0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rotorflight-firmware's Issues

Add persistent error flags

Add functionality to store an error log / flags.

This is similar to the blackbox events, but is only storing rarely happening (error) events.

This error log should be then available in the Configurator, without the need to load the log files in the BB Explorer.

Some events / flags that we would like to have:

  • Voltage low / critical
  • Low / Lost RX signal
  • Failsafe events
  • RPM signal errors
  • Vibration level errors (excessive vibes etc.)
  • HW faults

iFlight_F411_PRO no Blackbox

Describe the bug
Blackbox is not found with this FC.

To Reproduce
Flash 4.2.12 20220401; Apply Defaults; BB not found
Flash Betaflight 4.3RC5 - BB chip found

Expected behavior

Screenshots
grafik

Better telemetry with CRSF / ELRS

The current CRSF / ELRS is very limited for helicopter use.

An alternative should be considered how to pass telemetry sensors to the Tx.
One option is to use the "Ardupilot FrSky telemetry passthrough", which is sending FrSky telemetry information with custom CRSF frames. This can be decoded by a LUA widget in the Tx.

RX Config gets corrupted when ELRS module match used

It appears that the RX configuration in Rotorflight is getting corrupted with ELRS.
This seems to happen when modelmatch settings are changed.

This is resulting the Rx protocol changing to DSM2/X + inverted.
And other Rx parameters changing to zero or random values.

Triage found evidence of ELRS Tx sending MSP_SET_RX_CONFIG, which is likely sent to the FC accidentally.

Discussion with ELRS ongoing.

PT1 filter gain formula

Describe the bug
I think PT1 filter gain formula is wrong

float pt1FilterGain(float cutoff, float sampleRate)
{
    float omega = tan_approx(M_PIf * cutoff / sampleRate);
    float alpha = 2.0f / (1.0f / omega + 1.0f);
    return alpha;
}

I was courious how it works, so I've calculated some results and compared to previous version

float pt1FilterGain(float f_cut, float dT)
{
    float RC = 1 / (2 * M_PIf * f_cut);
    return dT / (RC + dT);
}

I noted that characteristics is slightly diferrent, especialy if the cutoff is above 0.1 of sample rate. And at the 0.25 of sampling rate is equal 1 and raises.

Expected behavior
PT1 gain shouldn't exceed 1.0, on a picture below you can see, that it equals 1 at 0.25 of sampling frequency. On the second picture you can see that filter starts oscillating if k > 1.

Screenshots
image
image

Additional context
I don't know why PT1 filter gain formula is diferrent than in Betaflight. But if I modify it slightly to

float alpha = 1.0f / (1.0f / omega + 1.0f);

then gain is lower than 1 for cutoffs below nyquist.

Here is the link with my calculations https://docs.google.com/spreadsheets/d/1Nv-octpMxmQeqS8wSkmaLvypIiryuTpIMJ8j50X9rwg/edit?usp=sharing

I hope this helps.

Add more ESC telemetry protocols

At the moment we have BLHeli (KISS) telemetry and Hobbywing V4 telemetry.

We should add more protocols. Possible candidates are:

  • Hobbywing V5
  • Kontronik
  • Scorpion
  • Castle
  • YGE
  • ExBus
  • MultiPlex

TTA with servo tail

Servo tail should benefit from TTA as well.

The variable pitch tail / servo is always slower than a motorised tail / main rotor torque, which means we can help it with TTA with fast moves.

It would need to work differently from the motorised tail TTA.

This would mean using TTA for high-pass filtered yaw, and the variable pitch for low-pass filtered, or something like this.

This would need to be investigated, as this is just an idea.

Support for voltage measurements

Add support for measuring more voltages, other than just the battery.

The MCU is likely to have free pins on the ADC, so they could be as well connected as voltage measurement inputs,
for measuring whatever voltages we have on the FC.

For example:

  • Servo bus voltage and current
  • +5V regulator voltage / current (if present)
  • Any other voltages

Fix GPS_RESCUE

Fix GPS_RESCUE to work with separate collective / throttle.

At the moment the code assumes that throttle is the up/down control.

Rescue mode rate limiting

One improvement to the rescue mode would be rate of change limiting (negative direction) on return from rescue mode...... The issue is if you rescue from inverted and it rolls to upright --- if you don't raise the collective stick before you exit rescue mode it will immediately pitch down negative to match your collective stick position (can be really rapid). It would be good to rate limit the reduction in collective until the collective command >= rate limit. I'm thinking this would be more of an issue if/when auto rescue based on baro was implemented.

Add airborne / flying detection

The information whether the heli is actually in the air and flying, is needed in many places in the FC.

A reliable method for detection this is required.

Add Vibration Analysis / Report

Add functionality to measure and report vibration levels.

Calculate and report the following:

  • Main rotor harmonic levels in the gyro signal (1,2,3,4)
  • Tail rotor harmonic levels in the gyro signal (1,2)
  • Motor vibration level
  • Remaining total vibration level in the filtered gyro signal
  • Exact frequency of the main motor and tail motor

This can be used also for fine-tuning the RPM input / filters.

It may be possible to detect one-way bearing detach from this too (in autorotation).

TTA with GOV Passthrough requires headspeed setting

TTA with GOV Passthrough does not work unless the Full Headspeed is set, and there the TTA headroom is also set.
Obviously passthrough should not need the HS, so the headroom calculation should use some other logic.

Extend ESC telemetry data

Some ESCs are providing more data than the FC can use at the moment.
The ESC telemetry support should be extented to handle this.

Add tail motor idle speed governor

Replace the tail motor idle throttle with a proper speed governor, not unlike in Betaflight.

This will help slowing down the tail motor, as the throttle can temporarily drop to zero, as long as the motor is still rotating.

The only parameter needed is the minimum tail motor speed.

Internally, a PID controller is needed.

Mixer Page Scaling - in two directions

The mixer page has a value for setting the scaling of the collective and cyclick.

Currently this scaling affects both positive and negative.

It would be very advantages to allow the scaling to be separated for positive and negative. This would essentially allow absolutely identical collective to be configured.

Swashplate indications

A method is needed for giving visual indications, other than LEDs. Most people seem to hate the buzzer, so the same indications should be available visually. Maybe with swashplate jerk or similar.

Better accelerometer signal filtering

Helicopters have much more vibrations than drones.

The current filtering for ACC is in adequate for helicopters.
It should be improved, possible with notch filters just like the gyro.

Bessel filter note

Hi,
I'm looking at the code and have a tiny doubt.
In the filter.c https://github.com/rotorflight/rotorflight-firmware/blob/master/src/main/common/filter.c#L109 there is a fragment

void biquadFilterInitBessel(biquadFilter_t *filter, float filterFreq, uint32_t refreshRate)
{
    biquadFilterInit(filter, filterFreq, refreshRate, 0, FILTER_BESSEL);
}

then later in https://github.com/rotorflight/rotorflight-firmware/blob/master/src/main/common/filter.c#L118
there is

void biquadFilterInit(biquadFilter_t *filter, float filterFreq, uint32_t refreshRate, float Q, biquadFilterType_e filterType)
{
    ...
    const float alpha = sn / (2.0f * Q);

The 4th parameter Q is set to 0, I wonder how is that possible that MCU do not crash here with division by 0 exception? ;)
According to this article https://hackaday.com/2018/11/21/creating-black-holes-division-by-zero-in-practice/ division by 0 is allowed in floating point operations, but result in NaN. Technically alpha is not used in bessel variant, but you never know when it might kick us :)
Personally I'd use 1.0 here, just for sure. If you want, I can prepare PR.

Add ALTITUDE_HOLD Flight Mode

Add a new flight mode ALTITUDE_HOLD.

As the name suggests, the altitude is stabilised and kept constant, while the collective stick is centered.
Off-center collective would cause climb/decent, with a speed indicated by the collective stick deflection.

This flight mode can be used together with ACRO, ANGLE, HORIZON and TRAINER modes.

Logging: mass storage device mode limits number of log files to 100

When more than 100 files are stored on flash memory, only the first 100 can be accessed when you activate Mass Storage Device Mode. I think it has to do with EMFAT_MAX_LOG_ENTRY, which is also 100.

Work-around: you can access all files by clicking Save to file in the Configurator. This takes a while and results in one big file, where each individual log file is a part.

Refactor Governor for Nitro

  1. The main distinction of nitro engine is that it requires an "idle" mode where the motor spins slowly and the clutch is not engaged. For simplicity, I believe that the "Arm" switch should be safe enough to enable the "idle" mode where a significant effort is required to start the engine (glow plug and starter) so that safety should not be a concern here.
  2. The idle mode needs some special attention. Let's say that we want idle mode enabled when the FC is armed but the throttle is still on hold. There should be an easy way to trim the idle output position (either by a trim knob or some people like to use the collective stick to output throttle position directly.) It is necessary because due to the different weather, fuel, temperature, the ideal idle throttle position might be slightly different.
  3. There is a problem with starting the motor as well. I found that the "start up" and "spool up" logic fails here since the rpm will have valid readout as soon as the motor is in idle. In addition, I found that at low rpm output, especially when the clutch is not engaged yet, the governor could be over-gained which results in rpm oscillation during spool up. Some ways to fix it is to engage PID loop after the output throttle or RPM has reached a minimum level to ensure the clutch is engaged.
  4. There is a notion that for nitro to work well, the output throttle should not be lower than a certain value. Therefore, we should have a "min output throttle" similar to "max output throttle" we currently have.
  5. (optional) Since nitro usually requires a lot of gov feedforward to work properly, it would be nice to have a way to visualize the gov FF effect on the throttle servo. One way to do it is to enable throttle FF when throttle is active and the spool up is completed even though the motor is not spinning.

ESC Setup / programming (bidirectional telemetry)

Provide ESC setup / programming functionality using the Tx via bidirectional telemetry on par with other modern R/C systems.

As heli pilots we are accustomed to being able to setup (set BEC voltage, change rotation, set cutoff behavior etc.) and tweak at the field (ESC internal gov gains etc). A growing number of ESCs support this functionality.
Support in RF.

Improve RPM sensor timer usage

Currently the RPM sensor is limited to one sensor input per timer.

With T2 or T5, it should be possible to have 4 RPM inputs per timer.

TTA for bidirectional tail motor

TTA function is likely to be beneficial to a bidirectional tail motor.

Changing the direction is slow, it can take up to 250ms for the motor to stop and then start in the other direction.
Meanwhile, TTA could take care of the tail torque control.

This requires development, evaluation and testing.

Yaw stick with stick commands and OSD/CMS control is reversed

The yaw inversion is done before the rcCommand is calculated, which means the rcCommand[YAW] is reversed.
The stick commands and OSD/CMS stick control are expecting it to be the normal way.

The inversion should be moved somewhere after the rcCommand calculation.

RPM filter autoconfig

Refactor the RPM filter, for full autoconfiguration.

Detect the RPM peaks and their widths, and configure each notch filter automatically.
Do this separately for each axis.

RPM and Temperature with ELRS telemetry

Improve ELRS / CRSF telemetry to pass RPM and Temperature to the Tx.

This is a difficult problem, because the CRSF protocol does not have these telemetry values.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.