Skip to content

Commit bc556e6

Browse files
committed
Fix RobotWrapper shutdown regarting consumer thread
1 parent b6ba100 commit bc556e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

include/ur_client_library/example_robot_wrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ExampleRobotWrapper
1717
ExampleRobotWrapper(const std::string& robot_ip, const std::string& output_recipe_file,
1818
const std::string& input_recipe_file, const bool headless_mode = true,
1919
const std::string& autostart_program = "", const std::string& script_file = SCRIPT_FILE);
20+
~ExampleRobotWrapper();
2021

2122
void initializeRobotWithDashboard();
2223

src/example_robot_wrapper.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ ExampleRobotWrapper::ExampleRobotWrapper(const std::string& robot_ip, const std:
2828
startRobotProgram(autostart_program);
2929
}
3030
}
31+
32+
ExampleRobotWrapper::~ExampleRobotWrapper()
33+
{
34+
if (rtde_communication_started_)
35+
{
36+
stopConsumingRTDEData();
37+
}
38+
}
3139
void ExampleRobotWrapper::initializeRobotWithDashboard()
3240
{
3341
// // Stop program, if there is one running
@@ -97,8 +105,14 @@ void ExampleRobotWrapper::startConsumingRTDEData()
97105

98106
void ExampleRobotWrapper::stopConsumingRTDEData()
99107
{
100-
consume_rtde_packages_ = false;
101-
rtde_consumer_thread_.join();
108+
if (consume_rtde_packages_)
109+
{
110+
consume_rtde_packages_ = false;
111+
if (rtde_consumer_thread_.joinable())
112+
{
113+
rtde_consumer_thread_.join();
114+
}
115+
}
102116
}
103117

104118
bool ExampleRobotWrapper::readDataPackage(std::unique_ptr<rtde_interface::DataPackage>& data_pkg)

0 commit comments

Comments
 (0)