Skip to content

Misc fixes#181

Merged
charliehuang09 merged 10 commits into
mainfrom
misc-fixes
May 19, 2026
Merged

Misc fixes#181
charliehuang09 merged 10 commits into
mainfrom
misc-fixes

Conversation

@charliehuang09
Copy link
Copy Markdown
Collaborator

No description provided.

Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Copilot AI review requested due to automatic review settings May 16, 2026 21:45
Copy link
Copy Markdown
Contributor

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 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::thread uses to std::jthread and threads std::stop_token through 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. Including stop.h in more than one source file in the same target will produce multiple definitions at link time; move the implementation to a .cc file 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. Including stop.h in more than one source file in the same target will produce multiple definitions at link time; move the implementation to a .cc file or mark header-defined functions inline.
void RegisterHandler() {

src/utils/stop.h:42

  • This function is defined in a header without being marked inline. Including stop.h in more than one source file in the same target will produce multiple definitions at link time; move the implementation to a .cc file or mark header-defined functions inline.
void WaitUntilStop() {


// TODO remove extrinsics
void RunLocalization(
const std::stop_token& stop_token,
Comment thread src/camera/multi_camera_source.cc Outdated
Comment on lines +14 to +15
[this, i](const std::stop_token& stop_token) -> void {
while (true) {
Comment thread src/main_bot_main.cc
left_thread.join();
right_thread.join();
pathing_thread.join();
stop::WaitUntilStop();
Comment thread src/second_bot_main.cc

left_thread.join();
pathing_thread.join();
stop::WaitUntilStop();
Comment thread src/utils/stop.h Outdated
std::atomic<bool> stop(false);
std::atomic<bool> registered_handler(false);

void SignalHander(int signal) {
Comment thread src/pathing/controller.cc
std::vector<frc::Pose2d> spline_points;

while (true) {
while (!stop_token.stop_requested()) {
Comment thread src/camera/camera_source.h Outdated
Comment on lines 21 to 22
std::jthread thread_;
std::mutex mutex_;
Comment thread src/camera/multi_camera_source.h Outdated
Comment on lines 23 to 24
std::vector<std::jthread> camera_threads_;
std::mutex mutex_;
Comment thread src/utils/stop.h Outdated
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);
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
Signed-off-by: Charlie Huang <charliehuang09@gmail.com>
@charliehuang09 charliehuang09 merged commit 4db7fbe into main May 19, 2026
1 check passed
@charliehuang09 charliehuang09 deleted the misc-fixes branch May 19, 2026 21:49
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