Skip to content

Commit b6ba100

Browse files
committed
Use ExampleRobotWrapper in test_ur_driver
1 parent e40eb26 commit b6ba100

File tree

3 files changed

+82
-199
lines changed

3 files changed

+82
-199
lines changed

include/ur_client_library/example_robot_wrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ExampleRobotWrapper
2323
void startRTDECommununication(const bool consume_data = false);
2424
void startConsumingRTDEData();
2525
void stopConsumingRTDEData();
26+
bool readDataPackage(std::unique_ptr<rtde_interface::DataPackage>& data_pkg);
2627

2728
bool waitForProgramRunning(int milliseconds = 100);
2829
bool waitForProgramNotRunning(int milliseconds = 100);

src/example_robot_wrapper.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ void ExampleRobotWrapper::stopConsumingRTDEData()
101101
rtde_consumer_thread_.join();
102102
}
103103

104+
bool ExampleRobotWrapper::readDataPackage(std::unique_ptr<rtde_interface::DataPackage>& data_pkg)
105+
{
106+
if (consume_rtde_packages_ == true)
107+
{
108+
URCL_LOG_ERROR("Unable to read packages while consuming, this should not happen!");
109+
return false;
110+
}
111+
std::lock_guard<std::mutex> lk(read_package_mutex_);
112+
data_pkg = ur_driver_->getDataPackage();
113+
if (data_pkg == nullptr)
114+
{
115+
URCL_LOG_ERROR("Timed out waiting for a new package from the robot");
116+
return false;
117+
}
118+
return true;
119+
}
120+
104121
bool ExampleRobotWrapper::waitForProgramRunning(int milliseconds)
105122
{
106123
std::unique_lock<std::mutex> lk(program_running_mutex_);

0 commit comments

Comments
 (0)