mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-09 17:40:47 +02:00
Use secondary port with secondary program for sending custom script messages
This commit is contained in:
committed by
Tristan Schnell
parent
7597c9fa6c
commit
2d78248760
@@ -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,
|
||||
|
||||
@@ -140,6 +140,7 @@ private:
|
||||
std::unique_ptr<comm::ReverseInterface> reverse_interface_;
|
||||
std::unique_ptr<comm::ScriptSender> script_sender_;
|
||||
std::unique_ptr<comm::URStream<ur_driver::primary_interface::PackageHeader>> primary_stream_;
|
||||
std::unique_ptr<comm::URStream<ur_driver::primary_interface::PackageHeader>> secondary_stream_;
|
||||
|
||||
double servoj_time_;
|
||||
uint32_t servoj_gain_;
|
||||
|
||||
@@ -63,6 +63,9 @@ ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& sc
|
||||
|
||||
primary_stream_.reset(new comm::URStream<ur_driver::primary_interface::PackageHeader>(
|
||||
robot_ip_, ur_driver::primary_interface::UR_PRIMARY_PORT));
|
||||
secondary_stream_.reset(new comm::URStream<ur_driver::primary_interface::PackageHeader>(
|
||||
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<const uint8_t*>(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;
|
||||
|
||||
Reference in New Issue
Block a user