Skip to content

Conversation

@MrD-RC
Copy link
Member

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

User description

This is to clean up some old references that should have been control_profile. But, have remained as different options.

Within the firmware, there are controlProfile (previously controlRateProfile) and PIDProfile. These are separate entities internal to the firmware. But, to the user, they only see control_profile which contains all the settings included within the firmware's separate controlProfile and PIDProfile.

This PR aims to take confusion away from the user by just referencing control_profile. This was most noticeable in the automated control_profile switching available in the battery_profile and the mixer_profile. Neither of which reference the UI visible control_profile. But mentioned controlrate_profile and PID Profile respectively. Neither of which are separately defined in the UI or CLI.

In future, it is worth remembering that the user sees all PIDProfile and control_profile settings within the control_profile in CLI or as a selectable Control Profile in Configurator.

Requires iNavFlight/inav-configurator#2429

2025-11-19
I have tested the changes that are not just renamed variables. i.e. the changes that needed to be updated in Configurator too.


PR Type

Enhancement


Description

  • Rename controlRateProfile references to controlProfile throughout codebase

  • Update CLI parameter from controlrate_profile to use_control_profile in battery profiles

  • Rename type controlRateConfig_t to controlConfig_t for consistency

  • Update mixer profile setting from PIDProfileLinking to controlProfileLinking

  • Rename parameter group from PG_CONTROL_RATE_PROFILES to PG_CONTROL_PROFILES


Diagram Walkthrough

flowchart LR
  A["controlRateProfile<br/>references"] -->|rename| B["controlProfile"]
  C["controlRateConfig_t<br/>type"] -->|rename| D["controlConfig_t"]
  E["PG_CONTROL_RATE_PROFILES<br/>parameter group"] -->|rename| F["PG_CONTROL_PROFILES"]
  G["controlrate_profile<br/>CLI param"] -->|rename| H["use_control_profile"]
  I["PIDProfileLinking<br/>mixer setting"] -->|rename| J["controlProfileLinking"]
  B --> K["Unified naming<br/>convention"]
  D --> K
  F --> K
  H --> K
  J --> K
Loading

File Walkthrough

Relevant files
Enhancement
37 files
pid.c
Update control profile references in PID calculations       
+23/-23 
fc_msp.c
Update MSP protocol to use control profile naming               
+53/-53 
rc_adjustments.c
Update RC adjustments to use control profile type               
+20/-20 
osd.c
Update OSD display to reference control profile                   
+15/-15 
osd_dji_hd.c
Update DJI OSD to use control profile naming                         
+26/-26 
rate_dynamics.c
Update rate dynamics to use control profile                           
+11/-11 
fc_core.c
Update core flight controller to use control profile         
+8/-8     
ez_tune.c
Update EZ tune to reference control profile                           
+6/-6     
blackbox.c
Update blackbox logging to use control profile                     
+10/-10 
rc_curves.c
Update throttle curve generation function signature           
+7/-7     
control_profile.c
Rename file and update function/variable names                     
+14/-15 
pid_autotune.c
Update autotune to use control profile naming                       
+4/-4     
cms_menu_imu.c
Update CMS menu to use control profile constant                   
+2/-2     
battery.c
Rename battery profile control rate field                               
+4/-4     
config.c
Update config activation to use control profile                   
+3/-3     
navigation_fixedwing.c
Update fixed wing navigation to use control profile           
+2/-2     
mixer_profile.c
Rename mixer profile PID linking to control profile linking
+2/-2     
control_profile.h
Rename header file and update declarations                             
+8/-8     
dashboard.c
Update dashboard function signature                                           
+2/-2     
cli.c
Update CLI to use control profile value type                         
+2/-2     
settings.h
Rename settings value type constant                                           
+1/-1     
rc_curves.h
Update function declaration with new type name                     
+2/-2     
control_profile_config_struct.h
Rename struct from controlRateConfig to controlConfig       
+2/-2     
parameter_group_ids.h
Rename parameter group ID constant                                             
+1/-1     
config.c
Update include to use control profile header                         
+1/-1     
config.c
Update include to use control profile header                         
+1/-1     
servos.c
Update include to use control profile header                         
+1/-1     
smartport.c
Update include to use control profile header                         
+1/-1     
settings.c
Update settings offset calculation for control profile     
+2/-2     
mixer.c
Update include to use control profile header                         
+1/-1     
battery_config_structs.h
Rename battery profile control rate field                               
+1/-1     
rc_controls.c
Update include to use control profile header                         
+1/-1     
failsafe.c
Update include to use control profile header                         
+1/-1     
rc_adjustments.h
Update function declaration with new type name                     
+2/-2     
mixer_profile.h
Rename mixer profile linking field                                             
+1/-1     
pid.h
Update forward declaration with new type name                       
+1/-1     
settings.yaml
Update settings configuration and parameter names               
+12/-12 
Documentation
5 files
msp_protocol.h
Update MSP protocol documentation comment                               
+1/-1     
displayport_msp_osd.c
Update comment to use control profile naming                         
+1/-1     
Settings.md
Update documentation for renamed settings                               
+12/-12 
inav_enums_ref.md
Update enum documentation                                                               
+1/-1     
MixerProfile.md
Update documentation to reference control profile               
+1/-1     
Tests
1 files
rc_controls_unittest.cc.txt
Update unit test counter names                                                     
+3/-3     
Configuration changes
2 files
settings.json
Add VSCode configuration entry                                                     
+2/-1     
CMakeLists.txt
Rename source files in build configuration                             
+3/-3     

