You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I'm familiarising with INAV 9.1.0. Looking at JavaProgramming, I'm wondering if I can use it to move elevons during transition for managing the asset change from TAIL SITTING to Horizontal Flight. Something like that:
where:
RC Channel 7 is used for mode selection (high is mixer control 2 - QUAD configuration, with IMU axis offset ON); mid is transition; low is fixed wing mixer control 1);
RC Channel 6 (is used in the servo mixer to move simultanously the two elevons up and down).
Ideally, when switching from TAIL to fixed wing, elevons should slightly pitch the nose down; when switching from FIXED wing should pitch the nose up. Would it work like that?
A couple things that may make this easier to read and reason about:
gvars can never be null, so that check can be removed for readability
Code is normally more readable if you name your variables
let oldRC6 = inav.rc[6];
if ( oldRC6 > 1500) {
I don't know about this part, but worth thinking about - if you need to increase forward pitch, and it happens that the elevons are wired to pitch, you MAY want the programming to increase pitch directly, rather than trying to end up with pitch being increased as a side effect of the ailerons moving, as a result of overriding the RC channel.
Since the radio is sending rc[5] you don't want to fight against your own own input. Rather than setting the mixer to use rc[5] and then having the programming tab and the radio fight over control of the channel, I would add a mixer line with gvar[4] or whichever gvar. So the mixer knows that the elevon is a mix of the gvar and whatever other inputs.
Thanks for replying. That's interesting.. How I'm supposed to act directly on a given pitch expected output? I totally agree with you. My approach would be a total failure: Since rc[5] is no way linked to a given attitude, loopback would try to counteract by spinning the 2 engines below to keep the nose pointing up...
It is not clear to me how to use the HMI. Can I write code directly in the window? I tried to write the code in Visual Studio, copy and paste it, but got no results. If you have a document providing full usage of the javascript programming feature, I'll get through it. Cheers
You can certainly write directly in the Configuraror window. That's probably easiest because then you get the full Intellicode auto complete for all of the INAV stuff etc. Syntax checking for the INAV stuff, etc. (The editor in Configurator is actually the same editor that VSCode uses, but wired up specifically for the INAV library).
would try to counteract by spinning the 2 engines below to keep the nose pointing up.
How I'm supposed to act directly on a given pitch expected output?
Yeah I would first get clear -- do you want to change the PITCH, or do you want to change an OUTPUT, such as a servo?
To change a servo, put in a mixer line for that servo. That new mixer line can reference a gvar, an RC channel, the target pitch, whatever is appropriate. That's to change the servo position, NOT the pitch target.
To override the pitch angle target, you can use
inav.override.flightAxis.pitch.angle
Ciao Sensei and all, please find here the js script for what we discussed and its transpilation to INAV logic. The idea is to use gvar[0] for register the mode (0 - QUAD, 2 - FIXED aircraft), linked to rc[7] (a three pos switch); gvar[1] is set to 1 only when in TRANSITION (i.e. rc[7] on its middle value). I didn't use edge or other events, it works for every cycle. Every time rc[7] gets in its low or high position gvar[1] is set to 0 and gvar[2] (a counter) is set to 0. Only when gvar[1] == 1, depending on the current value of gvar[0]: the counter gvar[2] is increased by one and the pitch angle is overridden to -45 or 45 degs, until the counter gets to 50.
I'm curious to test it in flight --- at banks seems it works fine.
note few issues with the GUI: for some reasons, as you leave the JS programming GUI without saving, and then you come back, the input text field get frozen. No copy, no return, you can't write into it. Seems disabled. You then need to disconnect, close the INAV GUI, then reopen it and get back to JS Programming.... I'm testing it on INAV 9.1.1. on Windows 11 OS. Cheers
Activity
sensei-hacker commentedon Jul 15, 2026
A couple things that may make this easier to read and reason about:
gvars can never be null, so that check can be removed for readability
Code is normally more readable if you name your variables
I don't know about this part, but worth thinking about - if you need to increase forward pitch, and it happens that the elevons are wired to pitch, you MAY want the programming to increase pitch directly, rather than trying to end up with pitch being increased as a side effect of the ailerons moving, as a result of overriding the RC channel.
Since the radio is sending rc[5] you don't want to fight against your own own input. Rather than setting the mixer to use rc[5] and then having the programming tab and the radio fight over control of the channel, I would add a mixer line with gvar[4] or whichever gvar. So the mixer knows that the elevon is a mix of the gvar and whatever other inputs.
CristianoUspace commentedon Jul 15, 2026
Thanks for replying. That's interesting.. How I'm supposed to act directly on a given pitch expected output? I totally agree with you. My approach would be a total failure: Since rc[5] is no way linked to a given attitude, loopback would try to counteract by spinning the 2 engines below to keep the nose pointing up...
It is not clear to me how to use the HMI. Can I write code directly in the window? I tried to write the code in Visual Studio, copy and paste it, but got no results. If you have a document providing full usage of the javascript programming feature, I'll get through it. Cheers
sensei-hacker commentedon Jul 15, 2026
You can certainly write directly in the Configuraror window. That's probably easiest because then you get the full Intellicode auto complete for all of the INAV stuff etc. Syntax checking for the INAV stuff, etc. (The editor in Configurator is actually the same editor that VSCode uses, but wired up specifically for the INAV library).
Copy and paste SHOULD work as well.
The documentation is is the wiki:
https://github.com/iNavFlight/inav/blob/master/docs/javascript_programming/JAVASCRIPT_PROGRAMMING_GUIDE.md
Yeah I would first get clear -- do you want to change the PITCH, or do you want to change an OUTPUT, such as a servo?
To change a servo, put in a mixer line for that servo. That new mixer line can reference a gvar, an RC channel, the target pitch, whatever is appropriate. That's to change the servo position, NOT the pitch target.
To override the pitch angle target, you can use
inav.override.flightAxis.pitch.angle
CristianoUspace commentedon Jul 17, 2026
Ciao Sensei and all, please find here the js script for what we discussed and its transpilation to INAV logic. The idea is to use gvar[0] for register the mode (0 - QUAD, 2 - FIXED aircraft), linked to rc[7] (a three pos switch); gvar[1] is set to 1 only when in TRANSITION (i.e. rc[7] on its middle value). I didn't use edge or other events, it works for every cycle. Every time rc[7] gets in its low or high position gvar[1] is set to 0 and gvar[2] (a counter) is set to 0. Only when gvar[1] == 1, depending on the current value of gvar[0]: the counter gvar[2] is increased by one and the pitch angle is overridden to -45 or 45 degs, until the counter gets to 50.
I'm curious to test it in flight --- at banks seems it works fine.
SMOOTH TRASITION FOR TAIL SITTER.txt
note few issues with the GUI: for some reasons, as you leave the JS programming GUI without saving, and then you come back, the input text field get frozen. No copy, no return, you can't write into it. Seems disabled. You then need to disconnect, close the INAV GUI, then reopen it and get back to JS Programming.... I'm testing it on INAV 9.1.1. on Windows 11 OS. Cheers