3232
3333#include " test_utils.h"
3434#include " ur_client_library/example_robot_wrapper.h"
35+ #include " ur_client_library/log.h"
3536
3637using namespace urcl ;
3738
@@ -74,6 +75,15 @@ class ExternalControlProgramTest : public ::testing::Test
7475 ASSERT_TRUE (g_my_robot->resendRobotProgram ());
7576 ASSERT_TRUE (g_my_robot->waitForProgramRunning (500 ));
7677 }
78+ server_.reset (new comm::TCPServer (60005 ));
79+ server_->setConnectCallback (
80+ std::bind (&ExternalControlProgramTest::connectionCallback, this , std::placeholders::_1));
81+ server_->start ();
82+ }
83+
84+ void TearDown () override
85+ {
86+ server_.reset ();
7787 }
7888
7989 std::string extendScript (const std::string& script_path)
@@ -117,6 +127,7 @@ class ExternalControlProgramTest : public ::testing::Test
117127 return false ;
118128 }
119129 }
130+ std::unique_ptr<comm::TCPServer> server_;
120131
121132private:
122133 std::condition_variable connect_cv_;
@@ -129,21 +140,17 @@ TEST_F(ExternalControlProgramTest, program_halts_on_timeout)
129140{
130141 vector6d_t zeros = { 0 , 0 , 0 , 0 , 0 , 0 };
131142 g_my_robot->getUrDriver ()->writeJointCommand (zeros, comm::ControlMode::MODE_IDLE , RobotReceiveTimeout::millisec (200 ));
132- EXPECT_TRUE (g_my_robot-> waitForProgramNotRunning ( 400 ));
143+ EXPECT_FALSE ( waitForConnectionCallback ( 1000 ));
133144}
134145
135146TEST_F (ExternalControlProgramTest, stop_control_does_not_halt_program)
136147{
137- comm::TCPServer server (60005 );
138- server.setConnectCallback (std::bind (&ExternalControlProgramTest::connectionCallback, this , std::placeholders::_1));
139- server.start ();
140-
141148 vector6d_t zeros = { 0 , 0 , 0 , 0 , 0 , 0 };
142149 g_my_robot->getUrDriver ()->writeJointCommand (zeros, comm::ControlMode::MODE_IDLE , RobotReceiveTimeout::off ());
143150
144151 // Make sure that we can stop the robot control, when robot receive timeout has been set off
145152 g_my_robot->getUrDriver ()->stopControl ();
146- EXPECT_TRUE (waitForConnectionCallback ());
153+ EXPECT_TRUE (waitForConnectionCallback (1000 ));
147154}
148155
149156int main (int argc, char * argv[])
0 commit comments