This is to clean up some old references that should have been `control_profile`. But, have remained as different options.

Within the firmware, there are `controlProfile` (previously `controlRateProfile`) and `PIDProfile`. These are separate entities internal to the firmware. But, to the user, they only see `control_profile` which contains all the settings included within the firmware's separate `controlProfile` and `PIDProfile`.

This PR aims to take confusion away from the user by just referencing `control_profile`. This was most noticeable in the automated `control_profile` switching available in the `battery_profile` and the `mixer_profile`. Neither of which reference the UI visible `control_profile`. But mentioned `controlrate_profile` and `PID Profile` respectively. Neither of which are separately defined in the UI or CLI.

In future, it is worth remembering that the user sees all `PIDProfile` and `control_profile` settings within the `control_profile` in CLI or as a selectable **Control Profile** in Configurator.
@MrD-RC MrD-RC added this to the 9.0 milestone Nov 18, 2025
@MrD-RC MrD-RC added Cleanup/refactor CLI Add this when new CLI commands needs to be added to docs labels Nov 19, 2025
Changed `control_profile` in the `battery_profile` to now be `use_control_profile`. Which separates the parameter name from being exactly what the profiles are called. Plus it makes the usage of the parameter a bit more obvious.
@MrD-RC MrD-RC added Release Notes Add this when a PR needs to be mentioned in the release notes Requires Configurator labels Nov 19, 2025
@MrD-RC MrD-RC marked this pull request as ready for review November 19, 2025 10:31
@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 19, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Action Logging: New code adjusts runtime control profile and tuning parameters (e.g.,
changeControlProfile, applyStepAdjustment) without any added audit/event logging, which
may be acceptable for firmware but lacks explicit audit trails for critical changes.

Referred Code
    switch (adjustmentFunction) {
        case ADJUSTMENT_RATE_PROFILE:
            if (getCurrentControlProfile() != position) {
                changeControlProfile(position);
                blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RATE_PROFILE, position);
                applied = true;
            }
            break;
    }

    if (applied) {
        beeperConfirmationBeeps(position + 1);
    }
}
#endif

#define RESET_FREQUENCY_2HZ (1000 / 2)

