ur_driver.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // Copyright 2019 FZI Forschungszentrum Informatik
5 // Created on behalf of Universal Robots A/S
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 // Many parts from this (Most of the URScript program) comes from the ur_modern_driver
20 // Copyright 2017, 2018 Simon Rasmussen (refactor)
21 // Copyright 2015, 2016 Thomas Timm Andersen (original version)
22 //
23 // -- END LICENSE BLOCK ------------------------------------------------
24 
25 //----------------------------------------------------------------------
32 //----------------------------------------------------------------------
33 
37 #include <memory>
38 #include <sstream>
39 
41 
42 namespace urcl
43 {
44 static const std::string BEGIN_REPLACE("{{BEGIN_REPLACE}}");
45 static const std::string JOINT_STATE_REPLACE("{{JOINT_STATE_REPLACE}}");
46 static const std::string TIME_REPLACE("{{TIME_REPLACE}}");
47 static const std::string SERVO_J_REPLACE("{{SERVO_J_REPLACE}}");
48 static const std::string SERVER_IP_REPLACE("{{SERVER_IP_REPLACE}}");
49 static const std::string SERVER_PORT_REPLACE("{{SERVER_PORT_REPLACE}}");
50 static const std::string TRAJECTORY_PORT_REPLACE("{{TRAJECTORY_SERVER_PORT_REPLACE}}");
51 static const std::string SCRIPT_COMMAND_PORT_REPLACE("{{SCRIPT_COMMAND_SERVER_PORT_REPLACE}}");
52 static const std::string FORCE_MODE_SET_DAMPING_REPLACE("{{FORCE_MODE_SET_DAMPING_REPLACE}}");
53 static const std::string FORCE_MODE_SET_GAIN_SCALING_REPLACE("{{FORCE_MODE_SET_GAIN_SCALING_REPLACE}}");
54 
56 {
57  robot_ip_ = config.robot_ip;
59  servoj_gain_ = config.servoj_gain;
67 
68  URCL_LOG_DEBUG("Initializing urdriver");
69  URCL_LOG_DEBUG("Initializing RTDE client");
70  rtde_client_.reset(
72 
74 
76 
77  initRTDE();
79 
80  // Figure out the ip automatically if the user didn't provide it
81  std::string local_ip = config.reverse_ip.empty() ? rtde_client_->getIP() : config.reverse_ip;
82 
83  std::string prog = readScriptFile(config.script_file);
84  while (prog.find(JOINT_STATE_REPLACE) != std::string::npos)
85  {
86  prog.replace(prog.find(JOINT_STATE_REPLACE), JOINT_STATE_REPLACE.length(),
88  }
89  while (prog.find(TIME_REPLACE) != std::string::npos)
90  {
91  prog.replace(prog.find(TIME_REPLACE), TIME_REPLACE.length(),
93  }
94 
95  std::ostringstream out;
96  out << "lookahead_time=" << servoj_lookahead_time_ << ", gain=" << servoj_gain_;
97  while (prog.find(SERVO_J_REPLACE) != std::string::npos)
98  {
99  prog.replace(prog.find(SERVO_J_REPLACE), SERVO_J_REPLACE.length(), out.str());
100  }
101 
102  while (prog.find(SERVER_IP_REPLACE) != std::string::npos)
103  {
104  prog.replace(prog.find(SERVER_IP_REPLACE), SERVER_IP_REPLACE.length(), local_ip);
105  }
106 
107  while (prog.find(SERVER_PORT_REPLACE) != std::string::npos)
108  {
109  prog.replace(prog.find(SERVER_PORT_REPLACE), SERVER_PORT_REPLACE.length(), std::to_string(config.reverse_port));
110  }
111 
112  while (prog.find(TRAJECTORY_PORT_REPLACE) != std::string::npos)
113  {
114  prog.replace(prog.find(TRAJECTORY_PORT_REPLACE), TRAJECTORY_PORT_REPLACE.length(),
115  std::to_string(config.trajectory_port));
116  }
117 
118  while (prog.find(SCRIPT_COMMAND_PORT_REPLACE) != std::string::npos)
119  {
120  prog.replace(prog.find(SCRIPT_COMMAND_PORT_REPLACE), SCRIPT_COMMAND_PORT_REPLACE.length(),
121  std::to_string(config.script_command_port));
122  }
123 
124  robot_version_ = rtde_client_->getVersion();
125 
126  std::stringstream begin_replace;
127  if (config.tool_comm_setup != nullptr)
128  {
129  if (robot_version_.major < 5)
130  {
131  throw ToolCommNotAvailable("Tool communication setup requested, but this robot version does not support using "
132  "the tool communication interface. Please check your configuration.",
133  5, robot_version_.major);
134  }
135  begin_replace << "set_tool_voltage("
136  << static_cast<std::underlying_type<ToolVoltage>::type>(config.tool_comm_setup->getToolVoltage())
137  << ")\n";
138  begin_replace << "set_tool_communication(" << "True" << ", " << config.tool_comm_setup->getBaudRate() << ", "
139  << static_cast<std::underlying_type<Parity>::type>(config.tool_comm_setup->getParity()) << ", "
140  << config.tool_comm_setup->getStopBits() << ", " << config.tool_comm_setup->getRxIdleChars() << ", "
141  << config.tool_comm_setup->getTxIdleChars() << ")";
142  }
143  prog.replace(prog.find(BEGIN_REPLACE), BEGIN_REPLACE.length(), begin_replace.str());
144 
147 
149  if (in_headless_mode_)
150  {
151  full_robot_program_ = "stop program\n";
152  full_robot_program_ += "def externalControl():\n";
153  std::istringstream prog_stream(prog);
154  std::string line;
155  while (std::getline(prog_stream, line))
156  {
157  full_robot_program_ += "\t" + line + "\n";
158  }
159  full_robot_program_ += "end\n";
161  }
162  else
163  {
165  URCL_LOG_DEBUG("Created script sender");
166  }
167 
168  if (!std::empty(config.calibration_checksum))
169  {
170  URCL_LOG_WARN("DEPRECATION NOTICE: Passing the calibration_checksum to the UrDriver's constructor has been "
171  "deprecated. Instead, use the checkCalibration(calibration_checksum) function separately. This "
172  "notice is for application developers using this library. If you are only using an application using "
173  "this library, you can ignore this message.");
175  {
176  URCL_LOG_INFO("Calibration checked successfully.");
177  }
178  else
179  {
180  URCL_LOG_ERROR("The calibration parameters of the connected robot don't match the ones from the given kinematics "
181  "config file. Please be aware that this can lead to critical inaccuracies of tcp positions. Use "
182  "the ur_calibration tool to extract the correct calibration from the robot and pass that into the "
183  "description. See "
184  "[https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#extract-calibration-information] "
185  "for details.");
186  }
187  }
188  URCL_LOG_DEBUG("Initialization done");
189 }
190 
191 std::unique_ptr<rtde_interface::DataPackage> urcl::UrDriver::getDataPackage()
192 {
193  // This can take one of two values, 0ms or 100ms. The large timeout is for when the robot is commanding the control
194  // loop's timing (read is blocking). The zero timeout is for when the robot is sharing a control loop with
195  // something else (combined_robot_hw)
196  std::chrono::milliseconds timeout(get_packet_timeout_);
197 
198  return rtde_client_->getDataPackage(timeout);
199 }
200 
201 bool UrDriver::writeJointCommand(const vector6d_t& values, const comm::ControlMode control_mode,
202  const RobotReceiveTimeout& robot_receive_timeout)
203 {
204  return reverse_interface_->write(&values, control_mode, robot_receive_timeout);
205 }
206 
207 bool UrDriver::writeTrajectoryPoint(const vector6d_t& positions, const float acceleration, const float velocity,
208  const bool cartesian, const float goal_time, const float blend_radius)
209 {
210  return trajectory_interface_->writeTrajectoryPoint(&positions, acceleration, velocity, goal_time, blend_radius,
211  cartesian);
212 }
213 
214 bool UrDriver::writeTrajectoryPoint(const vector6d_t& positions, const bool cartesian, const float goal_time,
215  const float blend_radius)
216 {
217  return trajectory_interface_->writeTrajectoryPoint(&positions, goal_time, blend_radius, cartesian);
218 }
219 
220 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const vector6d_t& velocities,
221  const vector6d_t& accelerations, const float goal_time)
222 {
223  return trajectory_interface_->writeTrajectorySplinePoint(&positions, &velocities, &accelerations, goal_time);
224 }
225 
226 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const vector6d_t& velocities,
227  const float goal_time)
228 {
229  return trajectory_interface_->writeTrajectorySplinePoint(&positions, &velocities, nullptr, goal_time);
230 }
231 
232 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const float goal_time)
233 {
234  return trajectory_interface_->writeTrajectorySplinePoint(&positions, nullptr, nullptr, goal_time);
235 }
236 
238  const int point_number, const RobotReceiveTimeout& robot_receive_timeout)
239 {
240  return reverse_interface_->writeTrajectoryControlMessage(trajectory_action, point_number, robot_receive_timeout);
241 }
242 
243 bool UrDriver::writeMotionPrimitive(const std::shared_ptr<control::MotionPrimitive> motion_instruction)
244 {
245  return trajectory_interface_->writeMotionPrimitive(motion_instruction);
246 }
247 
249  const RobotReceiveTimeout& robot_receive_timeout)
250 {
251  return reverse_interface_->writeFreedriveControlMessage(freedrive_action, robot_receive_timeout);
252 }
253 
255 {
256  if (getVersion().major < 5)
257  {
258  std::stringstream ss;
259  ss << "Zeroing the Force-Torque sensor is only available for e-Series robots (Major version >= 5). This robot's "
260  "version is "
261  << getVersion();
262  URCL_LOG_ERROR(ss.str().c_str());
263  return false;
264  }
265  else
266  {
267  if (script_command_interface_->clientConnected())
268  {
269  return script_command_interface_->zeroFTSensor();
270  }
271  else
272  {
273  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. This will "
274  "only work, if the robot is in remote_control mode.");
275  std::stringstream cmd;
276  cmd << "sec tareSetup():" << std::endl << " zero_ftsensor()" << std::endl << "end";
277  return sendScript(cmd.str());
278  }
279  }
280 }
281 
282 bool UrDriver::setPayload(const float mass, const vector3d_t& cog)
283 {
284  if (script_command_interface_->clientConnected())
285  {
286  return script_command_interface_->setPayload(mass, &cog);
287  }
288  else
289  {
290  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. On e-Series "
291  "robots this will only work, if the robot is in remote_control mode.");
292  std::stringstream cmd;
293  cmd.imbue(std::locale::classic()); // Make sure, decimal divider is actually '.'
294  cmd << "sec setup():" << std::endl
295  << " set_payload(" << mass << ", [" << cog[0] << ", " << cog[1] << ", " << cog[2] << "])" << std::endl
296  << "end";
297  return sendScript(cmd.str());
298  }
299 }
300 
302 {
303  // Test that the tool voltage is either 0, 12 or 24.
304  switch (voltage)
305  {
306  case ToolVoltage::OFF:
307  break;
308  case ToolVoltage::_12V:
309  break;
310  case ToolVoltage::_24V:
311  break;
312  default:
313  std::stringstream ss;
314  ss << "The tool voltage should be 0, 12 or 24. The tool voltage is " << toUnderlying(voltage);
315  URCL_LOG_ERROR(ss.str().c_str());
316  return false;
317  }
318 
319  if (script_command_interface_->clientConnected())
320  {
321  return script_command_interface_->setToolVoltage(voltage);
322  }
323  else
324  {
325  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. On e-Series "
326  "robots this will only work, if the robot is in remote_control mode.");
327  std::stringstream cmd;
328  cmd << "sec setup():" << std::endl << " set_tool_voltage(" << toUnderlying(voltage) << ")" << std::endl << "end";
329  return sendScript(cmd.str());
330  }
331 }
332 // Function for e-series robots (Needs both damping factor and gain scaling factor)
333 bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_t& selection_vector,
334  const vector6d_t& wrench, const unsigned int type, const vector6d_t& limits,
335  double damping_factor, double gain_scaling_factor)
336 {
337  if (robot_version_.major < 5)
338  {
339  std::stringstream ss;
340  ss << "Force mode gain scaling factor cannot be set on a CB3 robot.";
341  URCL_LOG_ERROR(ss.str().c_str());
342  VersionInformation req_version = VersionInformation::fromString("5.0.0.0");
343  throw IncompatibleRobotVersion(ss.str(), req_version, robot_version_);
344  }
345  // Test that the type is either 1, 2 or 3.
346  switch (type)
347  {
348  case 1:
349  break;
350  case 2:
351  break;
352  case 3:
353  break;
354  default:
355  std::stringstream ss;
356  ss << "The type should be 1, 2 or 3. The type is " << type;
357  URCL_LOG_ERROR(ss.str().c_str());
358  throw InvalidRange(ss.str().c_str());
359  }
360  for (unsigned int i = 0; i < selection_vector.size(); ++i)
361  {
362  if (selection_vector[i] > 1)
363  {
364  std::stringstream ss;
365  ss << "The selection vector should only consist of 0's and 1's";
366  URCL_LOG_ERROR(ss.str().c_str());
367  throw InvalidRange(ss.str().c_str());
368  }
369  }
370 
371  if (damping_factor > 1 || damping_factor < 0)
372  {
373  std::stringstream ss;
374  ss << "The force mode damping factor should be between 0 and 1, both inclusive.";
375  URCL_LOG_ERROR(ss.str().c_str());
376  throw InvalidRange(ss.str().c_str());
377  }
378 
379  if (gain_scaling_factor > 2 || gain_scaling_factor < 0)
380  {
381  std::stringstream ss;
382  ss << "The force mode gain scaling factor should be between 0 and 2, both inclusive.";
383  URCL_LOG_ERROR(ss.str().c_str());
384  throw InvalidRange(ss.str().c_str());
385  }
386 
387  if (script_command_interface_->clientConnected())
388  {
389  return script_command_interface_->startForceMode(&task_frame, &selection_vector, &wrench, type, &limits,
390  damping_factor, gain_scaling_factor);
391  }
392  else
393  {
394  URCL_LOG_ERROR("Script command interface is not running. Unable to start Force mode.");
395  return false;
396  }
397 }
398 
399 // Function for CB3 robots (CB3 robots cannot use gain scaling)
400 bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_t& selection_vector,
401  const vector6d_t& wrench, const unsigned int type, const vector6d_t& limits,
402  double damping_factor)
403 {
404  if (robot_version_.major >= 5)
405  {
406  std::stringstream ss;
407  ss << "You should also specify a force mode gain scaling factor to activate force mode on an e-series robot.";
408  URCL_LOG_ERROR(ss.str().c_str());
409  throw MissingArgument(ss.str(), "startForceMode", "gain_scaling_factor", 0.5);
410  }
411  // Test that the type is either 1, 2 or 3.
412  switch (type)
413  {
414  case 1:
415  break;
416  case 2:
417  break;
418  case 3:
419  break;
420  default:
421  std::stringstream ss;
422  ss << "The type should be 1, 2 or 3. The type is " << type;
423  URCL_LOG_ERROR(ss.str().c_str());
424  throw InvalidRange(ss.str().c_str());
425  }
426  for (unsigned int i = 0; i < selection_vector.size(); ++i)
427  {
428  if (selection_vector[i] > 1)
429  {
430  std::stringstream ss;
431  ss << "The selection vector should only consist of 0's and 1's";
432  URCL_LOG_ERROR(ss.str().c_str());
433  throw InvalidRange(ss.str().c_str());
434  }
435  }
436 
437  if (damping_factor > 1 || damping_factor < 0)
438  {
439  std::stringstream ss;
440  ss << "The force mode damping factor should be between 0 and 1, both inclusive.";
441  URCL_LOG_ERROR(ss.str().c_str());
442  throw InvalidRange(ss.str().c_str());
443  }
444 
445  if (script_command_interface_->clientConnected())
446  {
447  return script_command_interface_->startForceMode(&task_frame, &selection_vector, &wrench, type, &limits,
448  damping_factor, 0);
449  }
450  else
451  {
452  URCL_LOG_ERROR("Script command interface is not running. Unable to start Force mode.");
453  return false;
454  }
455 }
456 
457 bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_t& selection_vector,
458  const vector6d_t& wrench, const unsigned int type, const vector6d_t& limits)
459 {
460  if (robot_version_.major < 5)
461  {
462  return startForceMode(task_frame, selection_vector, wrench, type, limits, force_mode_damping_factor_);
463  }
464  else
465  {
466  return startForceMode(task_frame, selection_vector, wrench, type, limits, force_mode_damping_factor_,
468  }
469 }
470 
472 {
473  if (script_command_interface_->clientConnected())
474  {
475  return script_command_interface_->endForceMode();
476  }
477  else
478  {
479  URCL_LOG_ERROR("Script command interface is not running. Unable to end Force mode.");
480  return false;
481  }
482 }
483 
485 {
486  if (getVersion().major < 5)
487  {
488  std::stringstream ss;
489  ss << "Tool contact is only available for e-Series robots (Major version >= 5). This robot's "
490  "version is "
491  << getVersion();
492  URCL_LOG_ERROR(ss.str().c_str());
493  return false;
494  }
495 
496  if (script_command_interface_->clientConnected())
497  {
498  return script_command_interface_->startToolContact();
499  }
500  else
501  {
502  URCL_LOG_ERROR("Script command interface is not running. Unable to enable tool contact mode.");
503  return 0;
504  }
505 }
506 
508 {
509  if (getVersion().major < 5)
510  {
511  std::stringstream ss;
512  ss << "Tool contact is only available for e-Series robots (Major version >= 5). This robot's "
513  "version is "
514  << getVersion();
515  URCL_LOG_ERROR(ss.str().c_str());
516  return false;
517  }
518 
519  if (script_command_interface_->clientConnected())
520  {
521  return script_command_interface_->endToolContact();
522  }
523  else
524  {
525  URCL_LOG_ERROR("Script command interface is not running. Unable to end tool contact mode.");
526  return 0;
527  }
528 }
529 
530 bool UrDriver::writeKeepalive(const RobotReceiveTimeout& robot_receive_timeout)
531 {
532  vector6d_t* fake = nullptr;
533  return reverse_interface_->write(fake, comm::ControlMode::MODE_IDLE, robot_receive_timeout);
534 }
535 
537 {
538  rtde_client_->start();
539 }
540 
542 {
543  vector6d_t* fake = nullptr;
545 }
546 
547 std::string UrDriver::readScriptFile(const std::string& filename)
548 {
549  std::ifstream ifs;
550  ifs.open(filename);
551  if (!ifs)
552  {
553  std::stringstream ss;
554  ss << "URScript file '" << filename << "' doesn't exists.";
555  throw UrException(ss.str().c_str());
556  }
557  std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
558 
559  return content;
560 }
561 
562 bool UrDriver::checkCalibration(const std::string& checksum)
563 {
564  return primary_client_->checkCalibration(checksum);
565 }
566 
568 {
569  return rtde_client_->getWriter();
570 }
571 
572 bool UrDriver::sendScript(const std::string& program)
573 {
574  if (primary_client_ == nullptr)
575  {
576  throw std::runtime_error("Sending script to robot requested while there is no primary client initialized. "
577  "This should not happen.");
578  }
579  return primary_client_->sendScript(program);
580 }
581 
583 {
584  if (in_headless_mode_)
585  {
587  }
588  else
589  {
590  URCL_LOG_ERROR("Tried to send robot program directly while not in headless mode");
591  return false;
592  }
593 }
594 
595 std::vector<std::string> UrDriver::getRTDEOutputRecipe()
596 {
597  return rtde_client_->getOutputRecipe();
598 }
599 
600 void UrDriver::setKeepaliveCount(const uint32_t count)
601 {
602  URCL_LOG_WARN("DEPRECATION NOTICE: Setting the keepalive count has been deprecated. Instead use the "
603  "RobotReceiveTimeout, to set the timeout directly in the write commands. Please change your code to "
604  "set the "
605  "read timeout in the write commands directly. This keepalive count will overwrite the timeout passed "
606  "to the write functions.");
607 // TODO: Remove 2027-05
608 #pragma GCC diagnostic push
609 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
610  reverse_interface_->setKeepaliveCount(count);
611 #pragma GCC diagnostic pop
612 }
613 
614 void UrDriver::resetRTDEClient(const std::vector<std::string>& output_recipe,
615  const std::vector<std::string>& input_recipe, double target_frequency,
616  bool ignore_unavailable_outputs)
617 {
618  rtde_client_.reset(new rtde_interface::RTDEClient(robot_ip_, notifier_, output_recipe, input_recipe, target_frequency,
619  ignore_unavailable_outputs));
620  initRTDE();
621 }
622 
623 void UrDriver::resetRTDEClient(const std::string& output_recipe_filename, const std::string& input_recipe_filename,
624  double target_frequency, bool ignore_unavailable_outputs)
625 {
626  rtde_client_.reset(new rtde_interface::RTDEClient(robot_ip_, notifier_, output_recipe_filename, input_recipe_filename,
627  target_frequency, ignore_unavailable_outputs));
628  initRTDE();
629 }
630 
632 {
635  {
636  throw UrException("Initialization of RTDE client went wrong.");
637  }
638 }
639 
640 void UrDriver::setupReverseInterface(const uint32_t reverse_port)
641 {
642  auto rtde_frequency = rtde_client_->getTargetFrequency();
643  auto step_time = std::chrono::milliseconds(static_cast<int>(1000 / rtde_frequency));
644  reverse_interface_.reset(new control::ReverseInterface(reverse_port, handle_program_state_, step_time));
645 }
646 
648 {
650 }
651 
652 std::deque<urcl::primary_interface::ErrorCode> UrDriver::getErrorCodes()
653 {
654  return primary_client_->getErrorCodes();
655 }
656 } // namespace urcl
urcl::UrDriver::getRTDEOutputRecipe
std::vector< std::string > getRTDEOutputRecipe()
Getter for the RTDE output recipe used in the RTDE client.
Definition: ur_driver.cpp:595
urcl::comm::ControlMode
ControlMode
Control modes as interpreted from the script runnning on the robot.
Definition: control_mode.h:42
urcl::UrDriverConfiguration::output_recipe_file
std::string output_recipe_file
Filename where the output recipe is stored in.
Definition: ur_driver.h:56
urcl::VersionInformation::fromString
static VersionInformation fromString(const std::string &str)
Parses a version string into a VersionInformation object.
Definition: version_information.cpp:59
urcl::rtde_interface::RTDEWriter
The RTDEWriter class offers an abstraction layer to send data to the robot via the RTDE interface....
Definition: rtde_writer.h:50
urcl::UrDriver::trajectory_interface_
std::unique_ptr< control::TrajectoryPointInterface > trajectory_interface_
Definition: ur_driver.h:921
urcl::UrDriverConfiguration::handle_program_state
std::function< void(bool)> handle_program_state
Function handle to a callback on program state changes.
Definition: ur_driver.h:65
urcl::UrDriver::resetRTDEClient
void resetRTDEClient(const std::vector< std::string > &output_recipe, const std::vector< std::string > &input_recipe, double target_frequency=0.0, bool ignore_unavailable_outputs=false)
Reset the RTDE client. As during initialization the driver will start RTDE communication with the max...
Definition: ur_driver.cpp:614
urcl::BEGIN_REPLACE
static const std::string BEGIN_REPLACE("{{BEGIN_REPLACE}}")
exceptions.h
ur_driver.h
urcl::UrDriverConfiguration::input_recipe_file
std::string input_recipe_file
Filename where the input recipe is stored in.
Definition: ur_driver.h:57
urcl::UrDriver::startRTDECommunication
void startRTDECommunication()
Starts the RTDE communication.
Definition: ur_driver.cpp:536
urcl::UrDriver::setPayload
bool setPayload(const float mass, const vector3d_t &cog)
Set the payload mass and center of gravity. Note: It requires the external control script to be runni...
Definition: ur_driver.cpp:282
urcl::UrDriver::endForceMode
bool endForceMode()
Stop force mode and put the robot into normal operation mode.
Definition: ur_driver.cpp:471
urcl::UrDriver::get_packet_timeout_
int get_packet_timeout_
Definition: ur_driver.h:943
urcl::UrDriver::robot_ip_
std::string robot_ip_
Definition: ur_driver.h:939
urcl::control::ScriptSender
The ScriptSender class starts a TCPServer for a robot to connect to and waits for a request to receiv...
Definition: script_sender.h:47
calibration_checker.h
urcl::UrDriverConfiguration::robot_ip
std::string robot_ip
IP-address under which the robot is reachable.
Definition: ur_driver.h:54
urcl::UrDriver::force_mode_gain_scale_factor_
double force_mode_gain_scale_factor_
Definition: ur_driver.h:931
urcl::UrDriverConfiguration
Structure for configuration parameters of a UrDriver object.
Definition: ur_driver.h:52
urcl::UrDriverConfiguration::trajectory_port
uint32_t trajectory_port
Port used for sending trajectory points to the robot in case of trajectory forwarding.
Definition: ur_driver.h:84
urcl::ToolVoltage
ToolVoltage
Possible values for the tool voltage.
Definition: tool_communication.h:41
urcl
Definition: bin_parser.h:36
urcl::control::ReverseInterface::MULT_JOINTSTATE
static const int32_t MULT_JOINTSTATE
Definition: reverse_interface.h:72
urcl::UrDriver::stopControl
bool stopControl()
Sends a stop command to the socket interface which will signal the program running on the robot to no...
Definition: ur_driver.cpp:541
urcl::SERVER_PORT_REPLACE
static const std::string SERVER_PORT_REPLACE("{{SERVER_PORT_REPLACE}}")
urcl::UrDriver::getRTDEWriter
rtde_interface::RTDEWriter & getRTDEWriter()
Getter for the RTDE writer used to write to the robot's RTDE interface.
Definition: ur_driver.cpp:567
urcl::control::ReverseInterface
The ReverseInterface class handles communication to the robot. It starts a server and waits for the r...
Definition: reverse_interface.h:69
urcl::control::ScriptCommandInterface
The ScriptCommandInterface class starts a TCPServer for a robot to connect to and this connection is ...
Definition: script_command_interface.h:55
URCL_LOG_ERROR
#define URCL_LOG_ERROR(...)
Definition: log.h:26
urcl::UrDriverConfiguration::tool_comm_setup
std::unique_ptr< ToolCommSetup > tool_comm_setup
Configuration for using the tool communication.
Definition: ur_driver.h:68
urcl::TRAJECTORY_PORT_REPLACE
static const std::string TRAJECTORY_PORT_REPLACE("{{TRAJECTORY_SERVER_PORT_REPLACE}}")
urcl::UrDriverConfiguration::script_command_port
uint32_t script_command_port
Port used for forwarding script commands to the robot.
Definition: ur_driver.h:92
urcl::UrDriver::writeJointCommand
bool writeJointCommand(const vector6d_t &values, const comm::ControlMode control_mode, const RobotReceiveTimeout &robot_receive_timeout=RobotReceiveTimeout::millisec(20))
Writes a joint command together with a keepalive signal onto the socket being sent to the robot.
Definition: ur_driver.cpp:201
urcl::vector6d_t
std::array< double, 6 > vector6d_t
Definition: types.h:30
URCL_LOG_DEBUG
#define URCL_LOG_DEBUG(...)
Definition: log.h:23
urcl::UrDriver::in_headless_mode_
bool in_headless_mode_
Definition: ur_driver.h:940
urcl::JOINT_STATE_REPLACE
static const std::string JOINT_STATE_REPLACE("{{JOINT_STATE_REPLACE}}")
urcl::UrDriver::setupReverseInterface
void setupReverseInterface(const uint32_t reverse_port)
Definition: ur_driver.cpp:640
urcl::UrDriver::setKeepaliveCount
void setKeepaliveCount(const uint32_t count)
Set the Keepalive count. This will set the number of allowed timeout reads on the robot.
Definition: ur_driver.cpp:600
urcl::UrDriverConfiguration::rtde_initialization_timeout
std::chrono::milliseconds rtde_initialization_timeout
Time in between initialization attempts of the RTDE interface.
Definition: ur_driver.h:134
urcl::SERVO_J_REPLACE
static const std::string SERVO_J_REPLACE("{{SERVO_J_REPLACE}}")
urcl::UrDriver::socket_connection_attempts_
size_t socket_connection_attempts_
Definition: ur_driver.h:925
urcl::UrDriver::startForceMode
bool startForceMode(const vector6d_t &task_frame, const vector6uint32_t &selection_vector, const vector6d_t &wrench, const unsigned int type, const vector6d_t &limits, double damping_factor)
Start the robot to be controlled in force mode.
Definition: ur_driver.cpp:400
urcl::control::TrajectoryControlMessage
TrajectoryControlMessage
Control messages for forwarding and aborting trajectories.
Definition: reverse_interface.h:48
urcl::UrDriver::getDataPackage
std::unique_ptr< rtde_interface::DataPackage > getDataPackage()
Access function to receive the latest data package sent from the robot through RTDE interface.
Definition: ur_driver.cpp:191
urcl::comm::ControlMode::MODE_IDLE
@ MODE_IDLE
Set when no controller is currently active controlling the robot.
urcl::vector6uint32_t
std::array< uint32_t, 6 > vector6uint32_t
Definition: types.h:32
urcl::UrDriver::writeTrajectoryPoint
bool writeTrajectoryPoint(const vector6d_t &positions, const bool cartesian, const float goal_time=0.0, const float blend_radius=0.052)
Writes a trajectory point onto the dedicated socket.
Definition: ur_driver.cpp:214
urcl::VersionInformation::major
uint32_t major
Major version number.
Definition: version_information.h:71
urcl::UrDriver::sendScript
bool sendScript(const std::string &program)
Sends a custom script program to the robot.
Definition: ur_driver.cpp:572
urcl::UrDriverConfiguration::reverse_port
uint32_t reverse_port
Port that will be opened by the driver to allow direct communication between the driver and the robot...
Definition: ur_driver.h:74
urcl::UrDriverConfiguration::servoj_gain
int servoj_gain
Proportional gain for arm joints following target position, range [100,2000].
Definition: ur_driver.h:105
urcl::UrDriver::servoj_lookahead_time_
double servoj_lookahead_time_
Definition: ur_driver.h:935
urcl::UrException
Our base class for exceptions. Specialized exceptions should inherit from those.
Definition: exceptions.h:53
urcl::UrDriver::reverse_interface_
std::unique_ptr< control::ReverseInterface > reverse_interface_
Definition: ur_driver.h:920
urcl::VersionInformation
Struct containing a robot's version information.
Definition: version_information.h:42
urcl::UrDriver::socket_reconnection_timeout_
std::chrono::milliseconds socket_reconnection_timeout_
Definition: ur_driver.h:926
urcl::SCRIPT_COMMAND_PORT_REPLACE
static const std::string SCRIPT_COMMAND_PORT_REPLACE("{{SCRIPT_COMMAND_SERVER_PORT_REPLACE}}")
urcl::UrDriverConfiguration::calibration_checksum
std::string calibration_checksum
Definition: ur_driver.h:141
urcl::UrDriver::writeFreedriveControlMessage
bool writeFreedriveControlMessage(const control::FreedriveControlMessage freedrive_action, const RobotReceiveTimeout &robot_receive_timeout=RobotReceiveTimeout::millisec(200))
Writes a control message in freedrive mode.
Definition: ur_driver.cpp:248
urcl::ToolVoltage::_24V
@ _24V
24V
urcl::UrDriver::notifier_
comm::INotifier notifier_
Definition: ur_driver.h:917
urcl::UrDriver::robot_version_
VersionInformation robot_version_
Definition: ur_driver.h:946
urcl::primary_interface::PrimaryClient
Definition: primary_client.h:50
urcl::UrDriverConfiguration::reverse_ip
std::string reverse_ip
IP address that the reverse_port will get bound to.
Definition: ur_driver.h:100
urcl::UrDriverConfiguration::servoj_lookahead_time
double servoj_lookahead_time
Time [S], range [0.03,0.2] smoothens servoj calls with this lookahead time.
Definition: ur_driver.h:110
urcl::UrDriver::rtde_client_
std::unique_ptr< rtde_interface::RTDEClient > rtde_client_
Definition: ur_driver.h:918
urcl::UrDriver::writeTrajectorySplinePoint
bool writeTrajectorySplinePoint(const vector6d_t &positions, const vector6d_t &velocities, const vector6d_t &accelerations, const float goal_time=0.0)
Writes a trajectory spline point for quintic spline interpolation onto the dedicated socket.
Definition: ur_driver.cpp:220
urcl::UrDriver::initRTDE
void initRTDE()
Definition: ur_driver.cpp:631
urcl::UrDriver::writeKeepalive
bool writeKeepalive(const RobotReceiveTimeout &robot_receive_timeout=RobotReceiveTimeout::millisec(1000))
Write a keepalive signal only.
Definition: ur_driver.cpp:530
urcl::UrDriver::checkCalibration
bool checkCalibration(const std::string &checksum)
Checks if the kinematics information in the used model fits the actual robot.
Definition: ur_driver.cpp:562
urcl::UrDriverConfiguration::rtde_initialization_attempts
size_t rtde_initialization_attempts
Number of attempts to initialize (given a successful socket connection) the RTDE interface.
Definition: ur_driver.h:129
urcl::UrDriverConfiguration::script_sender_port
uint32_t script_sender_port
The driver will offer an interface to receive the program's URScript on this port....
Definition: ur_driver.h:79
urcl::UrDriverConfiguration::non_blocking_read
bool non_blocking_read
Definition: ur_driver.h:136
urcl::UrDriver::handle_program_state_
std::function< void(bool)> handle_program_state_
Definition: ur_driver.h:937
urcl::UrDriver::getErrorCodes
std::deque< urcl::primary_interface::ErrorCode > getErrorCodes()
Retrieves previously raised error codes from PrimaryClient. After calling this, recorded errors will ...
Definition: ur_driver.cpp:652
urcl::UrDriver::script_sender_
std::unique_ptr< control::ScriptSender > script_sender_
Definition: ur_driver.h:923
urcl::UrDriverConfiguration::socket_reconnection_timeout
std::chrono::milliseconds socket_reconnection_timeout
Time in between connection attempts to sockets such as the primary or RTDE interface.
Definition: ur_driver.h:122
URCL_LOG_INFO
#define URCL_LOG_INFO(...)
Definition: log.h:25
urcl::UrDriver::rtde_initialization_timeout_
std::chrono::milliseconds rtde_initialization_timeout_
Definition: ur_driver.h:929
urcl::UrDriver::script_command_interface_
std::unique_ptr< control::ScriptCommandInterface > script_command_interface_
Definition: ur_driver.h:922
urcl::FORCE_MODE_SET_DAMPING_REPLACE
static const std::string FORCE_MODE_SET_DAMPING_REPLACE("{{FORCE_MODE_SET_DAMPING_REPLACE}}")
urcl::InvalidRange
Definition: exceptions.h:170
urcl::IncompatibleRobotVersion
Definition: exceptions.h:147
urcl::UrDriver::non_blocking_read_
bool non_blocking_read_
Definition: ur_driver.h:944
urcl::comm::ControlMode::MODE_STOPPED
@ MODE_STOPPED
When this is set, the program is expected to stop and exit.
urcl::FORCE_MODE_SET_GAIN_SCALING_REPLACE
static const std::string FORCE_MODE_SET_GAIN_SCALING_REPLACE("{{FORCE_MODE_SET_GAIN_SCALING_REPLACE}}")
urcl::UrDriverConfiguration::socket_reconnect_attempts
size_t socket_reconnect_attempts
Number of attempts to reconnect to sockets such as the primary or RTDE interface.
Definition: ur_driver.h:117
urcl::UrDriver::full_robot_program_
std::string full_robot_program_
Definition: ur_driver.h:941
urcl::UrDriver::endToolContact
bool endToolContact()
This will stop the robot from looking for a tool contact, it will also enable sending move commands t...
Definition: ur_driver.cpp:507
urcl::ToolCommNotAvailable
A specialized exception representing that communication to the tool is not possible.
Definition: exceptions.h:106
urcl::UrDriver::zeroFTSensor
bool zeroFTSensor()
Zero the force torque sensor (only availbe on e-Series). Note: It requires the external control scrip...
Definition: ur_driver.cpp:254
urcl::UrDriver::getVersion
const VersionInformation & getVersion()
Returns version information about the currently connected robot.
Definition: ur_driver.h:796
urcl::UrDriver::startPrimaryClientCommunication
void startPrimaryClientCommunication()
Starts the primary client.
Definition: ur_driver.cpp:647
urcl::UrDriverConfiguration::headless_mode
bool headless_mode
Parameter to control if the driver should be started in headless mode.
Definition: ur_driver.h:66
urcl::toUnderlying
constexpr std::underlying_type< E >::type toUnderlying(const E e) noexcept
Converts an enum type to its underlying type.
Definition: types.h:80
urcl::ToolVoltage::_12V
@ _12V
12V
URCL_LOG_WARN
#define URCL_LOG_WARN(...)
Definition: log.h:24
urcl::control::TrajectoryPointInterface
The TrajectoryPointInterface class handles trajectory forwarding to the robot. Full trajectories are ...
Definition: trajectory_point_interface.h:62
urcl::vector3d_t
std::array< double, 3 > vector3d_t
Definition: types.h:29
urcl::MissingArgument
Definition: exceptions.h:187
urcl::ToolVoltage::OFF
@ OFF
0V
urcl::UrDriver::servoj_gain_
uint32_t servoj_gain_
Definition: ur_driver.h:934
urcl::UrDriver::startToolContact
bool startToolContact()
This will make the robot look for tool contact in the tcp directions that the robot is currently movi...
Definition: ur_driver.cpp:484
urcl::TIME_REPLACE
static const std::string TIME_REPLACE("{{TIME_REPLACE}}")
urcl::UrDriver::readScriptFile
static std::string readScriptFile(const std::string &filename)
Definition: ur_driver.cpp:547
urcl::UrDriver::writeMotionPrimitive
bool writeMotionPrimitive(const std::shared_ptr< control::MotionPrimitive > motion_instruction)
Writes a motion command to the trajectory point interface.
Definition: ur_driver.cpp:243
urcl::UrDriver::init
void init(const UrDriverConfiguration &config)
Definition: ur_driver.cpp:55
urcl::RobotReceiveTimeout
RobotReceiveTimeout class containing a timeout configuration.
Definition: robot_receive_timeout.h:47
urcl::UrDriver::sendRobotProgram
bool sendRobotProgram()
Sends the external control program to the robot.
Definition: ur_driver.cpp:582
primary_parser.h
urcl::SERVER_IP_REPLACE
static const std::string SERVER_IP_REPLACE("{{SERVER_IP_REPLACE}}")
urcl::control::FreedriveControlMessage
FreedriveControlMessage
Control messages for starting and stopping freedrive mode.
Definition: reverse_interface.h:58
urcl::UrDriver::primary_client_
std::shared_ptr< urcl::primary_interface::PrimaryClient > primary_client_
Definition: ur_driver.h:919
urcl::UrDriver::rtde_initialization_attempts_
size_t rtde_initialization_attempts_
Definition: ur_driver.h:928
urcl::rtde_interface::RTDEClient
The RTDEClient class manages communication over the RTDE interface. It contains the RTDE handshake an...
Definition: rtde_client.h:93
urcl::UrDriverConfiguration::script_file
std::string script_file
URScript file that should be sent to the robot.
Definition: ur_driver.h:55
urcl::control::TrajectoryPointInterface::MULT_TIME
static const int32_t MULT_TIME
Definition: trajectory_point_interface.h:65
urcl::UrDriver::setToolVoltage
bool setToolVoltage(const ToolVoltage voltage)
Set the tool voltage. Note: It requires the external control script to be running or the robot to be ...
Definition: ur_driver.cpp:301
urcl::UrDriver::writeTrajectoryControlMessage
bool writeTrajectoryControlMessage(const control::TrajectoryControlMessage trajectory_action, const int point_number=0, const RobotReceiveTimeout &robot_receive_timeout=RobotReceiveTimeout::millisec(200))
Writes a control message in trajectory forward mode.
Definition: ur_driver.cpp:237
urcl::UrDriver::force_mode_damping_factor_
double force_mode_damping_factor_
Definition: ur_driver.h:932


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58