diff --git a/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h b/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h index 6b417fa..99a699a 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h +++ b/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h @@ -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>& data_package, std::chrono::milliseconds timeout); + std::unique_ptr getDataPackage(std::chrono::milliseconds timeout); /*! * \brief Getter for the frequency the robot will publish RTDE data packages with. diff --git a/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h b/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h index 90b6c8f..be2f7b0 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h +++ b/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h @@ -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 getDataPackage(); diff --git a/ur_rtde_driver/src/rtde/rtde_client.cpp b/ur_rtde_driver/src/rtde/rtde_client.cpp index b533497..7a2340a 100644 --- a/ur_rtde_driver/src/rtde/rtde_client.cpp +++ b/ur_rtde_driver/src/rtde/rtde_client.cpp @@ -146,10 +146,19 @@ std::vector RTDEClient::readRecipe(const std::string& recipe_file) return recipe; } -bool RTDEClient::getDataPackage(std::unique_ptr>& data_package, - std::chrono::milliseconds timeout) +std::unique_ptr RTDEClient::getDataPackage(std::chrono::milliseconds timeout) { - return pipeline_.getLatestProduct(data_package, timeout); + std::unique_ptr> urpackage; + if (pipeline_.getLatestProduct(urpackage, timeout)) + { + rtde_interface::DataPackage* tmp = dynamic_cast(urpackage.get()); + if (tmp != nullptr) + { + urpackage.release(); + return std::unique_ptr(tmp); + } + } + return std::unique_ptr(nullptr); } std::string RTDEClient::getIP() const diff --git a/ur_rtde_driver/src/ur/ur_driver.cpp b/ur_rtde_driver/src/ur/ur_driver.cpp index 1774f4f..9923227 100644 --- a/ur_rtde_driver/src/ur/ur_driver.cpp +++ b/ur_rtde_driver/src/ur/ur_driver.cpp @@ -126,20 +126,9 @@ ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& sc std::unique_ptr ur_driver::UrDriver::getDataPackage() { - // TODO: This goes into the rtde_client - std::unique_ptr> 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(urpackage.get()); - if (tmp != nullptr) - { - urpackage.release(); - return std::unique_ptr(tmp); - } - } - return nullptr; + return rtde_client_->getDataPackage(timeout); } bool UrDriver::writeJointCommand(const vector6d_t& values)