Skip to content

Commit c6de57e

Browse files
committed
Make sure we wait for the trajectory interface to be stopped
1 parent ebe9eae commit c6de57e

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

include/ur_client_library/control/reverse_interface.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ class ReverseInterface
146146
disconnection_callback_ = disconnection_fun;
147147
}
148148

149+
/*!
150+
* \brief Checks if the reverse interface is connected to the robot.
151+
*
152+
* \returns True, if the interface is connected, false otherwise.
153+
*/
154+
bool isConnected() const
155+
{
156+
return client_fd_ != INVALID_SOCKET;
157+
}
158+
149159
protected:
150160
virtual void connectionCallback(const socket_t filedescriptor);
151161

include/ur_client_library/ur/ur_driver.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,16 @@ class UrDriver
880880
secondary_stream_->close();
881881
}
882882

883+
bool isReverseInterfaceConnected() const
884+
{
885+
return reverse_interface_->isConnected();
886+
}
887+
888+
bool isTrajectoryInterfaceConnected() const
889+
{
890+
return trajectory_interface_->isConnected();
891+
}
892+
883893
private:
884894
void init(const UrDriverConfiguration& config);
885895

src/control/trajectory_point_interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <ur_client_library/exceptions.h>
3131
#include <math.h>
3232
#include <stdexcept>
33+
#include "ur_client_library/comm/socket_t.h"
3334

3435
namespace urcl
3536
{
@@ -217,11 +218,11 @@ void TrajectoryPointInterface::connectionCallback(const socket_t filedescriptor)
217218
void TrajectoryPointInterface::disconnectionCallback(const socket_t filedescriptor)
218219
{
219220
URCL_LOG_DEBUG("Connection to trajectory interface dropped.");
220-
client_fd_ = -1;
221221
if (disconnection_callback_ != nullptr)
222222
{
223223
disconnection_callback_(filedescriptor);
224224
}
225+
client_fd_ = INVALID_SOCKET;
225226
}
226227

227228
void TrajectoryPointInterface::messageCallback(const socket_t filedescriptor, char* buffer, int nbytesrecv)

tests/test_instruction_executor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ class InstructionExecutorTest : public ::testing::Test
7272
ASSERT_TRUE(g_my_robot->waitForProgramRunning());
7373
}
7474
}
75-
void TearDown()
75+
void TearDown() override
7676
{
7777
g_my_robot->ur_driver_->stopControl();
7878
g_my_robot->waitForProgramNotRunning(1000);
79+
while (g_my_robot->ur_driver_->isTrajectoryInterfaceConnected())
80+
{
81+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
82+
}
83+
URCL_LOG_INFO("Stopped robot control.");
7984
}
8085

8186
static void TearDownTestSuite()

0 commit comments

Comments
 (0)