Skip to content

Optimize actuator control signal retrieval - #172

Open
jonyMarino wants to merge 1 commit into
mainfrom
enhacement/actuator_performance
Open

Optimize actuator control signal retrieval#172
jonyMarino wants to merge 1 commit into
mainfrom
enhacement/actuator_performance

Conversation

@jonyMarino

Copy link
Copy Markdown
Contributor

About

This PR optimizes how actuator control signals are retrieved during simulation updates.

Previously, every actuator requested its control signals by actuator ID on every update. This required repeated map lookups and, depending on the controller, repeated locks and temporary vector allocations.

This change:

  • Resolves and caches control-signal indices when the controller is assigned to the robot.
  • Retrieves a single, consistent snapshot of all control signals per simulation tick.
  • Reuses the snapshot buffer between updates.
  • Uses cached indices to access signals directly from the snapshot.
  • Uses a fixed-size std::array when passing signals to actuators.
  • Supports actuators that require multiple signals:
    • Wheels cache throttle, steering, and brake indices.
    • Other actuators cache one signal index.
  • Makes GetControlSignals(int signal_index) return exactly one signal.
  • Keeps the actuator-ID getter for backward compatibility.
  • Updates all existing controller implementations to support snapshots.
  • Adds tests for single-signal and multi-signal index caching.

This removes repeated map lookups, virtual calls, locks, and dynamic allocations from the actuator update loop. It also ensures that every actuator consumes signals from the same controller state during a simulation tick.

How Has This Been Tested?

The following targets were successfully built and linked on Windows:

  • core_sim
  • multirotor_api
  • rover_api
  • core_sim_gtests
  • multirotor_api_gtests
  • rover_api_gtests

Test results:

  • core_sim: 277 tests passed.
  • multirotor_api: 1 test passed.
  • rover_api: test executable passed; no tests are currently registered.
  • Added coverage verifying that:
    • Single-signal actuators cache their controller signal index.
    • Wheel actuators cache all three signal indices.
    • Signal-index lookup only occurs when assigning the controller.
  • git diff --check completed successfully.

Screenshots and videos (if appropriate):

Not applicable. This PR only changes internal control-signal handling and does not introduce visual changes.

@jonyMarino
jonyMarino marked this pull request as ready for review July 30, 2026 17:56
@github-actions

Copy link
Copy Markdown

❌ ProjectAirSim Self-Hosted CI

  • Status: failure
  • Pytest results: tests=N/A, failures=N/A, errors=N/A, skipped=N/A
  • Artifacts: test-results

View full workflow run

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.

1 participant