1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-09 17:40:47 +02:00

Moved getDataPackage functionality to rtde_client

This commit is contained in:
Felix Mauch
2019-09-25 11:35:53 +02:00
committed by Tristan Schnell
parent ac28aa43c6
commit 62146a49ae
4 changed files with 17 additions and 20 deletions

View File

@@ -84,12 +84,11 @@ public:
/*!
* \brief Reads the pipeline to fetch the next data package.
*
* \param data_package Pointer to set to the next data package
* \param timeout Time to wait if no data package is currently in the queue
*
* \returns True, if a package was fetched successfully
* \returns Unique ptr to the package, if a package was fetched successfully, nullptr otherwise
*/
bool getDataPackage(std::unique_ptr<comm::URPackage<PackageHeader>>& data_package, std::chrono::milliseconds timeout);
std::unique_ptr<rtde_interface::DataPackage> getDataPackage(std::chrono::milliseconds timeout);
/*!
* \brief Getter for the frequency the robot will publish RTDE data packages with.

View File

@@ -85,8 +85,8 @@ public:
* \brief Access function to receive the latest data package sent from the robot through RTDE
* interface.
*
* \returns The latest data package on success, a nullptr if no package can be found inside the
* interface's cycle time. See the private parameter #rtde_frequency_
* \returns The latest data package on success, a nullptr if no package can be found inside a preconfigured time
* window.
*/
std::unique_ptr<rtde_interface::DataPackage> getDataPackage();

View File

@@ -146,10 +146,19 @@ std::vector<std::string> RTDEClient::readRecipe(const std::string& recipe_file)
return recipe;
}
bool RTDEClient::getDataPackage(std::unique_ptr<comm::URPackage<PackageHeader>>& data_package,
std::chrono::milliseconds timeout)
std::unique_ptr<rtde_interface::DataPackage> RTDEClient::getDataPackage(std::chrono::milliseconds timeout)
{
return pipeline_.getLatestProduct(data_package, timeout);
std::unique_ptr<comm::URPackage<rtde_interface::PackageHeader>> urpackage;
if (pipeline_.getLatestProduct(urpackage, timeout))
{
rtde_interface::DataPackage* tmp = dynamic_cast<rtde_interface::DataPackage*>(urpackage.get());
if (tmp != nullptr)
{
urpackage.release();
return std::unique_ptr<rtde_interface::DataPackage>(tmp);
}
}
return std::unique_ptr<rtde_interface::DataPackage>(nullptr);
}
std::string RTDEClient::getIP() const

View File

@@ -126,20 +126,9 @@ ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& sc
std::unique_ptr<rtde_interface::DataPackage> ur_driver::UrDriver::getDataPackage()
{
// TODO: This goes into the rtde_client
std::unique_ptr<comm::URPackage<rtde_interface::PackageHeader>> urpackage;
std::chrono::milliseconds timeout(100); // We deliberately have a quite large timeout here, as the robot itself
// should command the control loop's timing.
if (rtde_client_->getDataPackage(urpackage, timeout))
{
rtde_interface::DataPackage* tmp = dynamic_cast<rtde_interface::DataPackage*>(urpackage.get());
if (tmp != nullptr)
{
urpackage.release();
return std::unique_ptr<rtde_interface::DataPackage>(tmp);
}
}
return nullptr;
return rtde_client_->getDataPackage(timeout);
}
bool UrDriver::writeJointCommand(const vector6d_t& values)