Skip to content

Commit 3c07a1b

Browse files
committed
Add retry for getting software version
1 parent 7db74c3 commit 3c07a1b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ur_controllers/src/ur_configuration_controller.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,20 @@ bool URConfigurationController::getRobotSoftwareVersion(
119119
RCLCPP_WARN(get_node()->get_logger(), "Robot software version not set yet.");
120120
return false;
121121
}
122-
return robot_software_version_.try_get([resp](const std::shared_ptr<VersionInformation> ptr) {
122+
int tries = 0;
123+
while (!robot_software_version_.try_get([resp](const std::shared_ptr<VersionInformation> ptr) {
123124
resp->major = ptr->major;
124125
resp->minor = ptr->minor;
125126
resp->build = ptr->build;
126127
resp->bugfix = ptr->bugfix;
127-
});
128+
})) {
129+
if (tries > 10) {
130+
return false;
131+
}
132+
rclcpp::sleep_for(std::chrono::milliseconds(50));
133+
tries++;
134+
}
135+
return true;
128136
}
129137
} // namespace ur_controllers
130138

0 commit comments

Comments
 (0)