Fix/camera config loading#34
Open
musyaree wants to merge 2 commits into
Open
Conversation
FaaizHaikal
requested changes
May 20, 2026
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); |
Contributor
There was a problem hiding this comment.
-
Load the configuration first before spinning up the node to avoid uninitialized variables.
-
Worst-case scenario, the node will just keep running here even after 10 failures. We should use an
initializedflag 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); | ||
| } |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
How Has This Been Tested?
Checklist:
feature/JIRA-ID-SHORT-DESCRIPTIONif has a JIRA ticketenhancement/SHORT-DESCRIPTIONif has/has no JIRA ticket and contain enhancementhotfix/SHORT-DESCRIPTIONif the change doesn't need to be tested (urgent)