denso_robot.h
Go to the documentation of this file.
1 #include <execinfo.h>
2 #include <signal.h>
3 #include <sys/mman.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <sys/socket.h>
7 #include <unistd.h>
8 #include <fcntl.h>
9 #include "b-Cap.h"
10 #define DEFAULT_SERVER_IP_ADDRESS "133.11.216.196" /* Your controller IP address */
11 #define DEFAULT_SERVER_PORT_NUM 5007
12 #define DEFAULT_UDP_TIMEOUT (10 * 1000)
13 #define CLOCK_PRIO 0
14 #define CONTROL_PRIO 0
15 #include <boost/thread.hpp>
16 
17 template <typename T>
18 std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
19  if ( !v.empty() ) {
20  out << '[';
21  std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
22  out << "\b\b]";
23  }
24  return out;
25 }
26 
28 {
29 public:
30  DensoRobot(): dryrunp_(false)
31  {
32  jntvalues_.resize(8);
33  }
34 
35  virtual ~DensoRobot(){
36  finalizeHW();
37  }
38 
39 public:
41  {
44  return hr;
45  }
46 
48  {
50  hr = bCap_Close(iSockFD_);
51  return hr;
52  }
53 
55  {
57  hr = bCap_ControllerConnect(iSockFD_, (char*)"", (char*)"caoProv.DENSO.VRC",
58  (char*)(server_ip_address_.c_str()), (char*)"", &lhController_);
59  return hr;
60  }
61 
63  {
66  return hr;
67  }
68 
70  {
72  long lResult = 0;
73  hr = bCap_ControllerExecute(iSockFD_, lhController_, (char*)"ClearError", (char*)"", &lResult);
74  ROS_INFO("clearError %02x %02x", hr, lResult);
75  return hr;
76  }
77 
79  {
81  hr = bCap_ControllerGetRobot(iSockFD_, lhController_, (char*)"", (char*)"", &lhRobot_); /* Get robot handle */
82  ROS_INFO("GetRobot %02x %02x", hr, lhRobot_);
83  return hr;
84  }
86  {
88  hr = bCap_RobotRelease(iSockFD_, lhRobot_); /* Release robot handle */
89  return hr;
90  }
91 
92  BCAP_HRESULT bCapRobotExecute(char* command, char* arg)
93  {
95  long lResult;
96  hr = bCap_RobotExecute(iSockFD_, lhRobot_, command, arg, &lResult);
97  return hr;
98  }
99 
101  {
102  BCAP_VARIANT takearmparam, takearmresult;
103  takearmparam.Type = VT_I4 | VT_ARRAY;
104  takearmparam.Arrays = 2;
105  ((u_int*)(&takearmparam.Value.LongValue))[0] = 0;
106  ((u_int*)(&takearmparam.Value.LongValue))[1] = 1;
107  BCAP_HRESULT hr;
108  //hr = bCap_RobotExecute(iSockFD_, lhRobot_, "Takearm", takearmparam, &takearmresult);
109  hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "Takearm", &takearmparam, &takearmresult);
110  //BCAP_HRESULT hr = bCapRobotExecute("Takearm", "");
111  return hr;
112  }
113 
115  {
116  BCAP_VARIANT lResult;
117  BCAP_HRESULT hr;
118  hr = bCap_RobotExecute(iSockFD_, lhRobot_, (char*)"Givearm", (char*)"", &lResult);
119  return hr;
120  }
121 
123  {
124  BCAP_HRESULT hr;
125  BCAP_VARIANT extspeedparam, extspeedresult;
126  extspeedparam.Type = VT_R4 | VT_ARRAY;
127  extspeedparam.Arrays = 1;
128  extspeedparam.Value.FloatValue = arg;
129  //((u_int*)(&extspeedparam.Value.LongValue))[1] = 0;
130  //((u_int*)(&extspeedparam.Value.LongValue))[2] = 0;
131  //hr = bCap_RobotExecute(iSockFD_, lhRobot_, "ExtSpeed", (char*)"80.0", &lResult);
132  hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "ExtSpeed", &extspeedparam, &extspeedresult);
133 
134  //BCAP_HRESULT hr = bCapRobotExecute("ExtSpeed", arg);
135  return hr;
136  }
137 
139  {
140  var_handlers_.insert(std::map<std::string, u_int>::value_type("MODE",bCapControllerGetVariable("@MODE")));
141  var_handlers_.insert(std::map<std::string, u_int>::value_type("ERROR_CODE",bCapControllerGetVariable("@ERROR_CODE")));
142  var_handlers_.insert(std::map<std::string, u_int>::value_type("ERROR_DESCRIPTION",bCapControllerGetVariable("@ERROR_DESCRIPTION")));
143  var_handlers_.insert(std::map<std::string, u_int>::value_type("VERSION",bCapControllerGetVariable("@VERSION")));
144  var_handlers_.insert(std::map<std::string, u_int>::value_type("SPEED",bCapRobotGetVariable("@SPEED")));
145  var_handlers_.insert(std::map<std::string, u_int>::value_type("ACCEL",bCapRobotGetVariable("@ACCEL")));
146  var_handlers_.insert(std::map<std::string, u_int>::value_type("DECEL",bCapRobotGetVariable("@DECEL")));
147  var_handlers_.insert(std::map<std::string, u_int>::value_type("JSPEED",bCapRobotGetVariable("@JSPEED")));
148  var_handlers_.insert(std::map<std::string, u_int>::value_type("JACCEL",bCapRobotGetVariable("@JACCEL")));
149  var_handlers_.insert(std::map<std::string, u_int>::value_type("JDECEL",bCapRobotGetVariable("@JDECEL")));
150  var_handlers_.insert(std::map<std::string, u_int>::value_type("EXTSPEED",bCapRobotGetVariable("@EXTSPEED")));
151  var_handlers_.insert(std::map<std::string, u_int>::value_type("EXTACCEL",bCapRobotGetVariable("@EXTACCEL")));
152  var_handlers_.insert(std::map<std::string, u_int>::value_type("EXTDECEL",bCapRobotGetVariable("@EXTDECEL")));
153  var_handlers_.insert(std::map<std::string, u_int>::value_type("SERVO_ON",bCapRobotGetVariable("@SERVO_ON")));
154  var_handlers_.insert(std::map<std::string, u_int>::value_type("BUSY_STATUS",bCapControllerGetVariable("@BUSY_STATUS")));
155  var_handlers_.insert(std::map<std::string, u_int>::value_type("CURRENT_TIME",bCapControllerGetVariable("@CURRENT_TIME")));
156  var_handlers_.insert(std::map<std::string, u_int>::value_type("LOCK",bCapControllerGetVariable("@LOCK")));
157  var_handlers_.insert(std::map<std::string, u_int>::value_type("EMERGENCY_STOP",bCapControllerGetVariable("@EMERGENCY_STOP")));
158 
159  var_types_.insert(std::map<std::string, u_short>::value_type("ERROR_CODE", VT_I4));
160  var_types_.insert(std::map<std::string, u_short>::value_type("MODE", VT_I4));
161  var_types_.insert(std::map<std::string, u_short>::value_type("ERROR_DESCRIPTION", VT_BSTR));
162  var_types_.insert(std::map<std::string, u_short>::value_type("VERSION", VT_BSTR));
163  var_types_.insert(std::map<std::string, u_short>::value_type("SPEED", VT_R4));
164  var_types_.insert(std::map<std::string, u_short>::value_type("ACCEL", VT_R4));
165  var_types_.insert(std::map<std::string, u_short>::value_type("DECEL", VT_R4));
166  var_types_.insert(std::map<std::string, u_short>::value_type("JSPEED", VT_R4));
167  var_types_.insert(std::map<std::string, u_short>::value_type("JACCEL", VT_R4));
168  var_types_.insert(std::map<std::string, u_short>::value_type("JDECEL", VT_R4));
169  var_types_.insert(std::map<std::string, u_short>::value_type("EXTSPEED", VT_R4));
170  var_types_.insert(std::map<std::string, u_short>::value_type("EXTACCEL", VT_R4));
171  var_types_.insert(std::map<std::string, u_short>::value_type("EXTDECEL", VT_R4));
172  var_types_.insert(std::map<std::string, u_short>::value_type("BUSY_STATUS", VT_BOOL));
173  var_types_.insert(std::map<std::string, u_short>::value_type("CURRENT_TIME", VT_DATE));
174  var_types_.insert(std::map<std::string, u_short>::value_type("LOCK", VT_BOOL));
175  var_types_.insert(std::map<std::string, u_short>::value_type("EMERGENCY_STOP", VT_BOOL));
176  }
177 
178  u_int bCapControllerGetVariable(const std::string& varname)
179  {
180  BCAP_HRESULT hr = BCAP_S_OK;
181  u_int varresult;
182  hr = bCap_ControllerGetVariable(iSockFD_, lhController_, (char*)(varname.c_str()), (char*)"", &varresult);
183  if(FAILED(hr)) {
184  ROS_WARN("failed to controller get variable '%s' hr:%02x result:%02x", varname.c_str(), hr, varresult);
185  }
186  return varresult;
187  }
188 
189  u_int bCapRobotGetVariable(const std::string& varname)
190  {
191  BCAP_HRESULT hr = BCAP_S_OK;
192  u_int varresult;
193  hr = bCap_RobotGetVariable(iSockFD_, lhRobot_, (char*)(varname.c_str()), (char*)"", &varresult);
194  if(FAILED(hr)) {
195  ROS_WARN("failed to controller get variable '%s' hr:%02x result:%02x", varname.c_str(), hr, varresult);
196  }
197  return varresult;
198  }
199 
200  bool bCapGetBoolVariable(const std::string& var_name)
201  {
202  bool var = 0;
203  if( var_types_.find(var_name.c_str()) != var_types_.end() ) {
204  BCAP_HRESULT hr = bCap_VariableGetValue(iSockFD_, var_handlers_[var_name.c_str()], &var);
205  if( FAILED(hr) ) {
206  ROS_WARN("Failed to get %s, return 0 instead.", var_name.c_str());
207  return 0;
208  }
209  return var;
210  }
211  ROS_WARN("No handler for %s, return 0 instead.", var_name.c_str());
212  return 0;
213  }
214 
215  u_int bCapGetIntegerVariable(const std::string& var_name)
216  {
217  u_int var = 0;
218  if( var_types_.find(var_name.c_str()) != var_types_.end() ) {
219  BCAP_HRESULT hr = bCap_VariableGetValue(iSockFD_, var_handlers_[var_name.c_str()], &var);
220  if( FAILED(hr) ) {
221  ROS_WARN("Failed to get %s, return 0 instead.", var_name.c_str());
222  return 0;
223  }
224  return var;
225  }
226  ROS_WARN("No handler for %s, return 0 instead.", var_name.c_str());
227  return 0;
228  }
229 
232  {
233  //u_int errorcode = 0; // this local variable is not allocated in debug mode...? why...
234  __errorcode__ = 0;
235  if( var_types_.find("ERROR_CODE") != var_types_.end() ) {
236  BCAP_HRESULT hr = bCap_VariableGetValue(iSockFD_, var_handlers_["ERROR_CODE"], &__errorcode__);
237  if( FAILED(hr) ) {
238  ROS_WARN("Failed to get ERROR_CODE, return %02x instead.", hr);
239  return hr;
240  }
241  return __errorcode__;
242  }
243  ROS_WARN("ERROR_CODE is not in variable handlers");
244  return 0;
245  }
246 
247  // 1: manual, 2: teachcheck, 3:auto
249  {
250  return bCapGetIntegerVariable("MODE");
251  }
252 
254  {
255  return bCapGetBoolVariable("EMERGENCY_STOP");
256  }
257 
258  u_int bCapErrorDescription(std::string& errormsg)
259  {
260  if( var_types_.find("ERROR_DESCRIPTION") != var_types_.end() ) {
262  errormsg = errdesc_buffer_; //copy
263 
264  // find null
265  size_t strlen = 0;
266  while(strlen<2000) {
267  if( *((uint16_t*)errdesc_buffer_+strlen) == 0 ) {
268  break;
269  }
270  ++strlen;
271  }
272 
273  ROS_INFO("raw error description: %s", errdesc_buffer_);
274  //try {
275  // utf8::utf16to8((uint16_t*)errdesc_buffer_, (uint16_t*)errdesc_buffer_+strlen, std::back_inserter(errormsg));
276  //} catch (utf8::invalid_utf16& e) {
277  //}
278  errormsg = errdesc_buffer_; //copy
279  return hr;
280  }
281  ROS_WARN("ERROR_DESCRIPTION is not in variable handlers");
282  return 0;
283  }
284 
285 
286  BCAP_HRESULT bCapMotor(bool command)
287  {
288  BCAP_HRESULT hr = BCAP_S_OK;
289  BCAP_VARIANT motorarmparam, motorarmresult;
290  motorarmparam.Type = VT_I4 | VT_ARRAY;
291  motorarmparam.Arrays = 2;
292  if (command)
293  {
294  //hr = bCapRobotExecute("Motor", "1");
295  ((u_int*)(&motorarmparam.Value.LongValue))[0] = 1;
296  ((u_int*)(&motorarmparam.Value.LongValue))[1] = 0;
297 
298  hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "Motor", &motorarmparam, &motorarmresult);
299  }
300  else
301  {
302  //hr = bCapRobotExecute("Motor", "0");
303  ((u_int*)(&motorarmparam.Value.LongValue))[0] = 0;
304  ((u_int*)(&motorarmparam.Value.LongValue))[1] = 1;
305 
306  hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "Motor", &motorarmparam, &motorarmresult);
307  }
308  return hr;
309  }
310 
311  BCAP_HRESULT bCapCurJnt(std::vector<double>& jointvalues)
312  {
314  //TODO: armgroup defines the size of jntvalues_
315  // we should set it collectly (using wincaps?) and use it when you send TakeArm command
316  hr = bCap_RobotExecute(iSockFD_, lhRobot_, "CurJnt", "", &jntvalues_[0]);
317  for (int i = 0; i < num_joints_; i++) {
318  jointvalues[i] = jntvalues_[i];
319  }
320  ROS_DEBUG_STREAM("curjoints: " << jointvalues);
321  return hr;
322  }
323 
325  {
326  //long lResult;
327  //BCAP_HRESULT hr = bCap_RobotExecute(iSockFD_, lhRobot_, "slvChangeMode", arg, &lResult);
328  BCAP_HRESULT hr;
329  BCAP_VARIANT slvchangeparam, slvchangeresult;
330  slvchangeparam.Type = VT_I4;
331  slvchangeparam.Arrays = 1;
332  slvchangeparam.Value.LongValue = arg;
333  hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "slvChangeMode", &slvchangeparam, &slvchangeresult);
334  //ROS_INFO("change slave mode: hr: %02x, result: %02x", hr, slvchangeresult);
335  return hr;
336  }
337 
339  {
340  // struct timeval tv;
341  // tv.tv_sec = 0;
342  // tv.tv_usec = 1000 * 1;
343  // setsockopt(iSockFD_, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
344  extern int failed_to_send_packet;
345  struct timespec tick, before;
346 
347  clock_gettime(CLOCK_MONOTONIC, &tick);
348  BCAP_HRESULT hr = bCap_RobotExecute2(iSockFD_, lhRobot_, (char*)"slvMove", pose, result);
349 
350  if (FAILED(hr)) {
351  ROS_WARN("failed to slvmove, errorcode: %02x", hr);
352  }
353 
354  clock_gettime(CLOCK_MONOTONIC, &before);
355  static const int NSEC_PER_SECOND = 1e+9;
356  //static const int USEC_PER_SECOND = 1e6;
357  double roundtrip = (before.tv_sec + double(before.tv_nsec) / NSEC_PER_SECOND)
358  - (tick.tv_sec + double(tick.tv_nsec) / NSEC_PER_SECOND);
359 
360  prev_time_ = tick;
361 
362  if (failed_to_send_packet)
363  {
364  ROS_WARN(" roundtrip: %f", roundtrip);
365  setUDPTimeout((udp_timeout_ / 1000), (udp_timeout_ % 1000) * 1000);
366  }
367 
368  return hr;
369  }
370 
372  {
373  ROS_INFO("try to fill buffer");
374  BCAP_HRESULT hr;
375  std::vector<double> cur_jnt;
376  cur_jnt.resize(num_joints_);
377  for (int i = 0; i < 3; i++) {
378  // sometimes robot returns [0,0,0...]
379  hr = bCapCurJnt(cur_jnt);
380  }
381  BCAP_VARIANT vntPose, vntResult;
382  vntPose.Type = VT_R8 | VT_ARRAY;
383  vntPose.Arrays = 8;
384  for (int i = 0; i < num_joints_; i++)
385  {
386  vntPose.Value.DoubleArray[i] = cur_jnt[i];
387  }
388  for (int i = num_joints_; i < 8; i++) {
389  vntPose.Value.DoubleArray[i] = 0;
390  }
391  // Fill the buffer for later use,
392  // unless fill the buffer, bCap slave will fall down
393  for (int i = 0; i < 4; i++) {
394  hr = bCapRobotSlvMove(&vntPose, &vntResult);
395  if (FAILED(hr)) {
396  return hr;
397  }
398  }
399  }
400 
401 // BCAP_HRESULT bCapReflectRealState() {
402 // // fill ac
403 // std::vector<double> cur_jnt;
404 // BCAP_HRESULT hr;
405 // hr = bCapCurJnt(cur_jnt);
406 // int i = 0;
407 // for (OpenControllersInterface::TransmissionIterator it = cm_->model_.transmissions_.begin();
408 // it != cm_->model_.transmissions_.end(); ++it)
409 // { // *** js and ac must be consistent
410 // pr2_hardware_interface::Actuator *ac = hw_->getActuator((*it)->actuator_names_[0]);
411 // bool is_prismatic = (*it)->actuator_names_[0].find("prismatic") != std::string::npos;
412 // if (is_prismatic) {
413 // ac->state_.position_ = cur_jnt[i] / 1000;
414 // } else {
415 // ac->state_.position_ = DEG2RAD(cur_jnt[i]); // degree -> radian
416 // }
417 // i++;
418 // }
419 // return hr;
420 // }
421 
422  virtual void finalizeHW()
423  {
424  if (!dryrunp_)
425  {
426  setUDPTimeout(2, 0);
427  boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
428  long lResult;
429  BCAP_HRESULT hr = BCAP_S_OK;
430  //bCapClearError();
431 
432  hr = bCapSlvChangeMode(0);
433  if (FAILED(hr))
434  {
435  ROS_WARN("failed to change slave mode");
436  }
437 
438  // disable logging mode
439  // hr = bCapRobotExecute("stopLog", "");
440  // if (FAILED(hr))
441  // {
442  // ROS_WARN(failed to disable logging mode");
443  // }
444 
445  hr = bCapMotor(false);
446  if (FAILED(hr))
447  {
448  ROS_WARN("failed to motor off");
449  }
450  else
451  {
452  ROS_INFO("successed to motor off");
453  }
454  hr = bCapGiveArm();
455  if (FAILED(hr))
456  {
457  ROS_WARN("failed to give arm");
458  }
459  else
460  {
461  ROS_INFO("successed to give arm");
462  }
463  hr = bCapReleaseRobot();
464  if (FAILED(hr))
465  {
466  ROS_WARN("failed to release the robot");
467  }
468  else
469  {
470  ROS_INFO( "successed to release the robot");
471  }
473  if (FAILED(hr))
474  {
475  ROS_WARN("failed to disconnect from the controller");
476  }
477  else
478  {
479  ROS_INFO("successed to disconnect from the controller");
480  }
481  /* Stop b-CAP service (Very important in UDP/IP connection) */
482  hr = bCapServerStop();
483  if (FAILED(hr))
484  {
485  ROS_WARN("failed to stop the service");
486  }
487  else
488  {
489  ROS_INFO("successed to stop the service");
490  }
491  boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
492  hr = bCapClose();
493  if (FAILED(hr))
494  {
495  ROS_WARN("failed to close bCap");
496  }
497  else
498  {
499  ROS_INFO("successed to close bCap");
500  }
501  }
502  ROS_INFO("finalizing finished");
503  }
504 
505  bool read(std::vector<double>& pos) {
506  if (dryrunp_)
507  {
508  for (int i = 0; i < num_joints_; i++) {
509  pos[i] = jntvalues_[i];
510  }
511  return true;
512  }
513  // fill ac
514  BCAP_HRESULT hr;
515  hr = bCapCurJnt(pos);
516  if (FAILED(hr)) {
517  return false;
518  }
519  return true;
520  }
521  bool write(const std::vector<double>& cmd, std::vector<double>& pos)
522  {
523  if (dryrunp_)
524  {
525  for (int i = 0; i < num_joints_; i++) {
526  pos[i] = cmd[i];
527  jntvalues_[i] = cmd[i];
528  }
529  return true;
530  }
531  // build vntPose
532  BCAP_VARIANT vntPose;
533  vntPose.Type = VT_R8 | VT_ARRAY;
534  vntPose.Arrays = 8;
535  std::memset(vntPose.Value.DoubleArray, 0, sizeof(double)*16);
536  for (int i = 0; i < cmd.size(); i++) {
537  vntPose.Value.DoubleArray[i] = cmd[i];
538  }
539 
540  bool status;
541  BCAP_VARIANT vntReturn;
542  // check bcap status beforehand
543  // u_int errorcode;
544  // errorcode = bCapGetErrorCode();
545  // if (FAILED(errorcode)) {
546  // ROS_WARN("bad status! robot needs recovery! hr: %02x", errorcode);
547  // //status.reset(new DensoRobotStatus(errorcode));
548  // status = false;
549  // }
550  BCAP_HRESULT hr = bCapRobotSlvMove(&vntPose, &vntReturn);
551  ROS_DEBUG("slvmove hr: %02x", hr);
552  if (hr == 0xF200501)
553  {
554  ROS_DEBUG("buf is filled, it's fine.");
555  status = true;
556  }
557  else if (FAILED(hr))
558  {
559  if (hr == 0x83500121)
560  {
561  ROS_INFO("robot is not in slavemode, try to change it");
562  BCAP_HRESULT hr;
563  hr = bCapClearError();
564  if (FAILED(hr)) {
565  ROS_WARN("failed to clear error, cannot recover");
566  return false;
567  }
568  hr = bCapRobotExecute("clearLog", "");
569  if (FAILED(hr)) {
570  ROS_WARN("failed to clear log");
571  return false;
572  }
573  hr = bCapSlvChangeMode(0x102);
574  if (FAILED(hr)) {
575  ROS_WARN("failed to change slvmode, cannot recover");
576  return false;
577  }
578  hr = bCapFillBuffer();
579  if (FAILED(hr)) {
580  ROS_WARN("failed to fill buffer in slave mode");
581  return false;
582  }
583  hr = bCapCurJnt(pos);
584  if (FAILED(hr)) {
585  ROS_WARN("failed to read cur jnt");
586  return false;
587  }
588  }
589  return true;
590  } else {
591  for (int i = 0; i < pos.size(); i++) {
592  pos[i] = vntReturn.Value.DoubleArray[i];
593  }
594  return true;
595  }
596  }
597 
598 // #define CAST_STATUS(hr) \
599 // boost::static_pointer_cast<OpenControllersInterface::ControllerStatus>(DensoRobotStatusPtr(new DensoRobotStatus(hr)))
600 //
601 // bool recoverController()
602 // {
603 // ROS_WARN("try to recover controller...");
604 // u_int errorcode;
605 // std::string errormsg;
606 //
607 // errorcode = bCapGetErrorCode();
608 // bCapErrorDescription(errormsg);
609 //
610 // ROS_INFO("errormsg: %s", errormsg.c_str());
611 //
612 // if (errorcode == BCAP_E_UNEXPECTED)
613 // {
614 // ROS_FATAL("Unexpected Error occured. no way to recover!");
615 // return CAST_STATUS(errorcode);
616 // }
617 //
618 // if (errorcode >= 0x83204071 && errorcode <= 0x83204078)
619 // {
620 // ROS_INFO("joint angle is over the software limit.");
621 // ROS_INFO("currently, there is no way to recover, quit.");
622 // // TODO publish message and return healthy status so that an application can send recovery-trajectory.
623 // return CAST_STATUS(BCAP_E_FAIL);
624 // }
625 // if (errorcode >= 0x84204081 && errorcode <= 0x842040A8)
626 // {
627 // ROS_INFO("joint angle velocity is over the software limit.");
628 // ROS_INFO("currently, there is no way to recover, quit.");
629 // // TODO publish message and return healthy status so that an application can send recovery-trajectory.
630 // return CAST_STATUS(BCAP_E_FAIL);
631 // }
632 // if (errorcode >= 0x84204051 && errorcode <= 0x84204058)
633 // {
634 // ROS_INFO("joint angle velocity(sent) is over the software limit.");
635 // //ROS_INFO("currently, there is no way to recover, quit.");
636 // //return CAST_STATUS(BCAP_E_FAIL);
637 // // TODO publish message and return healthy status so that an application can send recovery-trajectory.
638 // BCAP_HRESULT hr;
639 // hr = bCapClearError();
640 // if (FAILED(hr)) {
641 // ROS_WARN("failed to clear error %02x", hr);
642 // return CAST_STATUS(hr);
643 // }
644 // hr = bCapGiveArm();
645 // if (FAILED(hr)) {
646 // ROS_WARN("failed to give arm %02x", hr);
647 // return CAST_STATUS(hr);
648 // }
649 // //hr = bCap_RobotRelease(iSockFD_, lhRobot_); /* Release robot handle */
650 // //if (FAILED(hr))
651 // //{
652 // // ROS_WARN("failed to release the robot");
653 // //}
654 // //hr = bCapGetRobot();
655 // //if (FAILED(hr)) {
656 // // ROS_WARN("failed to get robot %02x", hr);
657 // // return CAST_STATUS(hr);
658 // //}
659 // boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
660 // hr = bCapTakearm();
661 // if (FAILED(hr)) {
662 // ROS_WARN("failed to take arm %02x", hr);
663 // return CAST_STATUS(hr);
664 // }
665 // hr = bCapMotor(true);
666 // if (FAILED(hr)) {
667 // ROS_WARN("failed to turn on motor %02x", hr);
668 // return CAST_STATUS(hr);
669 // }
670 // hr = bCapSlvChangeMode(0x202);
671 // if (FAILED(hr)) {
672 // ROS_WARN("failed to change to slvmode %02x", hr);
673 // return CAST_STATUS(hr);
674 // }
675 // return CAST_STATUS(BCAP_S_OK);
676 // }
677 // if (errorcode >= 0x84204041 && errorcode <= 0x84204048)
678 // {
679 // ROS_INFO("joint angle acceleration is over the software limit.");
680 // ROS_INFO("currently, there is no way to recover, quit.");
681 // // TODO publish message and return healthy status so that an application can send recovery-trajectory.
682 // return CAST_STATUS(BCAP_E_FAIL);
683 // }
684 //
685 //
686 // if (errorcode == 0x83204231)
687 // {
688 // ROS_INFO("invalid command was sent and everything stopped, needs to restart everything");
689 // //TODO restart everything
690 // return CAST_STATUS(BCAP_E_FAIL);
691 // }
692 //
693 // if (errorcode == 0x81501003)
694 // {
695 // ROS_INFO("motor is off, turn on");
696 // BCAP_HRESULT hr = bCapMotor(true);
697 // return CAST_STATUS(hr);
698 // }
699 //
700 // if (errorcode == 0x84201482)
701 // {
702 // // error: postion buffer is empty.
703 // //BCAP_HRESULT hr = bCapFillBuffer(); // this does not work
704 // // now completely restart bcap things
705 // BCAP_HRESULT hr;
706 // hr = bCapMotor(false);
707 // if (FAILED(hr)) {
708 // ROS_WARN("failed to turn off motor %02x", hr);
709 // return CAST_STATUS(hr);
710 // }
711 // hr = bCapGiveArm();
712 // if (FAILED(hr)) {
713 // ROS_WARN("failed to give arm %02x", hr);
714 // return CAST_STATUS(hr);
715 // }
716 // hr = bCapReleaseRobot();
717 // if (FAILED(hr)) {
718 // ROS_WARN("failed to release robot %02x", hr);
719 // return CAST_STATUS(hr);
720 // }
721 // hr = bCapControllerDisConnect();
722 // if (FAILED(hr)) {
723 // ROS_WARN("failed to disconnect controller %02x", hr);
724 // return CAST_STATUS(hr);
725 // }
726 // hr = bCapServerStop();
727 // if (FAILED(hr)) {
728 // ROS_WARN("failed to stop bcap service %02x", hr);
729 // return CAST_STATUS(hr);
730 // }
731 // boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
732 // hr = bCapClose();
733 // if (FAILED(hr)) {
734 // ROS_WARN("failed to close bcap socket %02x", hr);
735 // return CAST_STATUS(hr);
736 // }
737 // hr = bCapOpen();
738 // if (FAILED(hr)) {
739 // ROS_WARN("failed to open socket %02x", hr);
740 // return CAST_STATUS(hr);
741 // }
742 // setUDPTimeout(2, 0); // 2000msec
743 // hr = bCapServerStart();
744 // if (FAILED(hr)) {
745 // ROS_WARN("failed to start service %02x", hr);
746 // return CAST_STATUS(hr);
747 // }
748 // hr = bCapControllerConnect();
749 // if (FAILED(hr)) {
750 // ROS_WARN("failed to connect controller %02x", hr);
751 // return CAST_STATUS(hr);
752 // }
753 // hr = bCapClearError();
754 // if (FAILED(hr)) {
755 // ROS_WARN("failed to clear error %02x", hr);
756 // return CAST_STATUS(hr);
757 // }
758 // hr = bCapGetRobot();
759 // if (FAILED(hr)) {
760 // ROS_WARN("failed to get robot %02x", hr);
761 // return CAST_STATUS(hr);
762 // }
763 // hr = bCapTakearm();
764 // if (FAILED(hr)) {
765 // ROS_WARN("failed to take arm %02x", hr);
766 // return CAST_STATUS(hr);
767 // }
768 // hr = bCapMotor(true);
769 // if (FAILED(hr))
770 // {
771 // ROS_WARN("failed to turn on motor %02x", hr);
772 // return CAST_STATUS(hr);
773 // }
774 // //hr = bCapRobotExecute("clearLog", "");
775 // //if (FAILED(hr))
776 // //{
777 // // ROS_FATAL("failed to clear logging");
778 // // return CAST_STATUS(hr);
779 // //}
780 // hr = bCapSlvChangeMode(0x202);
781 // if (FAILED(hr))
782 // {
783 // ROS_FATAL("failed to change slave mode");
784 // return CAST_STATUS(hr);
785 // }
786 // hr = bCapFillBuffer();
787 // if (FAILED(hr))
788 // {
789 // ROS_FATAL("failed to fill bcap buffer");
790 // return CAST_STATUS(hr);
791 // }
792 // hr = bCapReflectRealState();
793 // if (FAILED(hr))
794 // {
795 // ROS_FATAL("failed to reflect real robot state into controller manager");
796 // return CAST_STATUS(hr);
797 // }
798 // setUDPTimeout((udp_timeout_ / 1000), (udp_timeout_ % 1000) * 1000);
799 //
800 // return CAST_STATUS(hr);
801 // }
802 //
803 // if (errorcode == 0x803022ef || errorcode == 0x84201486)
804 // {
805 // u_int mode;
806 // boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
807 // while(!g_quit_)
808 // {
809 // mode = bCapGetMode();
810 // if (mode != 3) {
811 // // user set controller to manual or teachcheck mode, wait until the user set back to auto
812 // ROS_WARN("waiting until you set back to auto");
813 // boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
814 // } else {
815 // bool estop = bCapGetEmergencyStop();
816 // if (estop) {
817 // ROS_WARN("please turn off emergency stop");
818 // boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
819 // continue;
820 // } else {
821 // break;
822 // }
823 // }
824 // }
825 // //TODO restart bcap server
826 // BCAP_HRESULT hr;
827 // hr = bCapControllerConnect();
828 // if (FAILED(hr)) {
829 // ROS_WARN("failed to connect controller %02x", hr);
830 // return CAST_STATUS(hr);
831 // }
832 // hr = bCapClearError();
833 // if (FAILED(hr)) {
834 // ROS_WARN("failed to clear error %02x", hr);
835 // return CAST_STATUS(hr);
836 // }
837 // hr = bCapGiveArm();
838 // if (FAILED(hr)) {
839 // ROS_WARN("failed to give arm %02x", hr);
840 // return CAST_STATUS(hr);
841 // }
842 // hr = bCapGetRobot();
843 // if (FAILED(hr)) {
844 // ROS_WARN("failed to get robot %02x", hr);
845 // return CAST_STATUS(hr);
846 // }
847 // boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
848 // hr = bCapTakearm();
849 // if (FAILED(hr)) {
850 // ROS_WARN("failed to take arm %02x", hr);
851 // return CAST_STATUS(hr);
852 // }
853 // hr = bCapMotor(true);
854 // if (FAILED(hr)) {
855 // ROS_WARN("failed to turn on motor %02x", hr);
856 // return CAST_STATUS(hr);
857 // }
858 // hr = bCapSlvChangeMode(0x202);
859 // if (FAILED(hr)) {
860 // ROS_WARN("failed to change to slvmode %02x", hr);
861 // return CAST_STATUS(hr);
862 // }
863 // hr = bCapFillBuffer();
864 // if (FAILED(hr)) {
865 // ROS_WARN("failed to fill buffer in slave mode");
866 // return CAST_STATUS(hr);
867 // }
868 // hr = bCapReflectRealState();
869 // if (FAILED(hr)) {
870 // ROS_WARN("failed to reflect real state");
871 // return CAST_STATUS(hr);
872 // }
873 // return CAST_STATUS(BCAP_S_OK);
874 // }
875 // if (errorcode == 0x83500121)
876 // {
877 // ROS_INFO("robot is not in slavemode, try to change it");
878 // BCAP_HRESULT hr;
879 // hr = bCapClearError();
880 // if (FAILED(hr)) return CAST_STATUS(hr);
881 // hr = bCapMotor(true);
882 // if (FAILED(hr)) {
883 // ROS_WARN("failed to turn on motor, cannot recover");
884 // return CAST_STATUS(hr);
885 // }
886 // hr = bCapRobotExecute("clearLog", "");
887 // if (FAILED(hr)) {
888 // ROS_WARN("failed to clear log");
889 // return CAST_STATUS(hr);
890 // }
891 // hr = bCapSlvChangeMode(0x202);
892 // if (FAILED(hr)) {
893 // ROS_WARN("failed to change slvmode, cannot recover");
894 // return CAST_STATUS(hr);
895 // }
896 // hr = bCapFillBuffer();
897 // if (FAILED(hr)) {
898 // ROS_WARN("failed to fill buffer in slave mode");
899 // return CAST_STATUS(hr);
900 // }
901 // hr = bCapReflectRealState();
902 // if (FAILED(hr)) {
903 // ROS_WARN("failed to reflect real state");
904 // return CAST_STATUS(hr);
905 // }
906 // return CAST_STATUS(hr);
907 // }
908 // if (errorcode == 0x83501032)
909 // {
910 // //TODO rethink the way to recover
911 // ROS_INFO("invalid command when the robot is in slave mode, disable slave mode");
912 // BCAP_HRESULT hr = bCapSlvChangeMode(0);
913 // return CAST_STATUS(hr);
914 // }
915 //
916 // if (errorcode == 0x81501025)
917 // {
918 // ROS_INFO("do not send message while an error is occuring");
919 // BCAP_HRESULT hr = bCapClearError();
920 // return CAST_STATUS(hr);
921 // }
922 //
923 // return CAST_STATUS(BCAP_S_OK);
924 // }
925 
926 
927 // OpenControllersInterface::ControllerStatusPtr moveGripper(double value) {
928 // BCAP_HRESULT hr;
929 // ROS_INFO("turn off slavemode");
930 // hr = bCapSlvChangeMode(0x0);
931 // if (FAILED(hr)) {
932 // ROS_WARN("failed to change from slvmode to normal mode");
933 // //return CAST_STATUS(hr);
934 // }
935 // std::vector<double> cur_jnt;
936 // hr = bCapCurJnt(cur_jnt);
937 //
938 // //BCAP_VARIANT gripperparam, gripperresult;
939 // //gripperparam.Type = VT_R4 | VT_ARRAY;
940 // //gripperparam.Arrays = 2;
941 // //gripperparam.Value.FloatArray[0] = 7;
942 // //gripperparam.Value.FloatArray[1] = value;
943 // //gripperparam.Type = VT_BSTR;
944 // //strcpy((char*)gripperparam.Value.String, "(7,23)");
945 // ROS_INFO("move gripper");
946 // //hr = bCap_RobotExecute2(iSockFD_, lhRobot_, "DriveAEx", &gripperparam, &gripperresult);
947 //
948 // std::stringstream ss;
949 // ss << "@P J(" << cur_jnt[0] << ","
950 // << cur_jnt[1] << ","
951 // << cur_jnt[2] << ","
952 // << cur_jnt[3] << ","
953 // << cur_jnt[4] << ","
954 // << cur_jnt[5] << ") EXA((7," << value << "))";
955 //
956 // hr = bCap_RobotMove(iSockFD_, lhRobot_, 1, (char*) ss.str().c_str(), "NEXT");
957 // // @param lComp : [in] completion parameter
958 // // @param pStrPose : [in] Pose string in AsciiZ
959 // // @param pstrOption : [in] Option string in AsciiZ
960 // if (SUCCEEDED(hr)) {
961 // ROS_INFO("succeeded to move gripper");
962 // } else {
963 // ROS_INFO("failed to move gripper %02x", hr);
964 // }
965 //
966 // boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
967 // ROS_INFO("turn on slavemode");
968 // bool b_success_turnonslavemode = false;
969 // for (int i = 0; i < 10; i++) {
970 // hr = bCapSlvChangeMode(0x202);
971 // if (FAILED(hr)) {
972 // ROS_WARN("failed to change slvmode %02x, %d", hr, i);
973 // boost::this_thread::sleep(boost::posix_time::milliseconds(100));
974 // continue;
975 // //return CAST_STATUS(hr);
976 // }
977 // b_success_turnonslavemode = true;
978 // break;
979 // }
980 // if (!b_success_turnonslavemode) {
981 // ROS_WARN("COMPLETELY failed to change slvmode", hr);
982 // }
983 // for (int i = 0; i < 5; i++) {
984 // hr = bCapFillBuffer();
985 // if (FAILED(hr)) {
986 // ROS_WARN("failed to fill buffer in slave mode %02x", hr);
987 // //return CAST_STATUS(hr);
988 // continue;
989 // }
990 // break;
991 // }
992 // ROS_INFO("reflect real state");
993 // hr = bCapReflectRealState();
994 // if (FAILED(hr)) {
995 // ROS_WARN("failed to reflect real state %02x", hr);
996 // //return CAST_STATUS(hr);
997 // }
998 // return CAST_STATUS(hr);
999 // }
1000 // #undef CAST_STATUS(hr)
1001 
1002  void setUDPTimeout(long sec, long usec)
1003  {
1004 #ifdef BCAP_CONNECTION_UDP
1005  struct timeval tv;
1006  tv.tv_sec = sec;
1007  tv.tv_usec = usec;
1008  if (setsockopt(iSockFD_, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0)
1009  {
1010  ROS_WARN("Failed to set send timeout");
1011  }
1012  if (setsockopt(iSockFD_, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0)
1013  {
1014  ROS_WARN("Failed to set recv timeout");
1015  }
1016 #endif
1017  }
1018 
1020  {
1021  BCAP_HRESULT hr = bCap_ServiceStart(iSockFD_); /* Start b-CAP service */
1022  return hr;
1023  }
1025  {
1026  BCAP_HRESULT hr = bCap_ServiceStop(iSockFD_); /* Start b-CAP service */
1027  return hr;
1028  }
1029 
1030  bool initialize(ros::NodeHandle& node, int num_joints)
1031  {
1032  // Set dryrunp_ to true, when no real robot exists
1033  node.getParam("dryrun", dryrunp_);
1034  if (dryrunp_)
1035  {
1036  ROS_WARN("running with loopback mode");
1037  }
1038 
1039  num_joints_ = num_joints;
1040  // Determine ip address of the robot's embedded machine.
1041  if (!node.getParam("server_ip", server_ip_address_))
1042  {
1044  }
1045 
1046  // Determine the pre-set port number used to communicate the robot's embedded computer via bCap.
1047  if (!node.getParam("server_port", server_port_number_))
1048  {
1050  }
1051 
1052  if (!dryrunp_)
1053  {
1054  ROS_INFO("server: %s:%d", server_ip_address_.c_str(), server_port_number_);
1055  }
1056 
1057  // Determine the pre-set UDP timeout length.
1058  if (!node.getParam("udp_timeout", udp_timeout_))
1059  {
1061  }
1062  if (!dryrunp_)
1063  {
1064  ROS_INFO("udp_timeout: %d micro sec", udp_timeout_);
1065  }
1066  if (!dryrunp_)
1067  {
1068  BCAP_HRESULT hr;
1069  ROS_INFO("bCapOpen");
1070  hr = bCapOpen();
1071  if(FAILED(hr))
1072  {
1073  ROS_FATAL("failed to open bCap socket. Exitting...");
1074  ROS_FATAL("make sure that your robot is connected to %s:%d", server_ip_address_.c_str(), server_port_number_);
1075  return false;
1076  }
1077  setUDPTimeout(2, 0); // 2000msec
1078  ROS_INFO("bCapServerStart");
1079  hr = bCapServerStart();
1080  if(FAILED(hr))
1081  {
1082  ROS_FATAL("failed to start bCap server. Exitting...");
1083  return false;
1084  }
1085  ROS_INFO("bCapControllerConnect");
1086  hr = bCapControllerConnect();
1087  if(FAILED(hr))
1088  {
1089  ROS_FATAL("failed to connect bCap controller. Exitting...");
1090  return false;
1091  }
1092  ROS_INFO("bCapClearError");
1093  hr = bCapClearError();
1094  if(FAILED(hr))
1095  {
1096  ROS_FATAL("failed to clear bCap error. Exitting...");
1097  return false;
1098  }
1099  ROS_INFO("bCapGetRobot");
1100  hr = bCapGetRobot();
1101  if(FAILED(hr))
1102  {
1103  ROS_FATAL("failed to get bCap robot. Exitting...");
1104  return false;
1105  }
1106  ROS_INFO("bCapTakearm");
1107  hr = bCapTakearm();
1108  if(FAILED(hr))
1109  {
1110  ROS_FATAL("failed to take bCap arm. Exitting...");
1111  return false;
1112  }
1113  ROS_INFO("bCapSetExternalSpeed");
1114  hr = bCapSetExternalSpeed(100.0);
1115  if(FAILED(hr))
1116  {
1117  ROS_FATAL("failed to set external speed. Exitting...");
1118  return false;
1119  }
1120 
1122 
1123  {
1124  ROS_WARN("bCapMotor On");
1125  hr = bCapMotor(true);
1126  if (FAILED(hr))
1127  {
1128  u_int errorcode;
1129  std::string errormsg;
1130  errorcode = bCapGetErrorCode();
1131  bCapErrorDescription(errormsg);
1132  ROS_INFO("errormsg: %s", errormsg.c_str());
1133  ROS_WARN("failed to motor on, errorcode: %02x, errormsg: %s", errorcode, errormsg.c_str());
1134  //ROS_FATAL("failed to motor on");
1135  //finalize();
1136  return false;
1137  }
1138  }
1139 
1140  // enable logging
1141  hr = bCapRobotExecute("clearLog", "");
1142  if (FAILED(hr))
1143  {
1144  ROS_FATAL("failed to enable logging mode");
1145  return false;
1146  }
1147 
1148  // enable logging
1149  // {
1150  // BCAP_HRESULT hr = bCapRobotExecute("startLog", "");
1151  // if (FAILED(hr)) {
1152  // ROS_FATAL("failed to start logging mode");
1153  // return;
1154  // }
1155  // }
1156 
1157  hr = bCapSlvChangeMode(0x102);
1158  //hr = bCapSlvChangeMode((char*)"258"); // 0x102
1159  //hr = bCapSlvChangeMode(0x102); // 0x102
1160  if (FAILED(hr))
1161  {
1162  ROS_FATAL("failed to change slave mode");
1163  return false;
1164  }
1165 
1166  ROS_INFO("initialize bCap slave connection");
1167  hr = bCapFillBuffer();
1168  if (FAILED(hr))
1169  {
1170  ROS_FATAL("failed to fill bcap buffer");
1171  return false;
1172  }
1173  ROS_INFO("bCap slave initialization done");
1174 
1175 // hr = bCapReflectRealState();
1176 // if (FAILED(hr))
1177 // {
1178 // ROS_FATAL("failed to reflect real robot state into controller manager");
1179 // return;
1180 // }
1181  setUDPTimeout((udp_timeout_ / 1000), (udp_timeout_ % 1000) * 1000);
1182  return true;
1183  } else {
1184  return true;
1185  }
1186  }
1187 
1188 // void quitRequest()
1189 // {
1190 // ROS_INFO("denso_controller received a quit request");
1191 // OpenController::quitRequest(); // call super class
1192 // ros::shutdown();
1193 // }
1194 
1195 private:
1196  std::vector<double> jntvalues_;
1197  std::string server_ip_address_;
1199  // for bCap parameters
1204  std::map<std::string, u_int> var_handlers_;
1205  std::map<std::string, u_short> var_types_;
1206  char errdesc_buffer_[2048]; // TODO: is this enough?
1207  bool dryrunp_;
1209 
1210  struct timespec prev_time_;
1211 };
b-CAP client library header
BCAP_HRESULT bCapCurJnt(std::vector< double > &jointvalues)
Definition: denso_robot.h:311
BCAP_HRESULT bCapFillBuffer()
Definition: denso_robot.h:371
u_int bCapGetIntegerVariable(const std::string &var_name)
Definition: denso_robot.h:215
#define ROS_FATAL(...)
float FloatValue
Definition: b-Cap.h:116
BCAP_HRESULT bCapRobotExecute(char *command, char *arg)
Definition: denso_robot.h:92
bool write(const std::vector< double > &cmd, std::vector< double > &pos)
Definition: denso_robot.h:521
u_int LongValue
Definition: b-Cap.h:115
BCAP_HRESULT bCapClose()
Definition: denso_robot.h:47
BCAP_HRESULT bCap_ControllerGetVariable(int iSockFd, u_int lhController, char *pVarName, char *pstrOption, u_int *plhVar)
Definition: b-Cap.c:655
BCAP_HRESULT bCapGetRobot()
Definition: denso_robot.h:78
BCAP_HRESULT bCap_ServiceStart(int iSockFd)
Definition: b-Cap.c:396
#define DEFAULT_UDP_TIMEOUT
Definition: denso_robot.h:12
#define VT_I4
Definition: b-Cap.h:74
BCAP_HRESULT
BCAP_HRESULT values.
Definition: b-Cap.h:38
bool initialize(ros::NodeHandle &node, int num_joints)
Definition: denso_robot.h:1030
BCAP_HRESULT bCapMotor(bool command)
Definition: denso_robot.h:286
int udp_timeout_
Definition: denso_robot.h:1203
u_short Type
Definition: b-Cap.h:110
unsigned int u_int
Definition: b-Cap.h:104
#define VT_BSTR
Definition: b-Cap.h:81
virtual void finalizeHW()
Definition: denso_robot.h:422
u_int lhRobot_
Definition: denso_robot.h:1202
BCAP_HRESULT bCapOpen()
Definition: denso_robot.h:40
double DoubleArray[16]
Definition: b-Cap.h:121
BCAP_HRESULT bCap_RobotGetVariable(int iSockFd, u_int lhRobot, char *pVarName, char *pStrOption, u_int *lhVarCurJnt)
Definition: b-Cap.c:982
u_int bCapGetMode()
Definition: denso_robot.h:248
BCAP_HRESULT bCap_ControllerConnect(int iSockFd, char *pStrCtrlname, char *pStrProvName, char *pStrPcName, char *pStrOption, u_int *plhController)
Definition: b-Cap.c:467
#define VT_R4
Definition: b-Cap.h:76
#define VT_BOOL
Definition: b-Cap.h:80
u_int __errorcode__
Definition: denso_robot.h:230
int failed_to_send_packet
Definition: b-Cap.c:1824
u_int bCapRobotGetVariable(const std::string &varname)
Definition: denso_robot.h:189
BCAP_HRESULT bCapClearError()
Definition: denso_robot.h:69
virtual ~DensoRobot()
Definition: denso_robot.h:35
BCAP_HRESULT bCap_ControllerExecute(int iSockFd, u_int lhController, char *pStrCommand, char *pStrOption, void *plResult)
Definition: b-Cap.c:800
std::map< std::string, u_short > var_types_
Definition: denso_robot.h:1205
#define DEFAULT_SERVER_PORT_NUM
Definition: denso_robot.h:11
#define ROS_WARN(...)
BCAP_HRESULT bCap_VariableGetValue(int iSockFd, u_int lhVar, void *pVntValue)
Definition: b-Cap.c:1676
u_int bCapGetErrorCode()
Definition: denso_robot.h:231
union BCAP_VARIANT::@0 Value
bool read(std::vector< double > &pos)
Definition: denso_robot.h:505
BCAP_HRESULT bCap_RobotExecute(int iSockFd, u_int lhRobot, char *pStrCommand, char *pStrOption, void *plResult)
Definition: b-Cap.c:1054
char errdesc_buffer_[2048]
Definition: denso_robot.h:1206
BCAP_HRESULT bCap_RobotExecute2(int iSockFd, u_int lhRobot, char *pStrCommand, BCAP_VARIANT *pVntOption, BCAP_VARIANT *pvntResult)
Definition: b-Cap.c:1121
BCAP_HRESULT bCapSetExternalSpeed(float arg)
Definition: denso_robot.h:122
BCAP_HRESULT bCap_ControllerDisconnect(int iSockFd, u_int lhController)
Definition: b-Cap.c:542
u_int lhController_
Definition: denso_robot.h:1201
#define FAILED(Status)
Definition: b-Cap.h:93
BCAP_HRESULT bCap_ControllerGetRobot(int iSockFd, u_int lhController, char *pStrRobotName, char *pStrOption, u_int *lhRobot)
Definition: b-Cap.c:587
BCAP_HRESULT bCap_RobotRelease(int iSockFd, u_int lhRobot)
Definition: b-Cap.c:936
#define ROS_INFO(...)
BCAP_HRESULT bCapRobotSlvMove(BCAP_VARIANT *pose, BCAP_VARIANT *result)
Definition: denso_robot.h:338
BCAP_HRESULT bCapControllerDisConnect()
Definition: denso_robot.h:62
#define VT_R8
Definition: b-Cap.h:77
#define VT_ARRAY
Definition: b-Cap.h:84
BCAP_HRESULT bCapSlvChangeMode(u_int arg)
Definition: denso_robot.h:324
struct timespec prev_time_
Definition: denso_robot.h:1210
BCAP_HRESULT bCapServerStop()
Definition: denso_robot.h:1024
#define ROS_DEBUG_STREAM(args)
void bCapInitializeVariableHandlers()
Definition: denso_robot.h:138
BCAP_HRESULT bCapReleaseRobot()
Definition: denso_robot.h:85
std::string server_ip_address_
Definition: denso_robot.h:1197
std::map< std::string, u_int > var_handlers_
Definition: denso_robot.h:1204
BCAP_HRESULT bCapTakearm()
Definition: denso_robot.h:100
BCAP_HRESULT bCapGiveArm()
Definition: denso_robot.h:114
u_int bCapControllerGetVariable(const std::string &varname)
Definition: denso_robot.h:178
bool getParam(const std::string &key, std::string &s) const
#define DEFAULT_SERVER_IP_ADDRESS
Definition: denso_robot.h:10
int server_port_number_
Definition: denso_robot.h:1198
bool bCapGetEmergencyStop()
Definition: denso_robot.h:253
bool bCapGetBoolVariable(const std::string &var_name)
Definition: denso_robot.h:200
u_int Arrays
Definition: b-Cap.h:111
BCAP_HRESULT bCapServerStart()
Definition: denso_robot.h:1019
BCAP_HRESULT bCap_Open(const char *pIPStr, int iPort, int *piSockFd)
Definition: b-Cap.c:225
void setUDPTimeout(long sec, long usec)
Definition: denso_robot.h:1002
std::vector< double > jntvalues_
Definition: denso_robot.h:1196
#define VT_DATE
Definition: b-Cap.h:79
BCAP_HRESULT bCap_ServiceStop(int iSockFd)
Definition: b-Cap.c:428
BCAP_HRESULT bCapControllerConnect()
Definition: denso_robot.h:54
u_int bCapErrorDescription(std::string &errormsg)
Definition: denso_robot.h:258
BCAP_HRESULT bCap_Close(int iSockFd)
Definition: b-Cap.c:359
#define ROS_DEBUG(...)


denso_ros_control
Author(s):
autogenerated on Mon Jun 10 2019 13:13:14