Skip to content

Conversation

@xznhj8129
Copy link

@xznhj8129 xznhj8129 commented Dec 14, 2025

User description

Add support for arc function IPF LCs (see iNavFlight/inav#11179)


PR Type

Enhancement, New Feature


Description

  • Add support for inverse trigonometric functions (acos, asin, atan2)

  • Replace hardcoded operation numbers with named constants for maintainability

  • Update error messages and diagnostics to reflect new supported functions

  • Define new logic operators 57, 58, 59 for arc trigonometry operations


Diagram Walkthrough

flowchart LR
  A["New Arc Trig Functions"] -->|acos, asin, atan2| B["Expression Generator"]
  B -->|Generate Logic Commands| C["Logic Operators 57-59"]
  C -->|Map to Operations| D["INAV Constants"]
  A -->|Update Type Definitions| E["TypeScript Declarations"]
  B -->|Update Diagnostics| F["Editor Validation"]
Loading

File Walkthrough

Relevant files
Enhancement
5 files
helpers.js
Add arc trig functions and refactor operation constants   
+42/-14 
expression_generator.js
Implement code generation for arc trigonometric functions
+26/-3   
logicConditionOperators.js
Define new logic operators for arc trigonometry                   
+19/-1   
diagnostics.js
Update diagnostics to support arc trigonometric functions
+3/-3     
inav_constants.js
Add operation constants for arc trigonometric functions   
+7/-0     
Documentation
1 files
types.js
Add TypeScript type declarations for arc functions             
+3/-0     
Additional files
3 files
inav_SITL [link]   
inav_SITL [link]   
inav_SITL [link]   

@github-actions
Copy link

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@xznhj8129 xznhj8129 changed the title Ipf trig IPF acos/asin/atan2 Dec 14, 2025
@qodo-code-review qodo-code-review bot changed the title IPF acos/asin/atan2 Ipf trig Dec 14, 2025
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

Comment on lines 32 to 37
abs: {
type: 'function',
desc: 'Return absolute value',
params: ['value'],
returns: 'number',
inavOperation: 32 // OPERATION.ABS
returns: 'number'
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Restore the inavOperation: OPERATION.ABS property for the abs function definition, as it was likely removed by mistake and is necessary for correct transpilation. [possible issue, importance: 9]

Suggested change
abs: {
type: 'function',
desc: 'Return absolute value',
params: ['value'],
returns: 'number',
inavOperation: 32 // OPERATION.ABS
returns: 'number'
},
abs: {
type: 'function',
desc: 'Return absolute value',
params: ['value'],
returns: 'number',
inavOperation: OPERATION.ABS
},

Comment on lines +264 to +275
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Update the hasOperand property for ACOS and ASIN in js/logicConditionOperators.js from [true, true] to [true, false] to correctly reflect that they are single-argument functions. [general, importance: 6]

Suggested change
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, false],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, false],
output: "raw"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants