During the alpha testing phase with the "APM Copter V3" code
i immediately reported to the Dev Team that the Loiter mode was very accurate but is not allowed to fly normally, like with other system as DJI and Mikrokopter, Zero-UAV, etc.
We preferred to make the Loiter mode that would serve to accurately reposition the multirotor, and to help beginners to fly slowly and safely.
An italian friend and developer, Sandro Tognana, collected my challenge and started to develop a flight mode as I wanted, in line with the other famous flight control board.
Another awesome programmer, Julien Dubois, has joined our team and has worked actively to implement the complicated wind compensation.
After several months of development and testing are pleased to present the "Hybrid flight mode", in two words a "flyable Loiter" with wind compensation, the code virtually switches from "Loiter" to "Alt-Hold" and viceversa when you exit and enter a sticks deadband (configurable), considering of course the compensation of the wind, therefore complies with the tuning of your multirotor.
You can configure some parameters but already with the default works perfectly, my video speaks for itself.

This new mode is currently being debugged (in alpha phase), it is therefore not available to the public, of course, will have to go into the hands of APM Copter Dev Team who will decide whether to adopt it in an upcoming release.
The results in my video are great, sorry but the audio is bad because it was very windy today, however, is clearly seen as a "Hybrid" works, is almost perfect.
In the second video by Julien you can see the Hybrid in action vs a "DJI Phantom 2" quad with "Naza 2" inside, imho Hybrid work better than the "GPS Position Hold" of DJI, especially on braking.
The tests were carried out on APM and VR Brain, but of course will work on any board that installs "APM Copter" as PX4 and Pixhawk.
I will keep you updated on the "Hybrid" developments, i'll open a discussion about this with other APM Copter developers to assess any changes in the code.

I want to say thanks to Sandro and Julien for their great work!

