xarm_driver.cpp
Go to the documentation of this file.
1 /* Copyright 2018 UFACTORY Inc. All Rights Reserved.
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Author: Jason Peng <jason@ufactory.cc>
6  ============================================================================*/
7 #include <xarm_driver.h>
9 #define CMD_HEARTBEAT_SEC 30 // 30s
10 
11 void* cmd_heart_beat(void* args)
12 {
13  xarm_api::XARMDriver *my_driver = (xarm_api::XARMDriver *) args;
14  UxbusCmd *arm_cmd = my_driver->get_uxbus_cmd();
15  while(arm_cmd->is_ok() == 0)
16  {
17  ros::Duration(CMD_HEARTBEAT_SEC).sleep(); // non-realtime
18  my_driver->Heartbeat();
19  }
20  ROS_ERROR("xArm Control Connection Failed! Please Shut Down (Ctrl-C) and Retry ...");
21  return (void*)0;
22 }
23 
24 namespace xarm_api
25 {
27  {
29  arm_cmd_->close();
30  spinner.stop();
31  }
32 
34  {
36  }
37 
38  bool XARMDriver::reConnectReportSocket(char *server_ip)
39  {
41  return arm_report_ != NULL;
42  }
43 
44  void XARMDriver::XARMDriverInit(ros::NodeHandle& root_nh, char *server_ip)
45  {
46  nh_ = root_nh;
47  nh_.getParam("DOF",dof_);
48  root_nh.getParam("xarm_report_type", report_type_);
50  // arm_report_ = connext_tcp_report_norm(server_ip);
51  // ReportDataNorm norm_data_;
52  arm_cmd_ = connect_tcp_control(server_ip);
53  if (arm_cmd_ == NULL)
54  ROS_ERROR("Xarm Connection Failed!");
55  else // clear unimportant errors
56  {
57  std::thread th(cmd_heart_beat, this);
58  th.detach();
59  int dbg_msg[16] = {0};
60  arm_cmd_->servo_get_dbmsg(dbg_msg);
61 
62  for(int i=0; i<dof_; i++)
63  {
64  if((dbg_msg[i*2]==1)&&(dbg_msg[i*2+1]==40))
65  {
67  ROS_WARN("Cleared low-voltage error of joint %d", i+1);
68  }
69  else if((dbg_msg[i*2]==1))
70  {
72  ROS_WARN("There is servo error code:(0x%x) in joint %d, trying to clear it..", dbg_msg[i*2+1], i+1);
73  }
74  }
75 
76  }
77 
78  // api command services:
84 
96 
97  // axis-angle motion:
100 
101  // tool io:
106  set_modbus_server_ = nh_.advertiseService("set_tool_modbus", &XARMDriver::SetModbusCB, this);
107 
111 
113 
114  // controller_io (digital):
119 
120  // velocity control:
123  set_max_jacc_server_ = nh_.advertiseService("set_max_acc_joint", &XARMDriver::SetMaxJAccCB, this);
125 
126  // trajectory recording and playback (beta):
127  traj_record_server_ = nh_.advertiseService("set_recording", &XARMDriver::SetRecordingCB, this); // start(1)/stop(0) recording
129  traj_play_server_ = nh_.advertiseService("play_traj", &XARMDriver::LoadNPlayTrajCB, this); // load and playback recorded trajectory
130 
131  // state feedback topics:
132  joint_state_ = nh_.advertise<sensor_msgs::JointState>("joint_states", 10, true);
133  robot_rt_state_ = nh_.advertise<xarm_msgs::RobotMsg>("xarm_states", 10, true);
134  // end_input_state_ = nh_.advertise<xarm_msgs::IOState>("xarm_input_states", 10, true);
135  cgpio_state_ = nh_.advertise<xarm_msgs::CIOState>("xarm_cgpio_states", 10, true);
136 
137  // subscribed topics
138  sleep_sub_ = nh_.subscribe("sleep_sec", 1, &XARMDriver::SleepTopicCB, this);
139 
140  }
141 
143  {
144  int cmd_num;
145  int ret = arm_cmd_->get_cmdnum(&cmd_num);
146  // if(ret)
147  // {
148  // ROS_ERROR("xArm Heartbeat error! ret = %d", ret);
149  // }
150  // ROS_INFO("xArm Heartbeat! %d", cmd_num);
151  }
152 
154  {
155  return arm_report_->is_ok() == 0; // is_ok will return 0 if connection is normal
156  }
157 
158  void XARMDriver::SleepTopicCB(const std_msgs::Float32ConstPtr& msg)
159  {
160  if(msg->data>0)
161  arm_cmd_->sleep_instruction(msg->data);
162  }
163 
164  bool XARMDriver::ClearErrCB(xarm_msgs::ClearErr::Request& req, xarm_msgs::ClearErr::Response& res)
165  {
166  // First clear controller warning and error:
167  int ret1 = arm_cmd_->gripper_modbus_clean_err();
168  int ret2 = arm_cmd_->clean_war();
169  int ret3 = arm_cmd_->clean_err();
170 
171  // Then try to enable motor again:
172  res.ret = arm_cmd_->motion_en(8, 1);
173 
174  if(res.ret)
175  {
176  res.message = "clear err, ret = " + std::to_string(res.ret);
177  }
178  return true;
179 
180  // After calling this service, user should check '/xarm_states' again to make sure 'err' field is 0, to confirm success.
181  }
182 
183  bool XARMDriver::MoveitClearErrCB(xarm_msgs::ClearErr::Request& req, xarm_msgs::ClearErr::Response& res)
184  {
185  if(ClearErrCB(req, res))
186  {
187  arm_cmd_->set_mode(1);
188  int ret = arm_cmd_->set_state(0);
189 
190  if(!ret)
191  return true;
192  return false;
193  }
194  return false;
195 
196  // After calling this service, user should check '/xarm_states' again to make sure 'err' field is 0, to confirm success.
197  }
198 
199  bool XARMDriver::GetErrCB(xarm_msgs::GetErr::Request & req, xarm_msgs::GetErr::Response & res)
200  {
201  res.err = curr_err_;
202  res.message = "current error code = " + std::to_string(res.err);
203  return true;
204  }
205 
206  bool XARMDriver::MotionCtrlCB(xarm_msgs::SetAxis::Request& req, xarm_msgs::SetAxis::Response& res)
207  {
208  res.ret = arm_cmd_->motion_en(req.id, req.data);
209  if(req.data == 1)
210  {
211  res.message = "motion enable, ret = " + std::to_string(res.ret);
212  }
213  else
214  {
215  res.message = "motion disable, ret = " + std::to_string(res.ret);
216  }
217  return true;
218  }
219 
220  bool XARMDriver::SetModeCB(xarm_msgs::SetInt16::Request& req, xarm_msgs::SetInt16::Response& res)
221  {
222  /* for successful none-zero mode switch, must happen at STOP state */
224  ros::Duration(0.01).sleep();
225 
226  res.ret = arm_cmd_->set_mode(req.data);
227  switch(req.data)
228  {
229  case XARM_MODE::POSE:
230  {
231  res.message = "pose mode, ret = " + std::to_string(res.ret);
232  }break;
233  case XARM_MODE::SERVO:
234  {
235  res.message = "servo mode, ret = " + std::to_string(res.ret);
236  }break;
238  {
239  res.message = "cartesian teach, ret = " + std::to_string(res.ret);
240  } break;
242  {
243  res.message = "joint teach, ret = " + std::to_string(res.ret);
244  } break;
246  {
247  res.message = "joint velocity, ret = " + std::to_string(res.ret);
248  } break;
250  {
251  res.message = "cartesian velocity, ret = " + std::to_string(res.ret);
252  } break;
253  default:
254  {
255  res.message = "the failed mode, ret = " + std::to_string(res.ret);
256  }
257  }
258 
259  return true;
260  }
261 
262  bool XARMDriver::SetStateCB(xarm_msgs::SetInt16::Request& req, xarm_msgs::SetInt16::Response& res)
263  {
264  res.ret = arm_cmd_->set_state(req.data);
265  switch(req.data)
266  {
267  case XARM_STATE::START:
268  {
269  res.message = "start, ret = " + std::to_string(res.ret);
270  }break;
271  case XARM_STATE::PAUSE:
272  {
273  res.message = "pause, ret = " + std::to_string(res.ret);
274  }break;
275  case XARM_STATE::STOP:
276  {
277  res.message = "stop, ret = " + std::to_string(res.ret);
278  }break;
279  default:
280  {
281  res.message = "the failed state, ret = " + std::to_string(res.ret);
282  }
283  }
284 
285  return true;
286  }
287 
288  bool XARMDriver::SetTCPOffsetCB(xarm_msgs::TCPOffset::Request &req, xarm_msgs::TCPOffset::Response &res)
289  {
290  float offsets[6] = {req.x, req.y, req.z, req.roll, req.pitch, req.yaw};
291  res.ret = arm_cmd_->set_tcp_offset(offsets) | arm_cmd_->save_conf();
292  res.message = "set tcp offset: ret = " + std::to_string(res.ret);
293  return true;
294  }
295 
296  bool XARMDriver::SetLoadCB(xarm_msgs::SetLoad::Request &req, xarm_msgs::SetLoad::Response &res)
297  {
298  float Mass = req.mass;
299  float CoM[3] = {req.xc, req.yc, req.zc};
300  res.ret = arm_cmd_->set_tcp_load(Mass, CoM) | arm_cmd_->save_conf();
301  res.message = "set load: ret = " + std::to_string(res.ret);
302  return true;
303  }
304 
305  bool XARMDriver::SetControllerDOutCB(xarm_msgs::SetDigitalIO::Request &req, xarm_msgs::SetDigitalIO::Response &res)
306  {
307  if(req.io_num>=1 && req.io_num<=8)
308  {
309  res.ret = arm_cmd_->cgpio_set_auxdigit(req.io_num-1, req.value);
310  res.message = "set Controller digital Output "+ std::to_string(req.io_num) +" to "+ std::to_string(req.value) + " : ret = " + std::to_string(res.ret);
311  return true;
312  }
313  ROS_WARN("Controller Digital IO io_num: from 1 to 8");
314  return false;
315  }
316 
317  bool XARMDriver::GetControllerDInCB(xarm_msgs::GetControllerDigitalIO::Request &req, xarm_msgs::GetControllerDigitalIO::Response &res)
318  {
319  if(req.io_num>=1 && req.io_num<=8)
320  {
321  int all_status;
322  res.ret = arm_cmd_->cgpio_get_auxdigit(&all_status);
323  res.value = (all_status >> (req.io_num - 1)) & 0x0001;
324  res.message = "get Controller digital Input ret = " + std::to_string(res.ret);
325  return true;
326  }
327  ROS_WARN("Controller Digital IO io_num: from 1 to 8");
328  return false;
329  }
330 
331  bool XARMDriver::GetControllerAInCB(xarm_msgs::GetAnalogIO::Request &req, xarm_msgs::GetAnalogIO::Response &res)
332  {
333  switch (req.port_num)
334  {
335  case 1:
336  res.ret = arm_cmd_->cgpio_get_analog1(&res.analog_value);
337  break;
338  case 2:
339  res.ret = arm_cmd_->cgpio_get_analog2(&res.analog_value);
340  break;
341 
342  default:
343  res.message = "GetAnalogIO Fail: port number incorrect ! Must be 1 or 2";
344  return false;
345  }
346  res.message = "get controller analog port " + std::to_string(req.port_num) + ", ret = " + std::to_string(res.ret);
347  return true;
348  }
349 
350  bool XARMDriver::SetControllerAOutCB(xarm_msgs::SetControllerAnalogIO::Request &req, xarm_msgs::SetControllerAnalogIO::Response &res)
351  {
352  switch (req.port_num)
353  {
354  case 1:
355  res.ret = arm_cmd_->cgpio_set_analog1(req.analog_value);
356  break;
357  case 2:
358  res.ret = arm_cmd_->cgpio_set_analog2(req.analog_value);
359  break;
360 
361  default:
362  res.message = "SetAnalogIO Fail: port number incorrect ! Must be 1 or 2";
363  return false;
364  }
365  res.message = "Set controller analog port " + std::to_string(req.port_num) + ", ret = " + std::to_string(res.ret);
366  return true;
367  }
368 
369  bool XARMDriver::SetDigitalIOCB(xarm_msgs::SetDigitalIO::Request &req, xarm_msgs::SetDigitalIO::Response &res)
370  {
371  res.ret = arm_cmd_->tgpio_set_digital(req.io_num, req.value);
372  res.message = "set Digital port "+ std::to_string(req.io_num) +" to "+ std::to_string(req.value) + " : ret = " + std::to_string(res.ret);
373  return true;
374  }
375 
376  bool XARMDriver::GetDigitalIOCB(xarm_msgs::GetDigitalIO::Request &req, xarm_msgs::GetDigitalIO::Response &res)
377  {
378  res.ret = arm_cmd_->tgpio_get_digital(&res.digital_1, &res.digital_2);
379  res.message = "get Digital port ret = " + std::to_string(res.ret);
380  return true;
381  }
382 
383  bool XARMDriver::GetAnalogIOCB(xarm_msgs::GetAnalogIO::Request &req, xarm_msgs::GetAnalogIO::Response &res)
384  {
385  switch (req.port_num)
386  {
387  case 1:
388  res.ret = arm_cmd_->tgpio_get_analog1(&res.analog_value);
389  break;
390  case 2:
391  res.ret = arm_cmd_->tgpio_get_analog2(&res.analog_value);
392  break;
393 
394  default:
395  res.message = "GetAnalogIO Fail: port number incorrect ! Must be 1 or 2";
396  return false;
397  }
398  res.message = "get tool analog port " + std::to_string(req.port_num) + ", ret = " + std::to_string(res.ret);
399  return true;
400  }
401 
402  bool XARMDriver::SetModbusCB(xarm_msgs::SetToolModbus::Request &req, xarm_msgs::SetToolModbus::Response &res)
403  {
404  int send_len = req.send_data.size();
405  int recv_len = req.respond_len;
406  unsigned char * tx_data = new unsigned char [send_len]{0};
407  unsigned char * rx_data = new unsigned char [recv_len]{0};
408 
409  for(int i=0; i<send_len; i++)
410  {
411  tx_data[i] = req.send_data[i];
412  }
413  res.ret = arm_cmd_->tgpio_set_modbus(tx_data, send_len, rx_data);
414  for(int i=0; i<recv_len; i++)
415  {
416  res.respond_data.push_back(rx_data[i]);
417  }
418 
419  delete [] tx_data;
420  delete [] rx_data;
421  return true;
422  }
423 
424  bool XARMDriver::ConfigModbusCB(xarm_msgs::ConfigToolModbus::Request &req, xarm_msgs::ConfigToolModbus::Response &res)
425  {
426  res.message = "";
427  if(get_error())
428  {
430  ROS_WARN("Cleared Existing Error Code %d", curr_err_);
431  }
432 
433  int ret = arm_cmd_->set_modbus_baudrate(req.baud_rate);
434  if(ret)
435  {
436  res.message = "set baud_rate, ret = "+ std::to_string(ret);
437  if(ret==1)
438  res.message += " controller error exists, please check and run clear_err service first!";
439  }
440  ret = arm_cmd_->set_modbus_timeout(req.timeout_ms);
441  if(ret)
442  {
443  res.message += (std::string(" set baud_rate, ret = ") + std::to_string(ret));
444  if(ret==1)
445  res.message += " controller error exists, please check and run clear_err service first!";
446  }
447 
448  if(res.message.size())
449  res.ret = -1;
450  else
451  res.message = "Modbus configuration OK";
452 
453  return true;
454  }
455 
456  bool XARMDriver::GoHomeCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
457  {
458  res.ret = arm_cmd_->move_gohome(req.mvvelo, req.mvacc, req.mvtime);
459  if(!res.ret)
460  {
461  res.ret = wait_for_finish();
462  }
463  res.message = "go home, ret = " + std::to_string(res.ret);
464  return true;
465  }
466 
467  bool XARMDriver::MoveJointCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
468  {
469  float joint[7]={0};
470  int index = 0;
471  if(req.pose.size() != dof_)
472  {
473  res.ret = req.pose.size();
474  res.message = "pose parameters incorrect! Expected: "+std::to_string(dof_);
475  return true;
476  }
477  else
478  {
479  for(index = 0; index < 7; index++) // should always send 7 joint commands, whatever current DOF is.
480  {
481  // joint[0][index] = req.pose[index];
482  if(index<req.pose.size())
483  joint[index] = req.pose[index];
484  else
485  joint[index] = 0;
486  }
487  }
488 
489  res.ret = arm_cmd_->move_joint(joint, req.mvvelo, req.mvacc, req.mvtime);
490  if(!res.ret)
491  {
492  res.ret = wait_for_finish();
493  }
494  res.message = "move joint, ret = " + std::to_string(res.ret);
495  return true;
496  }
497 
498  bool XARMDriver::MoveLineCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
499  {
500  float pose[6];
501  int index = 0;
502  if(req.pose.size() != 6)
503  {
504  res.ret = -1;
505  res.message = "number of parameters incorrect!";
506  return true;
507  }
508  else
509  {
510  for(index = 0; index < 6; index++)
511  {
512  pose[index] = req.pose[index];
513  }
514  }
515 
516  res.ret = arm_cmd_->move_line(pose, req.mvvelo, req.mvacc, req.mvtime);
517  if(!res.ret)
518  {
519  res.ret = wait_for_finish();
520  }
521  res.message = "move line, ret = " + std::to_string(res.ret);
522  return true;
523  }
524 
525  bool XARMDriver::MoveLineToolCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
526  {
527  float pose[6];
528  int index = 0;
529  if(req.pose.size() != 6)
530  {
531  res.ret = -1;
532  res.message = "number of parameters incorrect!";
533  return true;
534  }
535  else
536  {
537  for(index = 0; index < 6; index++)
538  {
539  pose[index] = req.pose[index];
540  }
541  }
542 
543  res.ret = arm_cmd_->move_line_tool(pose, req.mvvelo, req.mvacc, req.mvtime);
544  if(!res.ret)
545  {
546  res.ret = wait_for_finish();
547  }
548  res.message = "move line tool, ret = " + std::to_string(res.ret);
549  return true;
550  }
551 
552  bool XARMDriver::MoveLinebCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
553  {
554  float pose[6];
555  int index = 0;
556  if(req.pose.size() != 6)
557  {
558  res.ret = -1;
559  res.message = "number of parameters incorrect!";
560  return true;
561  }
562  else
563  {
564  for(index = 0; index < 6; index++)
565  {
566  pose[index] = req.pose[index];
567  }
568  }
569 
570  res.ret = arm_cmd_->move_lineb(pose, req.mvvelo, req.mvacc, req.mvtime, req.mvradii);
571  res.message = "move lineb, ret = " + std::to_string(res.ret);
572  return true;
573  }
574 
575  bool XARMDriver::MoveJointbCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
576  {
577  float joint[7]={0};
578  int index = 0;
579  if(req.pose.size() != dof_)
580  {
581  res.ret = req.pose.size();
582  res.message = "number of joint parameters incorrect! Expected: "+std::to_string(dof_);
583  return true;
584  }
585  else
586  {
587  for(index = 0; index < 7; index++) // should always send 7 joint commands, whatever current DOF is.
588  {
589  if(index<req.pose.size())
590  joint[index] = req.pose[index];
591  else
592  joint[index] = 0;
593  }
594  }
595 
596  res.ret = arm_cmd_->move_jointb(joint, req.mvvelo, req.mvacc, req.mvradii);
597  if(!res.ret)
598  {
599  res.ret = wait_for_finish();
600  }
601  res.message = "move jointB, ret = " + std::to_string(res.ret);
602  return true;
603  }
604 
605  bool XARMDriver::MoveServoJCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
606  {
607  float pose[7]={0};
608  int index = 0;
609  if(req.pose.size() != dof_)
610  {
611  res.ret = req.pose.size();
612  res.message = "pose parameters incorrect! Expected: "+std::to_string(dof_);
613  return true;
614  }
615  else
616  {
617  for(index = 0; index < 7; index++) // should always send 7 joint commands, whatever current DOF is.
618  {
619  if(index<req.pose.size())
620  pose[index] = req.pose[index];
621  else
622  pose[index] = 0;
623  }
624  }
625 
626  res.ret = arm_cmd_->move_servoj(pose, req.mvvelo, req.mvacc, req.mvtime);
627  res.message = "move servoj, ret = " + std::to_string(res.ret);
628  return true;
629  }
630 
631  bool XARMDriver::MoveServoCartCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
632  {
633  float pose[6];
634  int index = 0;
635  if(req.pose.size() != 6)
636  {
637  res.ret = -1;
638  res.message = "MoveServoCartCB parameters incorrect!";
639  return true;
640  }
641  else
642  {
643  for(index = 0; index < 6; index++)
644  {
645  pose[index] = req.pose[index];
646  }
647  }
648 
649  res.ret = arm_cmd_->move_servo_cartesian(pose, req.mvvelo, req.mvacc, req.mvtime);
650  res.message = "move servo_cartesian, ret = " + std::to_string(res.ret);
651  return true;
652  }
653 
654  bool XARMDriver::MoveLineAACB(xarm_msgs::MoveAxisAngle::Request &req, xarm_msgs::MoveAxisAngle::Response &res)
655  {
656  float pose[6];
657  int index = 0;
658  if(req.pose.size() != 6)
659  {
660  res.ret = -1;
661  res.message = "MoveServoCartCB parameters incorrect!";
662  return true;
663  }
664  else
665  {
666  for(index = 0; index < 6; index++)
667  {
668  pose[index] = req.pose[index];
669  }
670  }
671  res.ret = arm_cmd_->move_line_aa(pose, req.mvvelo, req.mvacc, req.mvtime, req.coord, req.relative);
672  if(!res.ret)
673  {
674  res.ret = wait_for_finish();
675  }
676  res.message = "move_line_aa, ret = " + std::to_string(res.ret);
677  return true;
678  }
679 
680  bool XARMDriver::MoveServoCartAACB(xarm_msgs::MoveAxisAngle::Request &req, xarm_msgs::MoveAxisAngle::Response &res)
681  {
682  float pose[6];
683  int index = 0;
684  if(req.pose.size() != 6)
685  {
686  res.ret = -1;
687  res.message = "MoveServoCartAACB parameters incorrect!";
688  return true;
689  }
690  else
691  {
692  for(index = 0; index < 6; index++)
693  {
694  pose[index] = req.pose[index];
695  }
696  }
697  res.ret = arm_cmd_->move_servo_cart_aa(pose, req.mvvelo, req.mvacc, req.coord, req.relative);
698  res.message = "move_servo_cart_aa, ret = " + std::to_string(res.ret);
699  return true;
700  }
701 
702  bool XARMDriver::VeloMoveJointCB(xarm_msgs::MoveVelo::Request &req, xarm_msgs::MoveVelo::Response &res)
703  {
704  float jnt_v[7]={0};
705  int index = 0;
706  if(req.velocities.size() < dof_)
707  {
708  res.ret = req.velocities.size();
709  res.message = "pose parameters incorrect! Expected: "+std::to_string(dof_);
710  return true;
711  }
712  else
713  {
714  for(index = 0; index < 7; index++) // should always send 7 joint commands, whatever current DOF is.
715  {
716  // jnt_v[0][index] = req.velocities[index];
717  if(index < req.velocities.size())
718  jnt_v[index] = req.velocities[index];
719  else
720  jnt_v[index] = 0;
721  }
722  }
723 
724  res.ret = arm_cmd_->vc_set_jointv(jnt_v, req.jnt_sync);
725  res.message = "velocity move joint, ret = " + std::to_string(res.ret);
726  return true;
727  }
728 
729  bool XARMDriver::VeloMoveLineVCB(xarm_msgs::MoveVelo::Request &req, xarm_msgs::MoveVelo::Response &res)
730  {
731  float line_v[6];
732  int index = 0;
733  if(req.velocities.size() < 6)
734  {
735  res.ret = -1;
736  res.message = "number of parameters incorrect!";
737  return true;
738  }
739  else
740  {
741  for(index = 0; index < 6; index++)
742  {
743  line_v[index] = req.velocities[index];
744  }
745  }
746 
747  res.ret = arm_cmd_->vc_set_linev(line_v, req.coord);
748  res.message = "velocity move line, ret = " + std::to_string(res.ret);
749  return true;
750  }
751 
752  bool XARMDriver::SetMaxJAccCB(xarm_msgs::SetFloat32::Request &req, xarm_msgs::SetFloat32::Response &res)
753  {
754  if(req.data<0 || req.data>20.0)
755  {
756  res.ret = -1;
757  res.message = "set max joint acc: " + std::to_string(req.data) + "error! Proper range is: 0-20.0 rad/s^2";
758  return true;
759  }
760  res.ret = arm_cmd_->set_joint_maxacc(req.data);
761  res.message = "set max joint acc: " + std::to_string(req.data) + " ret = " + std::to_string(res.ret);
762  return true;
763  }
764 
765  bool XARMDriver::SetMaxLAccCB(xarm_msgs::SetFloat32::Request &req, xarm_msgs::SetFloat32::Response &res)
766  {
767  if(req.data<0 || req.data>50000.0)
768  {
769  res.ret = -1;
770  res.message = "set max linear acc: " + std::to_string(req.data) + "error! Proper range is: 0-50000.0 mm/s^2";
771  return true;
772  }
773  res.ret = arm_cmd_->set_tcp_maxacc(req.data);
774  res.message = "set max linear acc: " + std::to_string(req.data) + " ret = " + std::to_string(res.ret);
775  return true;
776  }
777 
778  bool XARMDriver::GripperConfigCB(xarm_msgs::GripperConfig::Request &req, xarm_msgs::GripperConfig::Response &res)
779  {
780  if(req.pulse_vel>5000)
781  req.pulse_vel = 5000;
782  else if(req.pulse_vel<0)
783  req.pulse_vel = 0;
784 
785 
786  int ret1 = arm_cmd_->gripper_modbus_set_mode(0);
787  int ret2 = arm_cmd_->gripper_modbus_set_en(1);
788  int ret3 = arm_cmd_->gripper_modbus_set_posspd(req.pulse_vel);
789 
790  if(ret1 || ret2 || ret3)
791  {
792  res.ret = ret3;
793  }
794  else
795  {
796  res.ret = 0;
797  }
798  res.message = "gripper_config, ret = " + std::to_string(res.ret);
799  return true;
800  }
801 
802  bool XARMDriver::GripperMoveCB(xarm_msgs::GripperMove::Request &req, xarm_msgs::GripperMove::Response &res)
803  {
804  if(req.pulse_pos>850)
805  req.pulse_pos = 850;
806  else if(req.pulse_pos<-100)
807  req.pulse_pos = -100;
808 
809  res.ret = arm_cmd_->gripper_modbus_set_pos(req.pulse_pos);
810  res.message = "gripper_move, ret = " + std::to_string(res.ret);
811  return true;
812  }
813 
814  bool XARMDriver::GripperStateCB(xarm_msgs::GripperState::Request &req, xarm_msgs::GripperState::Response &res)
815  {
816  int err_code = 0;
817  float pos_now = 0;
818  if(arm_cmd_->gripper_modbus_get_errcode(&err_code))
819  return false;
820 
821  if(arm_cmd_->gripper_modbus_get_pos(&pos_now))
822  return false;
823 
824  res.err_code = err_code;
825  res.curr_pos = pos_now;
826  // fprintf(stderr, "gripper_pos: %f, gripper_err: %d\n", res.curr_pos, res.err_code);
827  return true;
828  }
829 
830  bool XARMDriver::VacuumGripperCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
831  {
832  if(req.data)
833  {
834  res.ret = arm_cmd_->tgpio_set_digital(1, 1);
835  res.ret = arm_cmd_->tgpio_set_digital(2, 0);
836  }
837  else
838  {
839  res.ret = arm_cmd_->tgpio_set_digital(1, 0);
840  res.ret = arm_cmd_->tgpio_set_digital(2, 1);
841  }
842  res.message = "set vacuum gripper: " + std::to_string(req.data) + " ret = " + std::to_string(res.ret);
843  return true;
844  }
845 
846 
847  bool XARMDriver::SetRecordingCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
848  {
849  if(req.data)
850  res.ret = arm_cmd_->set_record_traj(1); // start recording
851  else
852  res.ret = arm_cmd_->set_record_traj(0); // stop recording
853  res.message = "set trajectory recording: " + std::to_string(req.data) + " ret = " + std::to_string(res.ret);
854  return true;
855  }
856 
857  static enum rw_status
858  {
859  IDLE = 0,
866 
867  }rw_status_now;
868 
869  bool XARMDriver::SaveTrajCB(xarm_msgs::SetString::Request &req, xarm_msgs::SetString::Response &res)
870  {
871  if(req.str_data.size()>80)
872  {
873  res.ret = -1;
874  res.message = "Save Trajectory ERROR: name length should be within 80 characrters!";
875  return false;
876  }
877  char file_name[81]={0};
878  req.str_data.copy(file_name, req.str_data.size(), 0);
879  res.ret = arm_cmd_->save_traj(file_name);
880 
881  int rw_status_int = IDLE;
882 
883  int wait_cnt = 0;
884  ros::Duration slp_t(0.1);
885  while(rw_status_int!=SAVE_SUCCESS && rw_status_int!=SAVE_FAIL)
886  {
887  slp_t.sleep();
888  arm_cmd_->get_traj_rw_status(&rw_status_int);
889 
890  if(wait_cnt++ >50 || get_state()==XARM_STATE::STOP)
891  {
892  res.ret = -1;
893  res.message = "Save trajectory file: Time out!";
894  return false;
895  }
896  if(rw_status_int == SAVE_FAIL)
897  {
898  res.ret = -1;
899  res.message = "SAVE trajectory file Failed!, please make sure Recording is not in progress!";
900  ROS_ERROR("%s", res.message.c_str());
901  return false;
902  }
903  }
904  res.message = "save trajectory file: " + req.str_data + " ret = " + std::to_string(res.ret);
905  return true;
906  }
907 
908  bool XARMDriver::LoadNPlayTrajCB(xarm_msgs::PlayTraj::Request &req, xarm_msgs::PlayTraj::Response &res)
909  {
910  /* LOAD: */
911  if(req.traj_file.size()>80)
912  {
913  res.ret = -1;
914  res.message = "Load Trajectory ERROR: name length should be within 80 characrters!";
915  ROS_ERROR("%s", res.message.c_str());
916  return false;
917  }
918 
919  if(req.speed_factor != 1 && req.speed_factor != 2 && req.speed_factor != 4)
920  {
921  res.ret = -1;
922  res.message = "PlayBack Trajectory ERROR: please check given speed_factor (int: 1, 2 or 4)";
923  ROS_ERROR("%s", res.message.c_str());
924  return false;
925  }
926 
928  {
929  res.ret = -1;
930  res.message = "Please set the Robot to be in proper Mode and state(0) before loading trajectory!";
931  ROS_ERROR("%s", res.message.c_str());
932  return false;
933  }
934 
935  char file_name[81]={0};
936  req.traj_file.copy(file_name, req.traj_file.size(), 0);
937  res.ret = arm_cmd_->load_traj(file_name);
938  int rw_status_int = IDLE;
939 
940  int wait_cnts = 0;
941  ros::Duration wait_slp(0.1);
942 
943  while(rw_status_int!=LOAD_SUCCESS && rw_status_int!=LOAD_FAIL)
944  {
945  wait_slp.sleep();
946  arm_cmd_->get_traj_rw_status(&rw_status_int);
947 
948  if(wait_cnts++ >50 || get_state()==XARM_STATE::STOP)
949  {
950  res.ret = -1;
951  res.message = "Load trajectory file: Time out!";
952  ROS_ERROR("%s", res.message.c_str());
953  return false;
954  }
955  if(rw_status_int == LOAD_FAIL)
956  {
957  res.ret = -1;
958  res.message = "Load trajectory file Failed!, please check the correction and existence of file_name !";
959  ROS_ERROR("%s", res.message.c_str());
960  return false;
961  }
962  }
963 
964  ROS_INFO("Load trajectory file success!");
965 
966  /* PLAY: */
967  wait_cnts = 0;
968  while(get_cmdnum())
969  {
970  wait_slp.sleep();
971  if(wait_cnts++>=100)
972  {
973  res.ret=-1;
974  res.message = "PlayBack Trajectory ERROR: TIME OUT waiting for previous tasks";
975  ROS_ERROR("%s", res.message.c_str());
976  return false;
977  }
978  }
979 
980  res.ret = arm_cmd_->playback_traj(req.repeat_times,req.speed_factor);
981 
982  wait_cnts = 0;
983  while(get_mode()!=11 && get_state()!=XARM_STATE::STOP) // 11 is internal mode for playback trajectory
984  {
985  wait_slp.sleep();
986  if(wait_cnts++ >=100)
987  {
988  res.ret=-1;
989  res.message = "PlayBack Trajectory ERROR: TIME OUT waiting for starting position";
990  ROS_ERROR("%s", res.message.c_str());
991  return false;
992  }
993  }
994 
995  ros::Duration(0.5).sleep(); // DO not remove!
996 
997  wait_cnts = 0;
998  while(get_state()==XARM_STATE::MOVING)
999  {
1000  wait_slp.sleep();
1001  if(wait_cnts++ >=3000)
1002  {
1003  res.ret=-1;
1005  res.message = "PlayBack Trajectory ERROR: TIME OUT waiting for trajectory completion";
1006  ROS_ERROR("%s", res.message.c_str());
1007  return false;
1008  }
1009  }
1011  res.message = "PlayBack Trajectory, ret = " + std::to_string(res.ret);
1012  return true;
1013 
1014  }
1015 
1016  void XARMDriver::pub_robot_msg(xarm_msgs::RobotMsg &rm_msg)
1017  {
1018  std::lock_guard<std::mutex> locker(*mutex_);
1019  curr_err_ = rm_msg.err;
1020  curr_state_ = rm_msg.state;
1021  curr_cmd_num_ = rm_msg.cmdnum;
1022  curr_mode_ = rm_msg.mode;
1023  robot_rt_state_.publish(rm_msg);
1024  }
1025 
1026  void XARMDriver::pub_joint_state(sensor_msgs::JointState &js_msg)
1027  {
1028  joint_state_.publish(js_msg);
1029  }
1030 
1032  {
1033  arm_cmd_->tgpio_get_digital(&io_msg.digital_1, &io_msg.digital_2);
1034  arm_cmd_->tgpio_get_analog1(&io_msg.analog_1);
1035  arm_cmd_->tgpio_get_analog2(&io_msg.analog_2);
1036 
1038  }
1039 
1040  void XARMDriver::pub_cgpio_state(xarm_msgs::CIOState &cio_msg)
1041  {
1042  cgpio_state_.publish(cio_msg);
1043  }
1044 
1045  int XARMDriver::get_frame(unsigned char *data)
1046  {
1047  int ret;
1048  ret = arm_report_->read_frame(data);
1049  return ret;
1050  }
1051 
1053  {
1054  std::lock_guard<std::mutex> locker(*mutex_);
1055  return curr_state_;
1056  }
1057 
1059  {
1060  std::lock_guard<std::mutex> locker(*mutex_);
1061  return curr_err_;
1062  }
1063 
1065  {
1066  std::lock_guard<std::mutex> locker(*mutex_);
1067  return curr_cmd_num_;
1068  }
1069 
1071  {
1072  std::lock_guard<std::mutex> locker(*mutex_);
1073  return curr_mode_;
1074  }
1075  // void XARMDriver::update_rich_data(unsigned char *data, int size)
1076  // {
1077  // memcpy(rx_data_, data, size);
1078  // }
1079 
1080  // int XARMDriver::flush_report_data(XArmReportData &report_data)
1081  // {
1082  // int ret;
1083  // ret = report_data_.flush_data(rx_data_);
1084  // report_data = report_data_;
1085  // return ret;
1086  // }
1087 
1088  // int XARMDriver::get_rich_data(ReportDataNorm &norm_data)
1089  // {
1090  // int ret;
1091  // ret = norm_data_.flush_data(rx_data_);
1092  // norm_data = norm_data_;
1093  // return ret;
1094  // }
1095 
1097  {
1098  bool wait;
1099  int ret = 0;
1100 
1101  nh_.getParam("wait_for_finish", wait);
1102 
1103  if(!wait)
1104  return ret;
1105 
1106  ros::Duration(0.2).sleep(); // delay 0.2s, for 5Hz state update
1107  ros::Rate sleep_rate(10); // 10Hz
1108 
1109  while(get_state()== 1) // in MOVE state
1110  {
1111  if(get_error())
1112  {
1113  ret = UXBUS_STATE::ERR_CODE;
1114  break;
1115  }
1116  sleep_rate.sleep();
1117  }
1118 
1119  if(!ret)
1120  {
1121  int err_warn[2] = {0};
1122  arm_cmd_->get_err_code(err_warn);
1123  if(err_warn[0])
1124  {
1125  ROS_ERROR("XARM ERROR CODE: %d ", err_warn[0]);
1126  ret = UXBUS_STATE::ERR_CODE;
1127  }
1128  }
1129 
1130  return ret;
1131  }
1132 
1133 }
static const int MOVING
ros::ServiceServer get_digital_in_server_
Definition: xarm_driver.h:147
int gripper_modbus_set_pos(float pulse)
Definition: uxbus_cmd.cc:828
bool MotionCtrlCB(xarm_msgs::SetAxis::Request &req, xarm_msgs::SetAxis::Response &res)
int set_joint_maxacc(float maxacc)
Definition: uxbus_cmd.cc:484
static const int TEACH_JOINT
ros::ServiceServer move_servo_cart_server_
Definition: xarm_driver.h:141
bool GetControllerDInCB(xarm_msgs::GetControllerDigitalIO::Request &req, xarm_msgs::GetControllerDigitalIO::Response &res)
bool MoveLineAACB(xarm_msgs::MoveAxisAngle::Request &req, xarm_msgs::MoveAxisAngle::Response &res)
bool GoHomeCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
int get_err_code(int *rx_data)
Definition: uxbus_cmd.cc:319
bool GetDigitalIOCB(xarm_msgs::GetDigitalIO::Request &req, xarm_msgs::GetDigitalIO::Response &res)
bool SetMaxJAccCB(xarm_msgs::SetFloat32::Request &req, xarm_msgs::SetFloat32::Response &res)
int gripper_modbus_clean_err(void)
Definition: uxbus_cmd.cc:855
void closeReportSocket(void)
Definition: xarm_driver.cpp:33
ros::ServiceServer set_controller_aout_server_
Definition: xarm_driver.h:160
int save_conf(void)
Definition: uxbus_cmd.cc:514
int tgpio_get_analog1(float *value)
Definition: uxbus_cmd.cc:720
int cgpio_get_analog2(float *value)
Definition: uxbus_cmd.cc:942
int move_jointb(float mvjoint[7], float mvvelo, float mvacc, float mvradii)
Definition: uxbus_cmd.cc:386
void publish(const boost::shared_ptr< M > &message) const
int clean_war(void)
Definition: uxbus_cmd.cc:337
bool SetModbusCB(xarm_msgs::SetToolModbus::Request &req, xarm_msgs::SetToolModbus::Response &res)
ros::ServiceServer gripper_config_server_
Definition: xarm_driver.h:152
ros::ServiceServer set_controller_dout_server_
Definition: xarm_driver.h:158
ros::ServiceServer move_joint_server_
Definition: xarm_driver.h:132
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::ServiceServer set_max_lacc_server_
Definition: xarm_driver.h:171
ros::AsyncSpinner spinner
Definition: xarm_driver.h:121
int move_lineb(float mvpose[6], float mvvelo, float mvacc, float mvtime, float mvradii)
Definition: uxbus_cmd.cc:364
int set_tcp_maxacc(float maxacc)
Definition: uxbus_cmd.cc:474
bool MoveJointCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
static const int POSE
bool SetTCPOffsetCB(xarm_msgs::TCPOffset::Request &req, xarm_msgs::TCPOffset::Response &res)
int set_mode(int value)
Definition: uxbus_cmd.cc:347
SocketPort * arm_report_
Definition: xarm_driver.h:111
static const int STOP
bool sleep() const
bool GripperStateCB(xarm_msgs::GripperState::Request &req, xarm_msgs::GripperState::Response &res)
int servo_get_dbmsg(int rx_data[16])
Definition: uxbus_cmd.cc:866
bool MoveLineCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
bool VacuumGripperCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
int load_traj(char filename[81])
Definition: uxbus_cmd.cc:229
xarm_msgs::IOState io_msg
Definition: xarm_driver.h:128
int vc_set_linev(float line_v[6], int coord)
Definition: uxbus_cmd.cc:1189
int read_frame(unsigned char *data)
Definition: socket.cc:122
ros::ServiceServer gripper_state_server_
Definition: xarm_driver.h:154
void XARMDriverInit(ros::NodeHandle &root_nh, char *server_ip)
Definition: xarm_driver.cpp:44
bool ClearErrCB(xarm_msgs::ClearErr::Request &req, xarm_msgs::ClearErr::Response &res)
int get_frame(unsigned char *data)
int tgpio_get_digital(int *io1, int *io2)
Definition: uxbus_cmd.cc:695
bool GetErrCB(xarm_msgs::GetErr::Request &req, xarm_msgs::GetErr::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
SocketPort * connect_tcp_report(char *server_ip, std::string report_type="normal")
Definition: connect.cc:70
int save_traj(char filename[81])
Definition: uxbus_cmd.cc:225
bool SaveTrajCB(xarm_msgs::SetString::Request &req, xarm_msgs::SetString::Response &res)
ros::ServiceServer traj_save_server_
Definition: xarm_driver.h:174
#define ROS_WARN(...)
ros::ServiceServer vc_set_linev_server_
Definition: xarm_driver.h:169
void pub_joint_state(sensor_msgs::JointState &js_msg)
bool SetStateCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
int move_servo_cartesian(float mvpose[6], float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:421
ros::NodeHandle nh_
Definition: xarm_driver.h:130
ros::ServiceServer config_modbus_server_
Definition: xarm_driver.h:157
std::shared_ptr< std::mutex > mutex_
Definition: xarm_driver.h:127
ros::ServiceServer set_max_jacc_server_
Definition: xarm_driver.h:170
static const int VELO_CART
int playback_traj(int times, int spdx=1)
Definition: uxbus_cmd.cc:215
static const int PAUSE
ros::ServiceServer motion_ctrl_server_
Definition: xarm_driver.h:134
int get_traj_rw_status(int *rx_data)
Definition: uxbus_cmd.cc:233
bool VeloMoveJointCB(xarm_msgs::MoveVelo::Request &req, xarm_msgs::MoveVelo::Response &res)
bool GripperConfigCB(xarm_msgs::GripperConfig::Request &req, xarm_msgs::GripperConfig::Response &res)
int move_line_aa(float mvpose[6], float mvvelo, float mvacc, float mvtime, int mvcoord=0, int relative=0)
Definition: uxbus_cmd.cc:1059
ros::ServiceServer set_vacuum_gripper_server_
Definition: xarm_driver.h:155
void close_port(void)
Definition: socket.cc:136
int move_gohome(float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:404
int gripper_modbus_set_en(int value)
Definition: uxbus_cmd.cc:800
bool MoveitClearErrCB(xarm_msgs::ClearErr::Request &req, xarm_msgs::ClearErr::Response &res)
int tgpio_set_modbus(unsigned char *send_data, int length, unsigned char *recv_data)
Definition: uxbus_cmd.cc:760
int set_modbus_timeout(int value)
Definition: uxbus_cmd.cc:739
ros::Publisher joint_state_
Definition: xarm_driver.h:177
ros::ServiceServer vc_set_jointv_server_
Definition: xarm_driver.h:168
bool GetAnalogIOCB(xarm_msgs::GetAnalogIO::Request &req, xarm_msgs::GetAnalogIO::Response &res)
bool GripperMoveCB(xarm_msgs::GripperMove::Request &req, xarm_msgs::GripperMove::Response &res)
ros::ServiceServer get_analog_in_server_
Definition: xarm_driver.h:148
int gripper_modbus_get_errcode(int *err)
Definition: uxbus_cmd.cc:847
#define CMD_HEARTBEAT_SEC
Definition: xarm_driver.cpp:9
#define ROS_INFO(...)
ros::ServiceServer traj_play_server_
Definition: xarm_driver.h:175
int is_ok(void)
Definition: socket.cc:118
int cgpio_set_auxdigit(int ionum, int value)
Definition: uxbus_cmd.cc:948
void pub_cgpio_state(xarm_msgs::CIOState &cio_msg)
int gripper_modbus_set_posspd(float speed)
Definition: uxbus_cmd.cc:839
int set_tcp_offset(float pose_offset[6])
Definition: uxbus_cmd.cc:489
ros::ServiceServer set_mode_server_
Definition: xarm_driver.h:136
static enum xarm_api::rw_status rw_status_now
int set_modbus_baudrate(int baud)
Definition: uxbus_cmd.cc:743
ros::ServiceServer move_line_tool_server_
Definition: xarm_driver.h:139
int gripper_modbus_set_mode(int value)
Definition: uxbus_cmd.cc:808
ros::Publisher end_input_state_
Definition: xarm_driver.h:179
bool SetControllerDOutCB(xarm_msgs::SetDigitalIO::Request &req, xarm_msgs::SetDigitalIO::Response &res)
void * cmd_heart_beat(void *args)
Definition: xarm_driver.cpp:11
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::ServiceServer move_line_aa_server_
Definition: xarm_driver.h:142
bool SetMaxLAccCB(xarm_msgs::SetFloat32::Request &req, xarm_msgs::SetFloat32::Response &res)
std::string report_type_
Definition: xarm_driver.h:120
ros::ServiceServer go_home_server_
Definition: xarm_driver.h:131
ros::ServiceServer move_line_server_
Definition: xarm_driver.h:138
int tgpio_get_analog2(float *value)
Definition: uxbus_cmd.cc:727
virtual void close(void)
Definition: uxbus_cmd.cc:36
ros::ServiceServer set_state_server_
Definition: xarm_driver.h:135
UxbusCmd * get_uxbus_cmd(void)
Definition: xarm_driver.h:111
int set_state(int value)
Definition: uxbus_cmd.cc:307
bool SetModeCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
int cgpio_get_auxdigit(int *value)
Definition: uxbus_cmd.cc:933
int move_line_tool(float mvpose[6], float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:395
int sleep_instruction(float sltime)
Definition: uxbus_cmd.cc:449
bool sleep()
int clean_err(void)
Definition: uxbus_cmd.cc:332
int move_line(float mvpose[6], float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:355
ros::ServiceServer get_controller_din_server_
Definition: xarm_driver.h:159
ros::ServiceServer move_lineb_server_
Definition: xarm_driver.h:137
ros::ServiceServer set_tcp_offset_server_
Definition: xarm_driver.h:144
ros::ServiceServer move_servoj_server_
Definition: xarm_driver.h:140
ros::ServiceServer move_jointb_server_
Definition: xarm_driver.h:133
static const int ERR_CODE
static const int VELO_JOINT
bool isConnectionOK(void)
ros::ServiceServer moveit_clear_err_server_
Definition: xarm_driver.h:150
int get_cmdnum(int *rx_data)
Definition: uxbus_cmd.cc:315
bool VeloMoveLineVCB(xarm_msgs::MoveVelo::Request &req, xarm_msgs::MoveVelo::Response &res)
bool SetRecordingCB(xarm_msgs::SetInt16::Request &req, xarm_msgs::SetInt16::Response &res)
ros::ServiceServer gripper_move_server_
Definition: xarm_driver.h:153
ros::ServiceServer move_servo_cart_aa_server_
Definition: xarm_driver.h:143
static const int START
bool SetLoadCB(xarm_msgs::SetLoad::Request &req, xarm_msgs::SetLoad::Response &res)
bool getParam(const std::string &key, std::string &s) const
bool MoveLinebCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
ros::ServiceServer get_controller_ain_server_
Definition: xarm_driver.h:161
static const int SERVO
int set_record_traj(int value)
Definition: uxbus_cmd.cc:210
int move_servoj(float mvjoint[7], float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:412
ros::Publisher robot_rt_state_
Definition: xarm_driver.h:178
ros::ServiceServer clear_err_server_
Definition: xarm_driver.h:149
void pub_robot_msg(xarm_msgs::RobotMsg &rm_msg)
ros::Publisher cgpio_state_
Definition: xarm_driver.h:180
bool MoveServoCartAACB(xarm_msgs::MoveAxisAngle::Request &req, xarm_msgs::MoveAxisAngle::Response &res)
int gripper_modbus_get_pos(float *pulse)
Definition: uxbus_cmd.cc:820
static const int TEACH_CART
int move_joint(float mvjoint[7], float mvvelo, float mvacc, float mvtime)
Definition: uxbus_cmd.cc:376
bool SetControllerAOutCB(xarm_msgs::SetControllerAnalogIO::Request &req, xarm_msgs::SetControllerAnalogIO::Response &res)
void SleepTopicCB(const std_msgs::Float32ConstPtr &msg)
bool GetControllerAInCB(xarm_msgs::GetAnalogIO::Request &req, xarm_msgs::GetAnalogIO::Response &res)
bool LoadNPlayTrajCB(xarm_msgs::PlayTraj::Request &req, xarm_msgs::PlayTraj::Response &res)
ros::Subscriber sleep_sub_
Definition: xarm_driver.h:182
int vc_set_jointv(float jnt_v[7], int jnt_sync)
Definition: uxbus_cmd.cc:1182
int set_tcp_load(float mass, float load_offset[3])
Definition: uxbus_cmd.cc:493
int move_servo_cart_aa(float mvpose[6], float mvvelo, float mvacc, int tool_coord=0, int relative=0)
Definition: uxbus_cmd.cc:1069
bool MoveJointbCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
bool MoveServoCartCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
ros::ServiceServer set_modbus_server_
Definition: xarm_driver.h:156
ros::ServiceServer set_load_server_
Definition: xarm_driver.h:145
ros::ServiceServer set_end_io_server_
Definition: xarm_driver.h:146
#define ROS_ERROR(...)
int motion_en(int id, int value)
Definition: uxbus_cmd.cc:302
int cgpio_set_analog2(float value)
Definition: uxbus_cmd.cc:974
bool MoveLineToolCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
UxbusCmdTcp * connect_tcp_control(char *server_ip)
Definition: connect.cc:25
int cgpio_get_analog1(float *value)
Definition: uxbus_cmd.cc:936
virtual int is_ok(void)
Definition: uxbus_cmd.cc:38
bool MoveServoJCB(xarm_msgs::Move::Request &req, xarm_msgs::Move::Response &res)
ros::ServiceServer get_err_server_
Definition: xarm_driver.h:151
ros::ServiceServer traj_record_server_
Definition: xarm_driver.h:173
bool SetDigitalIOCB(xarm_msgs::SetDigitalIO::Request &req, xarm_msgs::SetDigitalIO::Response &res)
static const int MODE_CHANGE
bool ConfigModbusCB(xarm_msgs::ConfigToolModbus::Request &req, xarm_msgs::ConfigToolModbus::Response &res)
bool reConnectReportSocket(char *server_ip)
Definition: xarm_driver.cpp:38
int cgpio_set_analog1(float value)
Definition: uxbus_cmd.cc:969
int tgpio_set_digital(int ionum, int value)
Definition: uxbus_cmd.cc:704


xarm_api
Author(s):
autogenerated on Sat May 8 2021 02:51:23