Skip to content

Conversation

@MrD-RC
Copy link
Member

@MrD-RC MrD-RC commented Nov 2, 2025

User description

There was a discussion in the INAV Discord fixed-wing channel regarding the rudder control in INAV, how it's underwhelming, and how boosting FF to 255 for yaw is not the best solution. The idea (from James Downing FPV) of having negative expo on the rudder was discussed. It seems like a sound concept and worth investigating. So this PR, along with the configurator counterpart, allows negative expo on the yaw axis.

Configurator iNavFlight/inav-configurator#2419


PR Type

Enhancement


Description

  • This description is generated by an AI tool. It may have inaccuracies

  • Enable negative expo values for yaw axis control

    • Changed rcYawExpo8 from uint8_t to int8_t in stabilized and manual modes
    • Updated min range from 0 to -100 for yaw expo settings
  • Refactored RC curve calculation to support negative expo

    • Modified rcLookup() function with new expo formula
    • Added applyAdjustmentI8() for signed 8-bit adjustments
  • Updated MSP protocol handlers for signed yaw expo serialization

    • Changed sbufWriteU8() to sbufWriteI8() for yaw expo transmission
    • Changed sbufReadU8() to sbufReadI8() for yaw expo reception
  • Added stream buffer support for signed 8-bit integers


Diagram Walkthrough

flowchart LR
  A["Yaw Expo Config<br/>uint8_t → int8_t"] --> B["RC Curve Calculation<br/>New expo formula"]
  A --> C["MSP Serialization<br/>sbufWriteI8/ReadI8"]
  B --> D["Adjustment Handler<br/>applyAdjustmentI8"]
  C --> E["Settings Range<br/>-100 to 100"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
streambuf.c
Add signed 8-bit write function                                                   
+5/-0     
streambuf.h
Declare sbufWriteI8 function signature                                     
+1/-0     
controlrate_profile_config_struct.h
Change yaw expo to signed integer type                                     
+2/-2     
fc_core.c
Update axis command function parameter                                     
+2/-2     
fc_msp.c
Use signed serialization for yaw expo                                       
+6/-6     
rc_adjustments.c
Add signed adjustment and yaw-specific handling                   
+17/-7   
rc_curves.c
Implement new expo formula supporting negative values       
+11/-3   
rc_curves.h
Update rcLookup function signature                                             
+1/-1     
Documentation
1 files
Settings.md
Update yaw expo min range documentation                                   
+2/-2     
Configuration changes
1 files
settings.yaml
Extend yaw expo range to negative values                                 
+2/-2     

@qodo-merge-pro
Copy link

qodo-merge-pro bot commented Nov 2, 2025

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@qodo-merge-pro
Copy link

qodo-merge-pro bot commented Nov 2, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix pointer type mismatch bug
Suggestion Impact:The commit changed the call to applyAdjustmentU8, altering the type of val. Although it cast to (uint8_t)val (value cast) instead of (uint8_t *)val (pointer cast) as suggested, it was clearly intended to address the same mismatch.

code diff:

-        applyAdjustmentU8(adjustmentFunction, val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);
+        applyAdjustmentU8(adjustmentFunction, (uint8_t)val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);

Fix a pointer type mismatch in applyAdjustmentExpo by casting the val argument
to uint8_t
when calling applyAdjustmentU8 for non-yaw adjustments. This
prevents potential memory issues and ensures correct behavior.
*

src/main/fc/rc_adjustments.c [368-374]

 static void applyAdjustmentExpo(adjustmentFunction_e adjustmentFunction, int8_t *val, int delta, bool isYaw)
 {
     if (isYaw)
         applyAdjustmentI8(adjustmentFunction, val, delta, SETTING_RC_YAW_EXPO_MIN, SETTING_RC_YAW_EXPO_MAX);
     else
-        applyAdjustmentU8(adjustmentFunction, val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);
+        applyAdjustmentU8(adjustmentFunction, (uint8_t *)val, delta, SETTING_RC_EXPO_MIN, SETTING_RC_EXPO_MAX);
 }

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical type mismatch bug where an int8_t* is passed to a function expecting a uint8_t*, which could lead to incorrect behavior or memory corruption.

High
  • Update

- Removed debug, oops
- Tidied up the rcLookup function with a constrainf and lrintf
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.

3 participants