Bests, Marco

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Developer

    Perfect, thanks for your tests!

  • Thanks for your answer and new feature @Julien, i try it tomorrow afternoon with default parameters again.

    These adjust parameters will be also set in full parameter list? 

    Will tomorrow reporting regarding new feature ,,,

    Works very nice with default parameters, see here:

  • Franko,

    about the flight mode in mission planner, that is normal as this mode is still not included into master.

    So you did right, just assign n°14 to one of the 6 flight modes assigned to your radio switch.

    About brake speed, I don't understand your question... when there is not stick input, the brake will engage whatever your speed and it will loiter once speed<10cm/s.

    If you want the copter to brake more or less quickly, you can change the param WPNAV_BR_RATE (from 5=slow brake to 12=harder brake) but I suggest you to try first with the default value (8) as we've tested every combinations with other hybrid params and the best behaviours were with theses default values.

    If there is wind, let the copter loiter 5s at 2m high minimum before flying... it let the copter learn wind for better performances.

  • Hybrid was compiled and flashed.

    Flight Mode was not displayed in Flight Modes after inserting it into Full Parameters FL6 14, hope that is normal.

    Can´t wait to test and tried it in the dark... very impressive .. seems to work... ;-)

    Try it tomorrow again, but another question:

    Can i settle more brake speed after no stick input?

  • Thanks very much Julien, the ArduPilot version of Arduino did the trick :)

  • Hi,

    to make it compile, follow this tutorial (from step 4)

    You have to get this special version of Arduino, otherwise it won't work.

    I have sometimes compile problems, I just delete every "buildxxxxx" folders in the temp directory Arduino is building the code.

    Hope this helps

  • For some reason I am unable to get it to compile.

    In arduino v1.03 I get the follow errors:
    Building for ArduPilot Mega 2.x
    Excluding arduino core from include paths
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AC_WPNav\AC_WPNav.cpp: In member function 'void AC_WPNav::get_loiter_acceleration_to_lean_angles(float, float)':
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AC_WPNav\AC_WPNav.cpp:732: error: unable to find a register to spill in class 'POINTER_REGS'
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AC_WPNav\AC_WPNav.cpp:732: error: this is the insn:
    (insn 9 8 11 2 C:\ArdupilotST-JD-Hybrid-Mode\libraries\AC_WPNav\AC_WPNav.cpp:726 (set (reg:SF 48 [ D.30413 ])
            (mem/s:SF (post_inc:HI (reg/f:HI 12 r12 [orig:49 this ] [49])) [5 <variable>._cos_yaw+0 S4 A8])) 11 {*movsf} (expr_list:REG_INC (reg/f:HI 12 r12 [orig:49 this ] [49])
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AC_WPNav\AC_WPNav.cpp:732: confused by earlier errors, bailing out

    And in version 1.0.5 I get the follow errors:

    In file included from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Progmem/AP_Progmem.h:5,
                     from ArduCopter.pde:84:
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_HAL/AP_HAL_Boards.h:91:2: error: #error "Unknown CONFIG_HAL_BOARD type"
    In file included from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Compass/AP_Compass_HMC5843.h:9,
                     from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Compass/AP_Compass.h:6,
                     from ArduCopter.pde:104:
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Compass/Compass.h:37:3: error: #error "You must define a default compass orientation for this board"
    In file included from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Notify/AP_Notify.h:22,
                     from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Motors/AP_Motors_Class.h:9,
                     from C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Motors/AP_Motors.h:6,
                     from ArduCopter.pde:112:
    C:\ArdupilotST-JD-Hybrid-Mode\libraries\AP_Notify/AP_BoardLED.h:64:2: error: #error "Unknown board type in AP_Notify"
    In file included from ArduCopter.pde:142:
    /config.h:48:2: error: #error CONFIG_HAL_BOARD must be defined to build ArduCopter
    ArduCopter:420: error: 'void delay(uint32_t)' was declared 'extern' and later 'static'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:107: error: previous declaration of 'void delay(long unsigned int)'
    ArduCopter:422: error: 'uint32_t millis()' was declared 'extern' and later 'static'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:105: error: previous declaration of 'long unsigned int millis()'
    ArduCopter:423: error: 'uint32_t micros()' was declared 'extern' and later 'static'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:106: error: previous declaration of 'long unsigned int micros()'
    ArduCopter:424: error: 'void pinMode(uint8_t, uint8_t)' was declared 'extern' and later 'static'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:98: error: previous declaration of 'void pinMode(uint8_t, uint8_t)'
    ArduCopter:425: error: 'void digitalWrite(uint8_t, uint8_t)' was declared 'extern' and later 'static'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:99: error: previous declaration of 'void digitalWrite(uint8_t, uint8_t)'
    ArduCopter:426: error: new declaration 'uint8_t digitalRead(uint8_t)'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:100: error: ambiguates old declaration 'int digitalRead(uint8_t)'
    ArduCopter:163: error: 'AP_HAL_BOARD_DRIVER' was not declared in this scope
    ArduCopter:2470: error: expected constructor, destructor, or type conversion before ';' token
    Log.pde: In function 'void Log_Read(uint16_t, uint16_t, uint16_t)':
    Log:745: error: 'HAL_BOARD_NAME' was not declared in this scope
    compat.pde: In function 'uint8_t digitalRead(uint8_t)':
    compat:33: error: new declaration 'uint8_t digitalRead(uint8_t)'
    C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:100: error: ambiguates old declaration 'int digitalRead(uint8_t)'And it halts on a line in the code: "static int8_t control_mode = STABILIZE;"

    Would you have any ideas as to why I am getting the compile errors?


  • @Edgar : To complete Marco's answer, the current Alt controller we use in hyrbid is the Throttle_hold (used by Alt_hold and loiter modes). So, it suffers from the same "droping" problem due to baro disturbances... That is someting we have to improve to be >= DJI GPS mode.

    @Cam : This code is the last one, IMO at least as safe as the current loiter/alt_hold modes.

    As Hybrid is a mix between Alt_Hold and Loiter current modes, it will suffer from the problems of these two modes. I have noticed 3 mains :

    - The baro disturbances that brings the alt drop (for example when you full pitch and release stick, the copter alt decrease)

    - GPS glitch (in hybrid, when you move no stick, the copter is in "loiter" mode so, if you have bad GPS signal, the copter can drift sometimes hard). But hybrid is safer than true loiter because if you move roll or pitch stick, you exit loiter and switch to Alt_hold mode (no GPS, no more problem)

    - First take_off : Sometimes the copter jumps 2m high at first takeoff (only first takeoff btw)... probably a bad baro init but I have this problem in Alt_Hold, Loiter and Hybrid.

  • Developer

    Hi Cam, is stable, i haven't found bug but is in "alpha state" at the moment, so if you want compile and fly at your risk.

  • Hello Marco & Julien. Hope you are both well.

    I was wondering if there are any known bugs in the hybrid mode code for the APM that you are aware off. Do you believe it is safe to fly with?  I am dying to test/use this mode as it is what the APM has been in need of since it's design.
    Is the code here the latest compile you have?


    APM Plane, APM Copter, APM Rover source. Contribute to Ju1ien/ArdupilotST-JD development by creating an account on GitHub.
This reply was deleted.