void processRcAdjustments(controlConfig_t *controlConfig, bool canUseRxData)
{


 ... (clipped 46 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Input Validation: New MSP handlers write incoming values into control profiles with minimal validation
beyond range clamps and dataSize checks, lacking explicit error handling for malformed
payloads or invalid enum positions.

Referred Code
case MSP_SET_RC_TUNING:
    if ((dataSize == 10) || (dataSize == 11)) {
        sbufReadU8(src); //Read rcRate8, kept for protocol compatibility reasons
        // need to cast away const to set controlProfile
        ((controlConfig_t*)currentControlProfile)->stabilized.rcExpo8 = sbufReadU8(src);
        for (int i = 0; i < 3; i++) {
            tmp_u8 = sbufReadU8(src);
            if (i == FD_YAW) {
                ((controlConfig_t*)currentControlProfile)->stabilized.rates[i] = constrain(tmp_u8, SETTING_YAW_RATE_MIN, SETTING_YAW_RATE_MAX);
            }
            else {
                ((controlConfig_t*)currentControlProfile)->stabilized.rates[i] = constrain(tmp_u8, SETTING_CONSTANT_ROLL_PITCH_RATE_MIN, SETTING_CONSTANT_ROLL_PITCH_RATE_MAX);
            }
        }
        tmp_u8 = sbufReadU8(src);
        ((controlConfig_t*)currentControlProfile)->throttle.dynPID = MIN(tmp_u8, SETTING_TPA_RATE_MAX);
        ((controlConfig_t*)currentControlProfile)->throttle.rcMid8 = sbufReadU8(src);
        ((controlConfig_t*)currentControlProfile)->throttle.rcExpo8 = sbufReadU8(src);
        ((controlConfig_t*)currentControlProfile)->throttle.pa_breakpoint = sbufReadU16(src);
        if (dataSize > 10) {
            ((controlConfig_t*)currentControlProfile)->stabilized.rcYawExpo8 = sbufReadU8(src);


 ... (clipped 41 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
External Input: MSP set commands write directly to control profile fields with limited bounds checks and
no authentication or authorization context visible in the diff, which could be acceptable
in firmware but warrants review.

Referred Code
case MSP2_INAV_SET_RATE_PROFILE:
    if (dataSize == 15) {
        controlConfig_t *currentControlProfile_p = (controlConfig_t*)currentControlProfile; // need to cast away const to set controlProfile

        // throttle
        currentControlProfile_p->throttle.rcMid8 = sbufReadU8(src);
        currentControlProfile_p->throttle.rcExpo8 = sbufReadU8(src);
        currentControlProfile_p->throttle.dynPID = sbufReadU8(src);
        currentControlProfile_p->throttle.pa_breakpoint = sbufReadU16(src);

        // stabilized
        currentControlProfile_p->stabilized.rcExpo8 = sbufReadU8(src);
        currentControlProfile_p->stabilized.rcYawExpo8 = sbufReadU8(src);
        for (uint8_t i = 0; i < 3; ++i) {
            tmp_u8 = sbufReadU8(src);
            if (i == FD_YAW) {
                currentControlProfile_p->stabilized.rates[i] = constrain(tmp_u8, SETTING_YAW_RATE_MIN, SETTING_YAW_RATE_MAX);
            } else {
                currentControlProfile_p->stabilized.rates[i] = constrain(tmp_u8, SETTING_CONSTANT_ROLL_PITCH_RATE_MIN, SETTING_CONSTANT_ROLL_PITCH_RATE_MAX);
            }


 ... (clipped 11 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 19, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect manual yaw rate display
Suggestion Impact:The commit changed the OSD element to read currentControlProfile->manual.rates[FD_YAW] and use ADJUSTMENT_MANUAL_YAW_RATE, matching the suggestion.

code diff:

     case OSD_MANUAL_YAW_RATE:
-        osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "MYR", 0, currentControlProfile->stabilized.rates[FD_YAW], 3, 0, ADJUSTMENT_YAW_RATE);
+        osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "MYR", 0, currentControlProfile->manual.rates[FD_YAW], 3, 0, ADJUSTMENT_MANUAL_YAW_RATE);
         return true;

Correct the OSD element for Manual Yaw Rate (OSD_MANUAL_YAW_RATE) to use the
manual yaw rate value and adjustment function instead of the stabilized ones.

src/main/io/osd.c [3344-3346]

 case OSD_MANUAL_YAW_RATE:
-    osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "MYR", 0, currentControlProfile->stabilized.rates[FD_YAW], 3, 0, ADJUSTMENT_YAW_RATE);
+    osdDisplayAdjustableDecimalValue(elemPosX, elemPosY, "MYR", 0, currentControlProfile->manual.rates[FD_YAW], 3, 0, ADJUSTMENT_MANUAL_YAW_RATE);
     return true;

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: This is a valid bug fix for the OSD, as OSD_MANUAL_YAW_RATE was incorrectly using the stabilized yaw rate instead of the manual one, which would display the wrong value and adjust the wrong setting.

Medium
  • Update

Nice find AI code checker! No idea how long this bug has been there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cleanup/refactor CLI Add this when new CLI commands needs to be added to docs Release Notes Add this when a PR needs to be mentioned in the release notes Requires Configurator Review effort 2/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants