Misc fixes#181
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds cooperative stop-token plumbing for pathing/localization threads, adjusts camera worker thread ownership, and moves constants-copying out of the build script.
Changes:
- Converts several
std::threaduses tostd::jthreadand threadsstd::stop_tokenthrough pathing/localization entry points. - Adds a new stop utility header and updates main robot executables to wait on it.
- Updates camera frame-copying/thread internals and splits constants copying into a separate script.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/stop.h |
Adds signal/stop waiting helpers. |
src/unambiguous_first.cc |
Passes a stop token into pathing controller thread. |
src/test/integration_test/localization_test.cc |
Switches localization test threads to std::jthread and updated localization call signature. |
src/second_bot_main.cc |
Uses std::jthread, stop tokens, and stop wait helper in second bot main. |
src/pathing/controller.h |
Updates pathing controller API to accept a stop token. |
src/pathing/controller.cc |
Makes controller loop stop-token aware. |
src/main_bot_main.cc |
Uses std::jthread, stop tokens, and stop wait helper in main bot main. |
src/localization/run_localization.h |
Updates localization API signature. |
src/localization/run_localization.cc |
Updates localization implementation signature. |
src/camera/uvc_camera.cc |
Changes callback locking to non-blocking and fixes early-return unlocks. |
src/camera/select_camera.cc |
Makes UVC selection failure fatal. |
src/camera/multi_camera_source.h |
Changes camera worker storage to std::jthread. |
src/camera/multi_camera_source.cc |
Updates multi-camera worker lambdas for stop-token-compatible std::jthread. |
src/camera/camera_source.h |
Changes camera source worker storage to std::jthread. |
src/camera/camera_source.cc |
Makes camera source worker stop-token aware and deep-copies frames in Get(). |
scripts/copy_constants.sh |
Adds standalone constants-copy helper. |
scripts/build.sh |
Removes constants-copying from the build flow. |
Comments suppressed due to low confidence (3)
src/utils/stop.h:17
- This function is defined in a header without being marked
inline. Includingstop.hin more than one source file in the same target will produce multiple definitions at link time; move the implementation to a.ccfile or mark header-defined functions inline.
void SignalHander(int signal) {
src/utils/stop.h:22
- This function is defined in a header without being marked
inline. Includingstop.hin more than one source file in the same target will produce multiple definitions at link time; move the implementation to a.ccfile or mark header-defined functions inline.
void RegisterHandler() {
src/utils/stop.h:42
- This function is defined in a header without being marked
inline. Includingstop.hin more than one source file in the same target will produce multiple definitions at link time; move the implementation to a.ccfile or mark header-defined functions inline.
void WaitUntilStop() {
|
|
||
| // TODO remove extrinsics | ||
| void RunLocalization( | ||
| const std::stop_token& stop_token, |
Comment on lines
+14
to
+15
| [this, i](const std::stop_token& stop_token) -> void { | ||
| while (true) { |
| left_thread.join(); | ||
| right_thread.join(); | ||
| pathing_thread.join(); | ||
| stop::WaitUntilStop(); |
|
|
||
| left_thread.join(); | ||
| pathing_thread.join(); | ||
| stop::WaitUntilStop(); |
| std::atomic<bool> stop(false); | ||
| std::atomic<bool> registered_handler(false); | ||
|
|
||
| void SignalHander(int signal) { |
| std::vector<frc::Pose2d> spline_points; | ||
|
|
||
| while (true) { | ||
| while (!stop_token.stop_requested()) { |
Comment on lines
21
to
22
| std::jthread thread_; | ||
| std::mutex mutex_; |
Comment on lines
23
to
24
| std::vector<std::jthread> camera_threads_; | ||
| std::mutex mutex_; |
Comment on lines
+28
to
+36
| std::signal(SIGILL, SignalHander); | ||
| std::signal(SIGABRT, SignalHander); | ||
| std::signal(SIGFPE, SignalHander); | ||
| std::signal(SIGSEGV, SignalHander); | ||
| std::signal(SIGTERM, SignalHander); | ||
| std::signal(SIGHUP, SignalHander); | ||
| std::signal(SIGQUIT, SignalHander); | ||
| // std::signal(SIGTRAP, SignalHander); | ||
| std::signal(SIGKILL, SignalHander); |
Comment on lines
+25
to
+30
| const std::stop_token& stop_token, | ||
| std::unique_ptr<camera::CameraSource> source, | ||
| std::unique_ptr<localization::IAprilTagDetector> detector, | ||
| std::unique_ptr<localization::IPositionSolver> solver, | ||
| std::vector<std::unique_ptr<localization::IPositionSender>> sender, | ||
| const std::string& extrinsics, std::optional<uint> port = std::nullopt, | ||
| bool verbose = false); | ||
| std::optional<uint> port = std::nullopt, bool verbose = false); |
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.
No description provided.