Skip to content

Frontend: stop renaming RCIN9/RCIN10 if Sub version is higher than 4.5.4#3860

Open
Williangalvani wants to merge 1 commit intobluerobotics:masterfrom
Williangalvani:no_renaming_rcin
Open

Frontend: stop renaming RCIN9/RCIN10 if Sub version is higher than 4.5.4#3860
Williangalvani wants to merge 1 commit intobluerobotics:masterfrom
Williangalvani:no_renaming_rcin

Conversation

@Williangalvani
Copy link
Copy Markdown
Member

@Williangalvani Williangalvani commented Mar 31, 2026

We moved away from using RCIN9 and RCIN10 in 4.5.5. This renaming could then confuse users.

Summary by Sourcery

Conditionally map legacy RCIN9/RCIN10 labels for Sub vehicles based on firmware version to avoid incorrect PWM port naming in newer ArduSub releases.

Bug Fixes:

  • Stop renaming RCIN9 and RCIN10 to light controls for Sub vehicles when running ArduSub firmware versions newer than 4.5.4.

Enhancements:

  • Introduce a computed parameter value map that derives vehicle-specific RCIN label mappings dynamically from firmware version information.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 31, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds version-aware handling of ArduSub RCIN channel name mappings so that RCIN9/RCIN10 are only labeled as Lights 1/2 for firmware <= 4.5.4, preventing confusing renames on newer versions, by introducing an effective_param_value_map computed property and using semver comparison.

Class diagram for updated PwmSetup Vue component

classDiagram
  class PwmSetup {
    +string name
    +Dictionary~Dictionary~string~~ param_value_map
    +Dictionary~string~ legacy_sub_param_value_map
    +boolean is_sub
    +string vehicle_type
    +Dictionary~Dictionary~string~~ effective_param_value_map
    +Parameter[] servo_function_parameters()
    +string stringToUserFriendlyText(text string)
    +Parameter getParam(param string)
  }

  class Autopilot {
    +FirmwareInfo firmware_info
  }

  class FirmwareInfo {
    +string version
  }

  class Semver {
    +boolean lte(versionA string, versionB string)
  }

  PwmSetup --> Autopilot : uses_autopilot
  Autopilot --> FirmwareInfo : has
  PwmSetup ..> Semver : uses_lte_in_effective_param_value_map

  class ParamValueMaps {
    +Dictionary~Dictionary~string~~ param_value_map
    +Dictionary~string~ legacy_sub_param_value_map
    +Dictionary~Dictionary~string~~ effective_param_value_map
  }

  PwmSetup *-- ParamValueMaps : manages_channel_labels
Loading

File-Level Changes

Change Details Files
Introduce firmware-version-aware mapping for Submarine RCIN labels to avoid renaming RCIN9/RCIN10 on ArduSub > 4.5.4.
  • Import semver lte helper to compare autopilot firmware versions against 4.5.4.
  • Extract legacy Submarine RCIN9/RCIN10 light mappings into a dedicated legacy map.
  • Add effective_param_value_map computed property that merges legacy mappings into the Submarine map only when vehicle is Sub and firmware version is <= 4.5.4.
  • Update all usages of the parameter value map to reference effective_param_value_map so UI labels respect the firmware-aware behavior.
core/frontend/src/components/vehiclesetup/PwmSetup.vue

Possibly linked issues

  • #core: frontend: vehicle-setup: support new ArduSub output functions: PR implements the issue’s requested version-based handling of RCIN9/10 lights mappings for ArduSub 4.5.5 transition.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Defaulting the firmware version to '0.0.0' in sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.4') will cause the legacy RCIN9/RCIN10 mapping to be applied when the version is unknown; consider skipping the legacy behavior if the version is missing or unparsable instead.
  • To make the legacy cutoff clearer and easier to maintain, consider extracting the '4.5.4' version string into a named constant (e.g., LEGACY_SUB_LIGHTS_MAX_VERSION) near the legacy_sub_param_value_map definition and reusing it in the sem_ver_lte check.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Defaulting the firmware version to '0.0.0' in `sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.4')` will cause the legacy RCIN9/RCIN10 mapping to be applied when the version is unknown; consider skipping the legacy behavior if the version is missing or unparsable instead.
- To make the legacy cutoff clearer and easier to maintain, consider extracting the '4.5.4' version string into a named constant (e.g., `LEGACY_SUB_LIGHTS_MAX_VERSION`) near the `legacy_sub_param_value_map` definition and reusing it in the `sem_ver_lte` check.

## Individual Comments

### Comment 1
<location path="core/frontend/src/components/vehiclesetup/PwmSetup.vue" line_range="237-239" />
<code_context>
     }
   },
   computed: {
+    effective_param_value_map(): Dictionary<Dictionary<string>> {
+      const map = { ...param_value_map }
+      if (this.is_sub && sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.4')) {
+        map.Submarine = { ...legacy_sub_param_value_map, ...map.Submarine }
+      }
</code_context>
<issue_to_address>
**issue:** Defaulting to firmware version '0.0.0' risks misclassifying unknown or unparsable versions as legacy.

Using `'0.0.0'` as the fallback means any missing/unparsable `autopilot.firmware_info?.version` is treated as `<= 4.5.4`, so unknown versions silently get legacy behavior. That can hide issues when the version field is wrong or new firmware doesn’t match expectations. Consider either skipping the legacy map when the version is falsy/unparsable, or guarding `sem_ver_lte`/defaulting to a clearly non-legacy version so unknown versions don’t inherit legacy lights by default.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Collaborator

@ES-Alexander ES-Alexander left a comment

Choose a reason for hiding this comment

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

Code generally looks ok, though I haven't tested.

A couple of important comments:

computed: {
effective_param_value_map(): Dictionary<Dictionary<string>> {
const map = { ...param_value_map }
if (this.is_sub && sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.4')) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (this.is_sub && sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.4')) {
if (this.is_sub && sem_ver_lte(autopilot.firmware_info?.version ?? '0.0.0', '4.5.6')) {

According to the release notes and the tag diff, lights funcs were added in 4.5.6.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

bumped to 4.5.5, as we are using lower-than-equals

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants