Skip to content

Conversation

@jonyMarino
Copy link
Contributor

Fixes: #

About

This pull request makes a small change to the way control signals are returned in the ArduCopterApi::GetControlSignals method. Instead of copying the entire vector, it now returns a vector containing only a single control output value.

  • Changed ArduCopterApi::GetControlSignals in arducopter_api.cpp to return a vector with a single element (the mapped control output), rather than copying the entire vector.

How Has This Been Tested?

Screenshots and videos (if appropriate):

@jonyMarino jonyMarino requested a review from Copilot November 24, 2025 00:49
Copilot finished reviewing on behalf of jonyMarino November 24, 2025 00:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the ArduCopterApi::GetControlSignals method where the vector constructor was being used incorrectly. The old code attempted to use a float value as the size parameter for the vector constructor, which would create an empty or incorrectly-sized vector. The fix aligns the implementation with other controller APIs (MavLinkApi, ManualControllerApi, MatlabControllerApi, SimpleFlightApi) by using the two-parameter vector constructor to create a single-element vector containing the control output value.

Key changes:

  • Fixed vector instantiation in GetControlSignals to use std::vector<float>(1, value) instead of std::vector<float>(value)
  • Minor whitespace adjustment at end of file


// std::lock_guard<std::mutex> guard(hil_controls_mutex_);
return std::vector<float>(control_outputs_[actuator_map_itr->second]);
return std::vector<float>(1,control_outputs_[actuator_map_itr->second]);
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a space after the comma for consistency with similar code in MavLinkApi (line 392) and ManualControllerApi (line 50): std::vector<float>(1, control_outputs_[...])

Suggested change
return std::vector<float>(1,control_outputs_[actuator_map_itr->second]);
return std::vector<float>(1, control_outputs_[actuator_map_itr->second]);

Copilot uses AI. Check for mistakes.
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