Repository navigation
question on javascript programming #12007
|
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); 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? /// SMOOTH TRASITION FOR TAIL SITTER if (inav.rc[6].low || inav.rc[6].high) { } if (inav.gvar[1] = Null || inav.gvar[1] = 0) { if (inav.gvar[1] != inav.rc[6]) { if (inav.gvar[0] == 1) { if (inav.gvar[0] == 2) { |
Replies: 4 comments 1 reply
|
A couple things that may make this easier to read and reason about:
|
|
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... |
|
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:
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 |
|
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 |
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 fligh…