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 
55 urcl::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_file,
56  const std::string& output_recipe_file, const std::string& input_recipe_file,
57  std::function<void(bool)> handle_program_state, bool headless_mode,
58  std::unique_ptr<ToolCommSetup> tool_comm_setup, const uint32_t reverse_port,
59  const uint32_t script_sender_port, int servoj_gain, double servoj_lookahead_time,
60  bool non_blocking_read, const std::string& reverse_ip, const uint32_t trajectory_port,
61  const uint32_t script_command_port, double force_mode_damping, double force_mode_gain_scaling)
62  : servoj_time_(0.008)
63  , servoj_gain_(servoj_gain)
64  , servoj_lookahead_time_(servoj_lookahead_time)
65  , handle_program_state_(handle_program_state)
66  , robot_ip_(robot_ip)
67 {
68  URCL_LOG_DEBUG("Initializing urdriver");
69  URCL_LOG_DEBUG("Initializing RTDE client");
70  rtde_client_.reset(new rtde_interface::RTDEClient(robot_ip_, notifier_, output_recipe_file, input_recipe_file));
71 
72  primary_stream_.reset(
74  secondary_stream_.reset(
76  secondary_stream_->connect();
77 
78  non_blocking_read_ = non_blocking_read;
80 
81  if (!rtde_client_->init())
82  {
83  throw UrException("Initialization of RTDE client went wrong.");
84  }
85 
86  rtde_frequency_ = rtde_client_->getMaxFrequency();
88 
89  // Figure out the ip automatically if the user didn't provide it
90  std::string local_ip = reverse_ip.empty() ? rtde_client_->getIP() : reverse_ip;
91 
92  std::string prog = readScriptFile(script_file);
93  while (prog.find(JOINT_STATE_REPLACE) != std::string::npos)
94  {
95  prog.replace(prog.find(JOINT_STATE_REPLACE), JOINT_STATE_REPLACE.length(),
97  }
98  while (prog.find(TIME_REPLACE) != std::string::npos)
99  {
100  prog.replace(prog.find(TIME_REPLACE), TIME_REPLACE.length(),
102  }
103 
104  std::ostringstream out;
105  out << "lookahead_time=" << servoj_lookahead_time_ << ", gain=" << servoj_gain_;
106  while (prog.find(SERVO_J_REPLACE) != std::string::npos)
107  {
108  prog.replace(prog.find(SERVO_J_REPLACE), SERVO_J_REPLACE.length(), out.str());
109  }
110 
111  while (prog.find(SERVER_IP_REPLACE) != std::string::npos)
112  {
113  prog.replace(prog.find(SERVER_IP_REPLACE), SERVER_IP_REPLACE.length(), local_ip);
114  }
115 
116  while (prog.find(SERVER_PORT_REPLACE) != std::string::npos)
117  {
118  prog.replace(prog.find(SERVER_PORT_REPLACE), SERVER_PORT_REPLACE.length(), std::to_string(reverse_port));
119  }
120 
121  while (prog.find(TRAJECTORY_PORT_REPLACE) != std::string::npos)
122  {
123  prog.replace(prog.find(TRAJECTORY_PORT_REPLACE), TRAJECTORY_PORT_REPLACE.length(), std::to_string(trajectory_port));
124  }
125 
126  while (prog.find(SCRIPT_COMMAND_PORT_REPLACE) != std::string::npos)
127  {
128  prog.replace(prog.find(SCRIPT_COMMAND_PORT_REPLACE), SCRIPT_COMMAND_PORT_REPLACE.length(),
129  std::to_string(script_command_port));
130  }
131 
132  while (prog.find(FORCE_MODE_SET_DAMPING_REPLACE) != std::string::npos)
133  {
134  if (force_mode_damping < 0 || force_mode_damping > 1)
135  {
136  std::stringstream ss;
137  ss << "Force mode damping, should be between 0 and 1, but it is " << force_mode_damping;
138  force_mode_damping = 0.025;
139  ss << " setting it to default " << force_mode_damping;
140  URCL_LOG_ERROR(ss.str().c_str());
141  }
142  prog.replace(prog.find(FORCE_MODE_SET_DAMPING_REPLACE), FORCE_MODE_SET_DAMPING_REPLACE.length(),
143  std::to_string(force_mode_damping));
144  }
145 
146  while (prog.find(FORCE_MODE_SET_GAIN_SCALING_REPLACE) != std::string::npos)
147  {
148  if (robot_version_.major < 5)
149  {
150  // force_mode_set_gain_scaling is only available for e-series and is therefore removed, if the robot is not
151  // e-series
152  std::stringstream ss;
153  ss << "force_mode_set_gain_scaling(" << FORCE_MODE_SET_GAIN_SCALING_REPLACE << ")";
154  prog.replace(prog.find(ss.str()), ss.str().length(), "");
155  }
156  else
157  {
158  if (force_mode_gain_scaling < 0 || force_mode_gain_scaling > 2)
159  {
160  std::stringstream ss;
161  ss << "Force mode gain scaling, should be between 0 and 2, but it is " << force_mode_gain_scaling;
162  force_mode_gain_scaling = 0.5;
163  ss << " setting it to default " << force_mode_gain_scaling;
164  URCL_LOG_ERROR(ss.str().c_str());
165  }
167  std::to_string(force_mode_gain_scaling));
168  }
169  }
170 
171  robot_version_ = rtde_client_->getVersion();
172 
173  std::stringstream begin_replace;
174  if (tool_comm_setup != nullptr)
175  {
176  if (robot_version_.major < 5)
177  {
178  throw ToolCommNotAvailable("Tool communication setup requested, but this robot version does not support using "
179  "the tool communication interface. Please check your configuration.",
180  5, robot_version_.major);
181  }
182  begin_replace << "set_tool_voltage("
183  << static_cast<std::underlying_type<ToolVoltage>::type>(tool_comm_setup->getToolVoltage()) << ")\n";
184  begin_replace << "set_tool_communication("
185  << "True"
186  << ", " << tool_comm_setup->getBaudRate() << ", "
187  << static_cast<std::underlying_type<Parity>::type>(tool_comm_setup->getParity()) << ", "
188  << tool_comm_setup->getStopBits() << ", " << tool_comm_setup->getRxIdleChars() << ", "
189  << tool_comm_setup->getTxIdleChars() << ")";
190  }
191  prog.replace(prog.find(BEGIN_REPLACE), BEGIN_REPLACE.length(), begin_replace.str());
192 
193  in_headless_mode_ = headless_mode;
194  if (in_headless_mode_)
195  {
196  full_robot_program_ = "stop program\n";
197  full_robot_program_ += "def externalControl():\n";
198  std::istringstream prog_stream(prog);
199  std::string line;
200  while (std::getline(prog_stream, line))
201  {
202  full_robot_program_ += "\t" + line + "\n";
203  }
204  full_robot_program_ += "end\n";
206  }
207  else
208  {
209  script_sender_.reset(new control::ScriptSender(script_sender_port, prog));
210  URCL_LOG_DEBUG("Created script sender");
211  }
212 
213  reverse_interface_.reset(new control::ReverseInterface(reverse_port, handle_program_state));
214  trajectory_interface_.reset(new control::TrajectoryPointInterface(trajectory_port));
215  script_command_interface_.reset(new control::ScriptCommandInterface(script_command_port));
216 
217  URCL_LOG_DEBUG("Initialization done");
218 }
219 
220 urcl::UrDriver::UrDriver(const std::string& robot_ip, const std::string& script_file,
221  const std::string& output_recipe_file, const std::string& input_recipe_file,
222  std::function<void(bool)> handle_program_state, bool headless_mode,
223  std::unique_ptr<ToolCommSetup> tool_comm_setup, const std::string& calibration_checksum,
224  const uint32_t reverse_port, const uint32_t script_sender_port, int servoj_gain,
225  double servoj_lookahead_time, bool non_blocking_read, const std::string& reverse_ip,
226  const uint32_t trajectory_port, const uint32_t script_command_port, double force_mode_damping,
227  double force_mode_gain_scaling)
228  : UrDriver(robot_ip, script_file, output_recipe_file, input_recipe_file, handle_program_state, headless_mode,
229  std::move(tool_comm_setup), reverse_port, script_sender_port, servoj_gain, servoj_lookahead_time,
230  non_blocking_read, reverse_ip, trajectory_port, script_command_port, force_mode_damping,
231  force_mode_gain_scaling)
232 {
233  URCL_LOG_WARN("DEPRECATION NOTICE: Passing the calibration_checksum to the UrDriver's constructor has been "
234  "deprecated. Instead, use the checkCalibration(calibration_checksum) function separately. This "
235  "notice is for application developers using this library. If you are only using an application using "
236  "this library, you can ignore this message.");
237  if (checkCalibration(calibration_checksum))
238  {
239  URCL_LOG_INFO("Calibration checked successfully.");
240  }
241  else
242  {
243  URCL_LOG_ERROR("The calibration parameters of the connected robot don't match the ones from the given kinematics "
244  "config file. Please be aware that this can lead to critical inaccuracies of tcp positions. Use "
245  "the ur_calibration tool to extract the correct calibration from the robot and pass that into the "
246  "description. See "
247  "[https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#extract-calibration-information] "
248  "for details.");
249  }
250 }
251 
252 std::unique_ptr<rtde_interface::DataPackage> urcl::UrDriver::getDataPackage()
253 {
254  // This can take one of two values, 0ms or 100ms. The large timeout is for when the robot is commanding the control
255  // loop's timing (read is blocking). The zero timeout is for when the robot is sharing a control loop with
256  // something else (combined_robot_hw)
257  std::chrono::milliseconds timeout(get_packet_timeout_);
258 
259  return rtde_client_->getDataPackage(timeout);
260 }
261 
262 bool UrDriver::writeJointCommand(const vector6d_t& values, const comm::ControlMode control_mode)
263 {
264  return reverse_interface_->write(&values, control_mode);
265 }
266 
267 bool UrDriver::writeTrajectoryPoint(const vector6d_t& positions, const bool cartesian, const float goal_time,
268  const float blend_radius)
269 {
270  return trajectory_interface_->writeTrajectoryPoint(&positions, goal_time, blend_radius, cartesian);
271 }
272 
273 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const vector6d_t& velocities,
274  const vector6d_t& accelerations, const float goal_time)
275 {
276  return trajectory_interface_->writeTrajectorySplinePoint(&positions, &velocities, &accelerations, goal_time);
277 }
278 
279 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const vector6d_t& velocities,
280  const float goal_time)
281 {
282  return trajectory_interface_->writeTrajectorySplinePoint(&positions, &velocities, nullptr, goal_time);
283 }
284 
285 bool UrDriver::writeTrajectorySplinePoint(const vector6d_t& positions, const float goal_time)
286 {
287  return trajectory_interface_->writeTrajectorySplinePoint(&positions, nullptr, nullptr, goal_time);
288 }
289 
291  const int point_number)
292 {
293  return reverse_interface_->writeTrajectoryControlMessage(trajectory_action, point_number);
294 }
295 
297 {
298  return reverse_interface_->writeFreedriveControlMessage(freedrive_action);
299 }
300 
302 {
303  if (getVersion().major < 5)
304  {
305  std::stringstream ss;
306  ss << "Zeroing the Force-Torque sensor is only available for e-Series robots (Major version >= 5). This robot's "
307  "version is "
308  << getVersion();
309  URCL_LOG_ERROR(ss.str().c_str());
310  return false;
311  }
312  else
313  {
314  if (script_command_interface_->clientConnected())
315  {
316  return script_command_interface_->zeroFTSensor();
317  }
318  else
319  {
320  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. This will "
321  "only work, if the robot is in remote_control mode.");
322  std::stringstream cmd;
323  cmd << "sec tareSetup():" << std::endl << " zero_ftsensor()" << std::endl << "end";
324  return sendScript(cmd.str());
325  }
326  }
327 }
328 
329 bool UrDriver::setPayload(const float mass, const vector3d_t& cog)
330 {
331  if (script_command_interface_->clientConnected())
332  {
333  return script_command_interface_->setPayload(mass, &cog);
334  }
335  else
336  {
337  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. On e-Series "
338  "robots this will only work, if the robot is in remote_control mode.");
339  std::stringstream cmd;
340  cmd.imbue(std::locale::classic()); // Make sure, decimal divider is actually '.'
341  cmd << "sec setup():" << std::endl
342  << " set_payload(" << mass << ", [" << cog[0] << ", " << cog[1] << ", " << cog[2] << "])" << std::endl
343  << "end";
344  return sendScript(cmd.str());
345  }
346 }
347 
349 {
350  // Test that the tool voltage is either 0, 12 or 24.
351  switch (voltage)
352  {
353  case ToolVoltage::OFF:
354  break;
355  case ToolVoltage::_12V:
356  break;
357  case ToolVoltage::_24V:
358  break;
359  default:
360  std::stringstream ss;
361  ss << "The tool voltage should be 0, 12 or 24. The tool voltage is " << toUnderlying(voltage);
362  URCL_LOG_ERROR(ss.str().c_str());
363  return false;
364  }
365 
366  if (script_command_interface_->clientConnected())
367  {
368  return script_command_interface_->setToolVoltage(voltage);
369  }
370  else
371  {
372  URCL_LOG_WARN("Script command interface is not running. Falling back to sending plain script code. On e-Series "
373  "robots this will only work, if the robot is in remote_control mode.");
374  std::stringstream cmd;
375  cmd << "sec setup():" << std::endl << " set_tool_voltage(" << toUnderlying(voltage) << ")" << std::endl << "end";
376  return sendScript(cmd.str());
377  }
378 }
379 
380 bool UrDriver::startForceMode(const vector6d_t& task_frame, const vector6uint32_t& selection_vector,
381  const vector6d_t& wrench, const unsigned int type, const vector6d_t& limits)
382 {
383  // Test that the type is either 1, 2 or 3.
384  switch (type)
385  {
386  case 1:
387  break;
388  case 2:
389  break;
390  case 3:
391  break;
392  default:
393  std::stringstream ss;
394  ss << "The type should be 1, 2 or 3. The type is " << type;
395  URCL_LOG_ERROR(ss.str().c_str());
396  return false;
397  }
398  for (unsigned int i = 0; i < selection_vector.size(); ++i)
399  {
400  if (selection_vector[i] > 1)
401  {
402  URCL_LOG_ERROR("The selection vector should only consist of 0's and 1's");
403  return false;
404  }
405  }
406 
407  if (script_command_interface_->clientConnected())
408  {
409  return script_command_interface_->startForceMode(&task_frame, &selection_vector, &wrench, type, &limits);
410  }
411  else
412  {
413  URCL_LOG_ERROR("Script command interface is not running. Unable to start Force mode.");
414  return false;
415  }
416 }
417 
419 {
420  if (script_command_interface_->clientConnected())
421  {
422  return script_command_interface_->endForceMode();
423  }
424  else
425  {
426  URCL_LOG_ERROR("Script command interface is not running. Unable to end Force mode.");
427  return false;
428  }
429 }
430 
432 {
433  if (getVersion().major < 5)
434  {
435  std::stringstream ss;
436  ss << "Tool contact is only available for e-Series robots (Major version >= 5). This robot's "
437  "version is "
438  << getVersion();
439  URCL_LOG_ERROR(ss.str().c_str());
440  return false;
441  }
442 
443  if (script_command_interface_->clientConnected())
444  {
445  return script_command_interface_->startToolContact();
446  }
447  else
448  {
449  URCL_LOG_ERROR("Script command interface is not running. Unable to enable tool contact mode.");
450  return 0;
451  }
452 }
453 
455 {
456  if (getVersion().major < 5)
457  {
458  std::stringstream ss;
459  ss << "Tool contact is only available for e-Series robots (Major version >= 5). This robot's "
460  "version is "
461  << getVersion();
462  URCL_LOG_ERROR(ss.str().c_str());
463  return false;
464  }
465 
466  if (script_command_interface_->clientConnected())
467  {
468  return script_command_interface_->endToolContact();
469  }
470  else
471  {
472  URCL_LOG_ERROR("Script command interface is not running. Unable to end tool contact mode.");
473  return 0;
474  }
475 }
476 
478 {
479  vector6d_t* fake = nullptr;
481 }
482 
484 {
485  rtde_client_->start();
486 }
487 
489 {
490  vector6d_t* fake = nullptr;
492 }
493 
494 std::string UrDriver::readScriptFile(const std::string& filename)
495 {
496  std::ifstream ifs(filename);
497  std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
498 
499  return content;
500 }
501 
502 bool UrDriver::checkCalibration(const std::string& checksum)
503 {
504  if (primary_stream_ == nullptr)
505  {
506  throw std::runtime_error("checkCalibration() called without a primary interface connection being established.");
507  }
510  prod.setupProducer();
511 
512  CalibrationChecker consumer(checksum);
513 
514  comm::INotifier notifier;
515 
516  comm::Pipeline<primary_interface::PrimaryPackage> pipeline(prod, &consumer, "Pipeline", notifier);
517  pipeline.run();
518 
519  while (!consumer.isChecked())
520  {
521  std::this_thread::sleep_for(std::chrono::seconds(1));
522  }
523  URCL_LOG_DEBUG("Got calibration information from robot.");
524  return consumer.checkSuccessful();
525 }
526 
528 {
529  return rtde_client_->getWriter();
530 }
531 
532 bool UrDriver::sendScript(const std::string& program)
533 {
534  if (secondary_stream_ == nullptr)
535  {
536  throw std::runtime_error("Sending script to robot requested while there is no primary interface established. "
537  "This "
538  "should not happen.");
539  }
540 
541  // urscripts (snippets) must end with a newline, or otherwise the controller's runtime will
542  // not execute them. To avoid problems, we always just append a newline here, even if
543  // there may already be one.
544  auto program_with_newline = program + '\n';
545 
546  size_t len = program_with_newline.size();
547  const uint8_t* data = reinterpret_cast<const uint8_t*>(program_with_newline.c_str());
548  size_t written;
549 
550  if (secondary_stream_->write(data, len, written))
551  {
552  URCL_LOG_DEBUG("Sent program to robot:\n%s", program_with_newline.c_str());
553  return true;
554  }
555  URCL_LOG_ERROR("Could not send program to robot");
556  return false;
557 }
558 
560 {
561  if (in_headless_mode_)
562  {
564  }
565  else
566  {
567  URCL_LOG_ERROR("Tried to send robot program directly while not in headless mode");
568  return false;
569  }
570 }
571 
572 std::vector<std::string> UrDriver::getRTDEOutputRecipe()
573 {
574  return rtde_client_->getOutputRecipe();
575 }
576 
577 void UrDriver::setKeepaliveCount(const uint32_t& count)
578 {
579  reverse_interface_->setKeepaliveCount(count);
580 }
581 } // namespace urcl
static const std::string SERVER_IP_REPLACE("{{SERVER_IP_REPLACE}}")
bool in_headless_mode_
Definition: ur_driver.h:489
std::unique_ptr< control::ReverseInterface > reverse_interface_
Definition: ur_driver.h:475
UrDriver(const std::string &robot_ip, const std::string &script_file, const std::string &output_recipe_file, const std::string &input_recipe_file, std::function< void(bool)> handle_program_state, bool headless_mode, std::unique_ptr< ToolCommSetup > tool_comm_setup, const uint32_t reverse_port=50001, const uint32_t script_sender_port=50002, int servoj_gain=2000, double servoj_lookahead_time=0.03, bool non_blocking_read=false, const std::string &reverse_ip="", const uint32_t trajectory_port=50003, const uint32_t script_command_port=50004, double force_mode_damping=0.025, double force_mode_gain_scaling=0.5)
Constructs a new UrDriver object. Upon initialization this class will check the calibration checksum ...
Definition: ur_driver.cpp:55
#define URCL_LOG_ERROR(...)
Definition: log.h:26
This is the main class for interfacing the driver.
Definition: ur_driver.h:52
ToolVoltage
Possible values for the tool voltage.
static const int32_t MULT_JOINTSTATE
bool non_blocking_read_
Definition: ur_driver.h:493
bool writeJointCommand(const vector6d_t &values, const comm::ControlMode control_mode)
Writes a joint command together with a keepalive signal onto the socket being sent to the robot...
Definition: ur_driver.cpp:262
void setupProducer() override
Triggers the stream to connect to the robot.
Definition: producer.h:63
void run()
Starts the producer and, if existing, the consumer in new threads.
Definition: pipeline.h:300
The ScriptCommandInterface class starts a TCPServer for a robot to connect to and this connection is ...
comm::INotifier notifier_
Definition: ur_driver.h:473
VersionInformation robot_version_
Definition: ur_driver.h:495
FreedriveControlMessage
Control messages for starting and stopping freedrive mode.
The TrajectoryPointInterface class handles trajectory forwarding to the robot. Full trajectories are ...
static const std::string JOINT_STATE_REPLACE("{{JOINT_STATE_REPLACE}}")
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
Definition: stream.h:42
std::string readScriptFile(const std::string &filename)
Definition: ur_driver.cpp:494
std::vector< std::string > getRTDEOutputRecipe()
Getter for the RTDE output recipe used in the RTDE client.
Definition: ur_driver.cpp:572
static const std::string TIME_REPLACE("{{TIME_REPLACE}}")
bool sendRobotProgram()
Sends the external control program to the robot.
Definition: ur_driver.cpp:559
The primary specific parser. Interprets a given byte stream as serialized primary packages and parses...
A specialized exception representing that communication to the tool is not possible.
Definition: exceptions.h:94
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:454
uint32_t servoj_gain_
Definition: ur_driver.h:483
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:273
std::array< double, 3 > vector3d_t
Definition: types.h:29
void startRTDECommunication()
Starts the RTDE communication.
Definition: ur_driver.cpp:483
Set when no controller is currently active controlling the robot.
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:329
The RTDEWriter class offers an abstraction layer to send data to the robot via the RTDE interface...
Definition: rtde_writer.h:49
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:488
std::unique_ptr< control::ScriptSender > script_sender_
Definition: ur_driver.h:478
const VersionInformation & getVersion()
Returns version information about the currently connected robot.
Definition: ur_driver.h:423
std::unique_ptr< control::ScriptCommandInterface > script_command_interface_
Definition: ur_driver.h:477
std::unique_ptr< control::TrajectoryPointInterface > trajectory_interface_
Definition: ur_driver.h:476
rtde_interface::RTDEWriter & getRTDEWriter()
Getter for the RTDE writer used to write to the robot&#39;s RTDE interface.
Definition: ur_driver.cpp:527
static const std::string SERVO_J_REPLACE("{{SERVO_J_REPLACE}}")
Parent class for notifiers.
Definition: pipeline.h:210
uint32_t major
Major version number.
std::string full_robot_program_
Definition: ur_driver.h:490
#define URCL_LOG_DEBUG(...)
Definition: log.h:23
static const std::string FORCE_MODE_SET_GAIN_SCALING_REPLACE("{{FORCE_MODE_SET_GAIN_SCALING_REPLACE}}")
static const std::string SERVER_PORT_REPLACE("{{SERVER_PORT_REPLACE}}")
bool writeKeepalive()
Write a keepalive signal only.
Definition: ur_driver.cpp:477
bool sendScript(const std::string &program)
Sends a custom script program to the robot.
Definition: ur_driver.cpp:532
std::unique_ptr< comm::URStream< primary_interface::PrimaryPackage > > primary_stream_
Definition: ur_driver.h:479
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:348
bool isChecked()
Used to make sure the calibration check is not performed several times.
static const std::string TRAJECTORY_PORT_REPLACE("{{TRAJECTORY_SERVER_PORT_REPLACE}}")
bool zeroFTSensor()
Zero the force torque sensor (only availbe on e-Series). Note: It requires the external control scrip...
Definition: ur_driver.cpp:301
ControlMode
Control modes as interpreted from the script runnning on the robot.
Definition: control_mode.h:39
bool startForceMode(const vector6d_t &task_frame, const vector6uint32_t &selection_vector, const vector6d_t &wrench, const unsigned int type, const vector6d_t &limits)
Start the robot to be controlled in force mode.
Definition: ur_driver.cpp:380
When this is set, the program is expected to stop and exit.
#define URCL_LOG_WARN(...)
Definition: log.h:24
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:252
The ScriptSender class starts a TCPServer for a robot to connect to and waits for a request to receiv...
Definition: script_sender.h:47
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:267
int get_packet_timeout_
Definition: ur_driver.h:492
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:431
std::unique_ptr< rtde_interface::RTDEClient > rtde_client_
Definition: ur_driver.h:474
bool writeFreedriveControlMessage(const control::FreedriveControlMessage freedrive_action)
Writes a control message in freedrive mode.
Definition: ur_driver.cpp:296
int rtde_frequency_
Definition: ur_driver.h:472
constexpr std::underlying_type< E >::type toUnderlying(const E e) noexcept
Converts an enum type to its underlying type.
Definition: types.h:58
TrajectoryControlMessage
Control messages for forwarding and aborting trajectories.
bool writeTrajectoryControlMessage(const control::TrajectoryControlMessage trajectory_action, const int point_number=0)
Writes a control message in trajectory forward mode.
Definition: ur_driver.cpp:290
The CalibrationChecker class consumes primary packages ignoring all but KinematicsInfo packages...
The RTDEClient class manages communication over the RTDE interface. It contains the RTDE handshake an...
Definition: rtde_client.h:92
double servoj_time_
Definition: ur_driver.h:482
static const int UR_SECONDARY_PORT
bool checkCalibration(const std::string &checksum)
Checks if the kinematics information in the used model fits the actual robot.
Definition: ur_driver.cpp:502
double servoj_lookahead_time_
Definition: ur_driver.h:484
static const std::string BEGIN_REPLACE("{{BEGIN_REPLACE}}")
std::string robot_ip_
Definition: ur_driver.h:488
std::array< uint32_t, 6 > vector6uint32_t
Definition: types.h:32
static const std::string SCRIPT_COMMAND_PORT_REPLACE("{{SCRIPT_COMMAND_SERVER_PORT_REPLACE}}")
std::array< double, 6 > vector6d_t
Definition: types.h:30
static const std::string FORCE_MODE_SET_DAMPING_REPLACE("{{FORCE_MODE_SET_DAMPING_REPLACE}}")
bool checkSuccessful()
Returns whether the calibration check was successful.
The Pipepline manages the production and optionally consumption of packages. Cyclically the producer ...
Definition: pipeline.h:235
#define URCL_LOG_INFO(...)
Definition: log.h:25
std::unique_ptr< comm::URStream< primary_interface::PrimaryPackage > > secondary_stream_
Definition: ur_driver.h:480
A general producer for URPackages. Implements funcionality to produce packages by reading and parsing...
Definition: producer.h:40
The ReverseInterface class handles communication to the robot. It starts a server and waits for the r...
Our base class for exceptions. Specialized exceptions should inherit from those.
Definition: exceptions.h:41
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:577
bool endForceMode()
Stop force mode and put the robot into normal operation mode.
Definition: ur_driver.cpp:418


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47