File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ Joy::Joy(const rclcpp::NodeOptions & options)
105
105
106
106
future_ = exit_signal_.get_future ();
107
107
108
+ if (SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0 ) {
109
+ throw std::runtime_error (" SDL could not be initialized: " + std::string (SDL_GetError ()));
110
+ }
108
111
// In theory we could do this with just a timer, which would simplify the code
109
112
// a bit. But then we couldn't react to "immediate" events, so we stick with
110
113
// the thread.
@@ -423,11 +426,6 @@ void Joy::eventThread()
423
426
rclcpp::Time last_publish = this ->now ();
424
427
425
428
do {
426
- if (joystick_ == nullptr ) {
427
- if (SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0 ) {
428
- throw std::runtime_error (" SDL could not be initialized: " + std::string (SDL_GetError ()));
429
- }
430
- }
431
429
432
430
bool should_publish = false ;
433
431
SDL_Event e;
@@ -475,10 +473,6 @@ void Joy::eventThread()
475
473
pub_->publish (joy_msg_);
476
474
}
477
475
478
- if (joystick_ == nullptr ) {
479
- SDL_Quit ();
480
- }
481
-
482
476
status = future_.wait_for (std::chrono::seconds (0 ));
483
477
} while (status == std::future_status::timeout);
484
478
}
You can’t perform that action at this time.
0 commit comments