Skip to content

Fix/camera config loading#34

Open
musyaree wants to merge 2 commits into
masterfrom
fix/camera-config-loading
Open

Fix/camera config loading#34
musyaree wants to merge 2 commits into
masterfrom
fix/camera-config-loading

Conversation

@musyaree
Copy link
Copy Markdown

@musyaree musyaree commented May 18, 2026

Jira Link:

Description

Fix camera config loading when camera starts

Describe problems, if any, clearly and concisely.
Describe any changes that have been made in this pull request.

Type of Change

  • Bugfix
  • Enhancement
  • New feature
  • Breaking change (fix or feature that would cause the existing functionality to not work as expected)

How Has This Been Tested?

  • New unit tests added.
  • Manual tested.

Checklist:

  • Using Branch Name Convention
    • feature/JIRA-ID-SHORT-DESCRIPTION if has a JIRA ticket
    • enhancement/SHORT-DESCRIPTION if has/has no JIRA ticket and contain enhancement
    • hotfix/SHORT-DESCRIPTION if the change doesn't need to be tested (urgent)
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made the documentation for the corresponding changes.

Comment on lines +37 to 47
for (int i = 0; i < 10; ++i) {
try {
camera_node->update();
break;
} catch (const std::exception & e) {
RCLCPP_WARN(node->get_logger(), "Waiting for camera to be ready...");
std::this_thread::sleep_for(100ms);
}
}

camera_node->load_configuration(path);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Load the configuration first before spinning up the node to avoid uninitialized variables.

  2. Worst-case scenario, the node will just keep running here even after 10 failures. We should use an initialized flag to explicitly track if the node is ready, and throw an error/abort if it still fails after the retries.

Comment on lines -212 to +237
// Get new capture setting from the camera
new_capture_setting.brightness = video_capture->get(cv::CAP_PROP_BRIGHTNESS);
new_capture_setting.contrast = video_capture->get(cv::CAP_PROP_CONTRAST);
new_capture_setting.saturation = video_capture->get(cv::CAP_PROP_SATURATION);
new_capture_setting.temperature = video_capture->get(cv::CAP_PROP_WB_TEMPERATURE);
new_capture_setting.exposure = video_capture->get(cv::CAP_PROP_EXPOSURE);
new_capture_setting.gain = video_capture->get(cv::CAP_PROP_GAIN);
// Get new capture setting from the camera if they were empty
if (new_capture_setting.brightness.is_empty()) {
new_capture_setting.brightness = video_capture->get(cv::CAP_PROP_BRIGHTNESS);
}

if (new_capture_setting.contrast.is_empty()) {
new_capture_setting.contrast = video_capture->get(cv::CAP_PROP_CONTRAST);
}

if (new_capture_setting.saturation.is_empty()) {
new_capture_setting.saturation = video_capture->get(cv::CAP_PROP_SATURATION);
}

if (new_capture_setting.temperature.is_empty()) {
new_capture_setting.temperature = video_capture->get(cv::CAP_PROP_WB_TEMPERATURE);
}

if (new_capture_setting.exposure.is_empty()) {
new_capture_setting.exposure = video_capture->get(cv::CAP_PROP_EXPOSURE);
}

if (new_capture_setting.gain.is_empty()) {
new_capture_setting.gain = video_capture->get(cv::CAP_PROP_GAIN);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Big No-No on this change. We can't guard these with is_empty(). The camera has its own internal value limits and hardware states, so we must always overwrite our local struct with the actual values coming from video_capture->get(). Please put the old logic back.

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