Skip to content

Commit 15ec4ff

Browse files
committed
Throw an exception in isRobotProtectiveStopped when no robot mode has been received, yet
1 parent 3cc3d4e commit 15ec4ff

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

include/ur_client_library/primary/primary_client.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ class PrimaryClient
188188
*
189189
* The robot's protective_stop state will be updated in the background. This will always show the latest received
190190
* state independent of the time that has passed since receiving it.
191+
*
192+
* \throws UrException when no robot mode data has been received, yet.
191193
*/
192194
bool isRobotProtectiveStopped()
193195
{
194196
std::shared_ptr<RobotModeData> robot_mode_data = consumer_->getRobotModeData();
195197
if (robot_mode_data == nullptr)
196198
{
197-
return false;
199+
throw UrException("Robot mode data is a nullptr. Probably it hasn't been received, yet.");
198200
}
199201
return robot_mode_data->is_protective_stopped_;
200202
}

tests/test_primary_client.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ TEST_F(PrimaryClientTest, test_uninitialized_primary_client)
128128
{
129129
// The client is not started yet, so the robot mode should be UNKNOWN
130130
ASSERT_EQ(client_->getRobotMode(), RobotMode::UNKNOWN);
131+
ASSERT_THROW(client_->isRobotProtectiveStopped(), UrException);
131132
}
132133

133134
TEST_F(PrimaryClientTest, test_stop_command)
@@ -189,4 +190,4 @@ int main(int argc, char* argv[])
189190
}
190191

191192
return RUN_ALL_TESTS();
192-
}
193+
}

0 commit comments

Comments
 (0)