Skip to content

Commit 8e74347

Browse files
committed
RTDEClient: pause and stop in destructor only if running
Otherwise we produce an error when destructing an initialized, but non-started client.
1 parent fd2fda3 commit 8e74347

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/rtde/rtde_client.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ void RTDEClient::queryURControlVersion()
256256

257257
void RTDEClient::resetOutputRecipe(const std::vector<std::string> new_recipe)
258258
{
259-
prod_->teardownProducer();
260259
disconnect();
261260

262261
output_recipe_.assign(new_recipe.begin(), new_recipe.end());
@@ -445,10 +444,16 @@ void RTDEClient::setupInputs()
445444
void RTDEClient::disconnect()
446445
{
447446
// If communication is started it should be paused before disconnecting
448-
if (client_state_ > ClientState::UNINITIALIZED)
447+
if (client_state_ == ClientState::RUNNING)
448+
{
449+
pause();
450+
}
451+
if (client_state_ >= ClientState::INITIALIZING)
449452
{
450-
sendPause();
451453
pipeline_->stop();
454+
}
455+
if (client_state_ > ClientState::UNINITIALIZED)
456+
{
452457
stream_.disconnect();
453458
}
454459
client_state_ = ClientState::UNINITIALIZED;

tests/test_rtde_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ TEST_F(RTDEClientTest, check_all_rtde_output_variables_exist)
380380
client_.reset(new rtde_interface::RTDEClient(g_ROBOT_IP, notifier_, exhaustive_output_recipe_file_,
381381
input_recipe_file_, 0.0, true));
382382

383-
EXPECT_NO_THROW(client_->init());
383+
EXPECT_TRUE(client_->init());
384384
client_->start();
385385

386386
// Test that we can receive and parse the timestamp from the received package to prove the setup was successful

0 commit comments

Comments
 (0)