-
Notifications
You must be signed in to change notification settings - Fork 276
Add reboot service #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add reboot service #359
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -290,6 +290,11 @@ void ZedCamera::initServices() | |||||||||||
|
|
||||||||||||
| std::string srv_prefix = "~/"; | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| srv_name = srv_prefix + mSrvReboot; | ||||||||||||
| mRebootSrv = create_service<std_srvs::srv::Trigger>( | ||||||||||||
| srv_name, std::bind(&ZedCamera::callback_reboot, this, _1, _2, _3)); | ||||||||||||
|
|
||||||||||||
| if (!mDepthDisabled) { | ||||||||||||
| // Reset Odometry | ||||||||||||
| srv_name = srv_prefix + mSrvResetOdomName; | ||||||||||||
|
|
@@ -3312,6 +3317,94 @@ void ZedCamera::initThreads() | |||||||||||
| mGrabThread = std::thread(&ZedCamera::threadFunc_zedGrab, this); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| bool ZedCamera::restartCamera() { | ||||||||||||
| sl_tools::StopWatch connectTimer(get_clock()); | ||||||||||||
|
|
||||||||||||
| RCLCPP_INFO(get_logger(), "=== RESTARTING CAMERA ==="); | ||||||||||||
|
|
||||||||||||
| // Wait longer for GMSL camera connection | ||||||||||||
| int camera_timeout_sec = sl_tools::isZEDX(mCamRealModel) ? 15: mCamTimeoutSec; | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| while (1) { | ||||||||||||
|
||||||||||||
| while (1) { | |
| while (true) { |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the debug message: 'successfull' should be 'successful'.
| DEBUG_STREAM_COMM("Opening successfull"); | |
| DEBUG_STREAM_COMM("Opening successful"); |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return false; statement on line 3381 is unreachable code because the infinite while (1) loop on line 3329 only exits via return statements inside the loop.
| return false; |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent here. The code inside the if statement has extra spaces that don't match the project's indentation style.
| mRebootCondVar.notify_all(); | |
| mRebootCondVar.notify_all(); |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent here. The code inside the scope has extra spaces that don't match the project's indentation style.
| std::lock_guard<std::mutex> lock(mRebootMutex); | |
| mCameraRebooting = false; | |
| std::lock_guard<std::mutex> lock(mRebootMutex); | |
| mCameraRebooting = false; |
Copilot
AI
Jul 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Joining the restart thread while holding mRebootMutex can lead to deadlocks or block other camera threads. Consider moving the join() call outside the locked section or unlocking before joining.
| if (mRestartThread.joinable()) { | |
| bool shouldJoin = mRestartThread.joinable(); | |
| lock.unlock(); | |
| if (shouldJoin) { |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent here. This line has extra spaces that don't match the surrounding code's indentation style.
| ++activeUsers; | |
| ++activeUsers; |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is inconsistent here. The code inside the scope has extra spaces that don't match the project's indentation style.
| std::lock_guard<std::mutex> lock(mRebootMutex); | |
| mCameraRebooting = true; | |
| std::lock_guard<std::mutex> lock(mRebootMutex); | |
| mCameraRebooting = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number
15should be defined as a named constant (e.g.,ZEDX_CAMERA_TIMEOUT_SEC) to improve code maintainability and make the special timeout value for ZEDX cameras more explicit.