diff --git a/ur_rtde_driver/include/ur_rtde_driver/primary/package_header.h b/ur_rtde_driver/include/ur_rtde_driver/primary/package_header.h index fa25fad..e99555c 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/primary/package_header.h +++ b/ur_rtde_driver/include/ur_rtde_driver/primary/package_header.h @@ -39,6 +39,7 @@ namespace ur_driver namespace primary_interface { static const int UR_PRIMARY_PORT = 30001; +static const int UR_SECONDARY_PORT = 30002; enum class RobotPackageType : int8_t { DISCONNECT = -1, 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 13659a4..554cde0 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 @@ -140,6 +140,7 @@ private: std::unique_ptr reverse_interface_; std::unique_ptr script_sender_; std::unique_ptr> primary_stream_; + std::unique_ptr> secondary_stream_; double servoj_time_; uint32_t servoj_gain_; diff --git a/ur_rtde_driver/src/ur/ur_driver.cpp b/ur_rtde_driver/src/ur/ur_driver.cpp index f7f3465..1774f4f 100644 --- a/ur_rtde_driver/src/ur/ur_driver.cpp +++ b/ur_rtde_driver/src/ur/ur_driver.cpp @@ -63,6 +63,9 @@ ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& sc primary_stream_.reset(new comm::URStream( robot_ip_, ur_driver::primary_interface::UR_PRIMARY_PORT)); + secondary_stream_.reset(new comm::URStream( + robot_ip_, ur_driver::primary_interface::UR_SECONDARY_PORT)); + secondary_stream_->connect(); LOG_INFO("Checking if calibration data matches connected robot."); checkCalibration(calibration_checksum); @@ -246,16 +249,17 @@ rtde_interface::RTDEWriter& UrDriver::getRTDEWriter() bool UrDriver::sendScript(const std::string& program) { - if (primary_stream_ == nullptr) + if (secondary_stream_ == nullptr) { throw std::runtime_error("Sending script to robot requested while there is no primary interface established. This " "should not happen."); } + size_t len = program.size(); const uint8_t* data = reinterpret_cast(program.c_str()); size_t written; - if (primary_stream_->write(data, len, written)) + if (secondary_stream_->write(data, len, written)) { LOG_DEBUG("Sent program to robot"); return true;