RobotHardware/robot.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <fstream>
5 #include <sys/time.h>
6 #include <hrpModel/Sensor.h>
7 #include <hrpModel/Link.h>
8 #include "defs.h"
9 #include "hrpsys/io/iob.h"
10 #include "robot.h"
11 #include "hrpsys/util/Hrpsys.h"
12 
13 #define CALIB_COUNT (10*200)
14 #define GAIN_COUNT ( 5*200)
15 
16 #define DEFAULT_MAX_ZMP_ERROR 0.03 //[m]
17 #define DEFAULT_ANGLE_ERROR_LIMIT 0.2 // [rad]
18 
19 using namespace hrp;
20 
21 
22 robot::robot(double dt) : m_fzLimitRatio(0), m_maxZmpError(DEFAULT_MAX_ZMP_ERROR), m_accLimit(0), m_calibRequested(false), m_pdgainsFilename("PDgains.sav"), m_reportedEmergency(true), m_dt(dt), m_enable_poweroff_check(false),m_servoOnDelay(0)
23 {
24  sem_init(&wait_sem, 0, 0);
26 }
27 
29 {
30  close_iob();
31 }
32 
34 {
35  int i;
36  gain_counter.resize(numJoints());
37  for (unsigned i=0; i<numJoints(); i++){
39  }
40 
42 
43  pgain.resize(numJoints());
44  dgain.resize(numJoints());
45  old_pgain.resize(numJoints());
46  old_dgain.resize(numJoints());
47  default_pgain.resize(numJoints());
48  default_dgain.resize(numJoints());
49  tqpgain.resize(numJoints());
50  tqdgain.resize(numJoints());
51  old_tqpgain.resize(numJoints());
52  old_tqdgain.resize(numJoints());
53  default_tqpgain.resize(numJoints());
54  default_tqdgain.resize(numJoints());
55  for (unsigned int i=0; i<numJoints(); i++){
56  pgain[i] = dgain[i] = 0.0;
57  old_pgain[i] = old_dgain[i] = 0.0;
58  default_pgain[i] = default_dgain[i] = 0.0;
59  tqpgain[i] = tqdgain[i] = 0.0;
60  old_tqpgain[i] = old_tqdgain[i] = 0.0;
61  default_tqpgain[i] = default_tqdgain[i] = 0.0;
62  }
63  loadGain();
64  for (unsigned int i=0; i<numJoints(); i++){
65  pgain[i] = default_pgain[i];
66  dgain[i] = default_dgain[i];
67  tqpgain[i] = default_tqpgain[i];
68  tqdgain[i] = default_tqdgain[i];
69  }
70 
71  m_servoErrorLimit.resize(numJoints());
72  for (unsigned int i=0; i<numJoints(); i++){
74  }
75 
76 
77 
80  set_number_of_gyro_sensors(numSensors(Sensor::RATE_GYRO));
81  set_number_of_accelerometers(numSensors(Sensor::ACCELERATION));
82 
83  gyro_sum.resize(numSensors(Sensor::RATE_GYRO));
84  accel_sum.resize(numSensors(Sensor::ACCELERATION));
85  force_sum.resize(numSensors(Sensor::FORCE));
86 
87  if ((number_of_joints() != (int)numJoints())
88  || (number_of_force_sensors() != (int)numSensors(Sensor::FORCE))
89  || (number_of_gyro_sensors() != (int)numSensors(Sensor::RATE_GYRO))
90  || (number_of_accelerometers() != (int)numSensors(Sensor::ACCELERATION))){
91  std::cerr << "VRML and IOB are inconsistent" << std::endl;
92  std::cerr << " joints:" << numJoints() << "(VRML), " << number_of_joints() << "(IOB)" << std::endl;
93  std::cerr << " force sensor:" << numSensors(Sensor::FORCE) << "(VRML), " << number_of_force_sensors() << "(IOB)" << std::endl;
94  std::cerr << " gyro sensor:" << numSensors(Sensor::RATE_GYRO) << "(VRML), " << number_of_gyro_sensors() << "(IOB)" << std::endl;
95  std::cerr << " accelerometer:" << numSensors(Sensor::ACCELERATION) << "(VRML), " << number_of_accelerometers() << "(IOB)" << std::endl;
96  return false;
97  }
98  G << 0, 0, 9.8;
99 
100  if (open_iob() == FALSE) return false;
101 
102  return true;
103 }
104 
106 {
107  std::cerr << "[RobotHardware] removeForceSensorOffset..." << std::endl;
109  std::cerr << "[RobotHardware] removeForceSensorOffset...done." << std::endl;
110 }
111 
113 {
114  std::ifstream strm(m_pdgainsFilename.c_str());
115  if (!strm.is_open()) {
116  std::cerr << m_pdgainsFilename << " not found" << std::endl;
117  return false;
118  }
119 
120  for (int i = 0; i < numJoints(); i++) {
121  std::string str;
122  bool getlinep;
123  while ((getlinep = !!(std::getline(strm, str)))) {
124  if (str.empty()) {
125  // std::cerr << "[RobotHardware] : loadGain : skip emptiy line" << std::endl;
126  continue;
127  }
128  if (str[0] == '#') {
129  // std::cerr << "[RobotHardware] : loadGain : skip # started line" << std::endl;
130  continue;
131  }
132  double tmp;
133  std::istringstream sstrm(str);
134  sstrm >> tmp;
135  default_pgain[i] = tmp;
136  if(sstrm.eof()) break;
137 
138  sstrm >> tmp; // I gain
139  if(sstrm.eof()) break;
140 
141  sstrm >> tmp;
142  default_dgain[i] = tmp;
143  if(sstrm.eof()) break;
144 
145  sstrm >> tmp;
146  default_tqpgain[i] = tmp;
147  if(sstrm.eof()) break;
148 
149  sstrm >> tmp; // I gain for torque
150  if(sstrm.eof()) break;
151 
152  sstrm >> tmp;
153  default_tqdgain[i] = tmp;
154 
155  break;
156  }
157  if(!getlinep) {
158  if (i < numJoints()) {
159  std::cerr << "[RobotHardware] loadGain error: size of gains reading from file ("
161  << ") does not match size of joints" << std::endl;
162  }
163  break;
164  }
165  }
166 
167  strm.close();
168  // Print loaded gain
169  std::cerr << "[RobotHardware] loadGain" << std::endl;
170  for (unsigned int i=0; i<numJoints(); i++) {
171  std::cerr << "[RobotHardware] " << joint(i)->name
172  << ", pgain = " << default_pgain[i]
173  << ", dgain = " << default_dgain[i]
174  << ", tqpgain = " << default_tqpgain[i]
175  << ", tqdgain = " << default_tqdgain[i]
176  << std::endl;
177  }
178  return true;
179 }
180 
182 {
183  std::cerr << "[RobotHardware] startInertiaSensorCalibration..." << std::endl;
184  if (numSensors(Sensor::ACCELERATION)==0
185  && numSensors(Sensor::RATE_GYRO)==0) return;
186 
187  if (isBusy()) return;
188 
189  for (unsigned int j=0; j<numSensors(Sensor::RATE_GYRO); j++) {
190  for (int i=0; i<3; i++) {
191  gyro_sum[j][i] = 0;
192  }
194  }
195 
196  for(unsigned int j=0; j<numSensors(Sensor::ACCELERATION); j++) {
197  for (int i=0; i<3; i++) {
198  accel_sum[j][i] = 0;
199  }
201  }
202 
203 #if 0
204  for(unsigned int j=0; j<m_natt; j++) {
205  for (int i=0; i<3; i++) {
206  att_sum[j][i] = 0;
207  }
209  }
210 #endif
211 
213 
214  sem_wait(&wait_sem);
215  std::cerr << "[RobotHardware] startInertiaSensorCalibration...done." << std::endl;
216 }
217 
219 {
220  if (numSensors(Sensor::FORCE)==0) return;
221 
222  if (isBusy()) return;
223 
224  for (unsigned int j=0; j<numSensors(Sensor::FORCE); j++) {
225  for (int i=0; i<6; i++) {
226  force_sum[j][i] = 0;
227  }
228  }
229 
231 
232  sem_wait(&wait_sem);
233 }
234 
235 void robot::initializeJointAngle(const char *name, const char *option)
236 {
238  m_calibOptions = option;
239  m_calibRequested = true;
240  sem_wait(&wait_sem);
241 }
242 
244 {
245  if (inertia_calib_counter>0) {
246  for (unsigned int j=0; j<numSensors(Sensor::RATE_GYRO); j++){
247  double rate[3];
248  read_gyro_sensor(j, rate);
249  for (int i=0; i<3; i++)
250  gyro_sum[j][i] += rate[i];
251  }
252 
253  for (unsigned int j=0; j<numSensors(Sensor::ACCELERATION); j++){
254  double acc[3];
255  read_accelerometer(j, acc);
256  for (int i=0; i<3; i++)
257  accel_sum[j][i] += acc[i];
258  }
259 
260 #if 0
261  for (unsigned int j=0; j<m_natt; j++){
262  double att[3];
263  read_attitude_sensor(j, att);
264  for (int i=0; i<3; i++)
265  att_sum[j][i] += att[i];
266  }
267 #endif
268 
270  if (inertia_calib_counter==0) {
271 
272  for (unsigned int j=0; j<numSensors(Sensor::RATE_GYRO); j++) {
273  for (int i=0; i<3; i++) {
274  gyro_sum[j][i] = -gyro_sum[j][i]/CALIB_COUNT;
275  }
277  }
278 
279  for (unsigned int j=0; j<numSensors(Sensor::ACCELERATION); j++) {
281  hrp::Matrix33 m_sensorR = m_sensor->link->R * m_sensor->localR;
282  hrp::Vector3 G_rotated = m_sensorR.transpose() * G;
283  for (int i=0; i<3; i++) {
284  accel_sum[j][i] = -accel_sum[j][i]/CALIB_COUNT + G_rotated(i);
285  }
287  }
288 
289 #if 0
290  for (unsigned int j=0; j<m_natt; j++) {
291  for (int i=0; i<3; i++) {
292  att_sum[j][i] = -att_sum[j][i]/CALIB_COUNT;
293  }
295  }
296 #endif
297 
298  sem_post(&wait_sem);
299  }
300  }
301 }
302 
304 {
305  if (force_calib_counter>0) {
306  for (unsigned int j=0; j<numSensors(Sensor::FORCE); j++){
307  double force[6];
308  read_force_sensor(j, force);
309  for (int i=0; i<6; i++)
310  force_sum[j][i] += force[i];
311  }
313  if (force_calib_counter==0) {
314 
315  for (unsigned int j=0; j<numSensors(Sensor::FORCE); j++) {
316  for (int i=0; i<6; i++) {
317  force_sum[j][i] = -force_sum[j][i]/CALIB_COUNT;
318  }
320  }
321 
322  sem_post(&wait_sem);
323  }
324  }
325 }
326 
328 {
329  double new_pgain=0,new_dgain=0,new_tqpgain=0,new_tqdgain=0;
330  if (gain_counter[i] < GAIN_COUNT){
331  gain_counter[i]++;
332  new_pgain = (pgain[i]-old_pgain[i])*gain_counter[i]/GAIN_COUNT + old_pgain[i];
333  new_dgain = (dgain[i]-old_dgain[i])*gain_counter[i]/GAIN_COUNT + old_dgain[i];
334  new_tqpgain = (tqpgain[i]-old_tqpgain[i])*gain_counter[i]/GAIN_COUNT + old_tqpgain[i];
335  new_tqdgain = (tqdgain[i]-old_tqdgain[i])*gain_counter[i]/GAIN_COUNT + old_tqdgain[i];
336  write_pgain(i, new_pgain);
337  write_dgain(i, new_dgain);
338 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
339  write_torque_pgain(i, new_tqpgain);
340  write_torque_dgain(i, new_tqdgain);
341 #endif
342  }
343 }
344 
346 {
347  int i;
348  for (unsigned i=0; i<numJoints(); i++) gain_control(i);
349 }
350 
352 {
355  gain_control();
356  if (m_calibRequested){
358  m_calibOptions.c_str());
359  m_calibRequested = false;
360  sem_post(&wait_sem);
361  }
362 }
363 
364 bool robot::servo(const char *jname, bool turnon)
365 {
366  Link *l = NULL;
367  if (strcmp(jname, "all") == 0 || strcmp(jname, "ALL") == 0){
368  bool ret = true;
369  for (unsigned int i=0; i<numJoints(); i++){
370  ret = ret && servo(i, turnon);
371  if (turnon) usleep(m_servoOnDelay*1e6);
372  }
373  m_reportedEmergency = false;
374  return ret;
375  }else if ((l = link(jname)) && (l->jointId >= 0)){
376  return servo(l->jointId, turnon);
377  }else{
378  char *s = (char *)jname; while(*s) {*s=toupper(*s);s++;}
379  const std::vector<int> jgroup = m_jointGroups[jname];
380  if (jgroup.size() == 0) return false;
381  bool ret = true;
382  for (unsigned int i=0; i<jgroup.size(); i++){
383  ret = ret && servo(jgroup[i], turnon);
384  return ret;
385  }
386  }
387  return false;
388 }
389 
390 bool robot::servo(int jid, bool turnon)
391 {
392  if (jid == JID_INVALID || jid >= (int)numJoints()) return false;
393 
394  int com = OFF;
395 
396  if (turnon) {
397  com = ON;
398  }
399 
400  write_pgain(jid, 0);
401  write_dgain(jid, 0);
402  old_pgain[jid] = 0;
403  old_dgain[jid] = 0;
404 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
405  write_torque_pgain(jid, 0);
406  write_torque_dgain(jid, 0);
407 #endif
408  old_tqpgain[jid] = 0;
409  old_tqdgain[jid] = 0;
410  if (turnon){
411  double angle;
412  read_actual_angle(jid, &angle);
413  write_command_angle(jid, angle);
414  }
415  write_servo(jid, com);
416  if (turnon) gain_counter[jid] = 0;
417 
418  return true;
419 }
420 
421 
422 bool robot::power(const char *jname, bool turnon)
423 {
424  int jid = JID_INVALID;
425 
426  if (strcmp(jname, "all") == 0 || strcmp(jname, "ALL") == 0){
427  jid = JID_ALL;
428  }else{
429  Link *l = link(jname);
430  if (!l) return false;
431  if (l->jointId < 0) return false;
432  jid = l->jointId;
433  }
434  return power(jid, turnon);
435 }
436 
437 bool robot::power(int jid, bool turnon)
438 {
439  if (jid == JID_INVALID || jid >= (int)numJoints()) return false;
440 
441  int com = OFF;
442 
443  if (turnon) {
444 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
445  int s;
446  read_servo_state(jid, &s);
447  if (s == ON)
448  return false;
449 #else
450  for(unsigned int i=0; i<numJoints(); i++) {
451  int s;
452  read_servo_state(i, &s);
453  if (s == ON)
454  return false;
455  }
456 #endif
457  com = ON;
458  }
459 
460  // next part written as if there is a relay for each joint
461  // up to HRP2, TREX, PARASA there is only one.
462 
463  if(jid == JID_ALL) {
464  if (com == OFF) {
465  for (unsigned int i=0; i<numJoints(); i++) {
466  write_pgain(i, 0);
467  write_dgain(i, 0);
468 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
469  write_torque_pgain(i, 0);
470  write_torque_dgain(i, 0);
471 #endif
472  write_servo(i, com);
473  write_power_command(i, com);
474  }
475  } else
476  for (unsigned int i=0; i<numJoints(); i++)
477  write_power_command(i, com);
478  } else {
479  if (com == OFF) {
480  write_pgain(jid, 0);
481  write_dgain(jid, 0);
482 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
483  write_torque_pgain(jid, 0);
484  write_torque_dgain(jid, 0);
485 #endif
486  write_servo(jid, com);
487  write_power_command(jid, com);
488  } else {
489  write_power_command(jid, com);
490  }
491  }
492 
493  return true;
494 }
495 
496 bool robot::isBusy() const
497 {
499  return true;
500 
501  for (unsigned int i=0; i<numJoints(); i++) {
502  if (gain_counter[i] < GAIN_COUNT) {
503  return true;
504  }
505  }
506 
507  return false;
508 }
509 
510 void robot::readJointAngles(double *o_angles)
511 {
512  read_actual_angles(o_angles);
513 }
514 
515 void robot::readJointVelocities(double *o_velocities)
516 {
517  read_actual_velocities(o_velocities);
518 }
519 
520 int robot::readJointTorques(double *o_torques)
521 {
522  return read_actual_torques(o_torques);
523 }
524 
525 int robot::readJointCommandTorques(double *o_torques)
526 {
527  return read_command_torques(o_torques);
528 }
529 
530 void robot::readGyroSensor(unsigned int i_rank, double *o_rates)
531 {
532  read_gyro_sensor(i_rank, o_rates);
533 }
534 
535 void robot::readAccelerometer(unsigned int i_rank, double *o_accs)
536 {
537  read_accelerometer(i_rank, o_accs);
538 }
539 
540 void robot::readForceSensor(unsigned int i_rank, double *o_forces)
541 {
542  read_force_sensor(i_rank, o_forces);
543 }
544 
545 void robot::writeJointCommands(const double *i_commands)
546 {
547  if (!m_commandOld.size()) {
548  m_commandOld.resize(numJoints());
549  m_velocityOld.resize(numJoints());
550  }
551  for (unsigned int i=0; i<numJoints(); i++){
552  m_velocityOld[i] = (i_commands[i] - m_commandOld[i])/m_dt;
553  m_commandOld[i] = i_commands[i];
554  }
555  write_command_angles(i_commands);
556 }
557 
558 void robot::readJointCommands(double *o_commands)
559 {
560  read_command_angles(o_commands);
561 }
562 
563 void robot::writeTorqueCommands(const double *i_commands)
564 {
565  write_command_torques(i_commands);
566 }
567 
568 void robot::writeVelocityCommands(const double *i_commands)
569 {
570  write_command_velocities(i_commands);
571 }
572 
573 void robot::writeAccelerationCommands(const double *i_commands)
574 {
575 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
576  write_command_accelerations(i_commands);
577 #endif
578 }
579 
580 void robot::readPowerStatus(double &o_voltage, double &o_current)
581 {
582  read_power(&o_voltage, &o_current);
583 }
584 
586 {
587  int v=0;
588  read_calib_state(i, &v);
589  return v;
590 }
591 
593 {
594  int v=0;
595  read_power_state(i, &v);
596  return v;
597 }
598 
600 {
601  int v=0;
602  read_servo_state(i, &v);
603  return v;
604 }
605 
607 {
608  int v=0;
609  read_servo_alarm(i, &v);
610  return v;
611 }
612 
614 {
615  unsigned char temp=0;
616  read_driver_temperature(i, &temp);
617  return temp;
618 }
619 
620 char *time_string()
621 {
622  struct timeval tv;
623  gettimeofday(&tv, NULL);
624  struct tm *tm_ = localtime(&tv.tv_sec);
625  static char time[20];
626  sprintf(time, "%02d:%02d:%02d.%06d", tm_->tm_hour, tm_->tm_min, tm_->tm_sec, (int)tv.tv_usec);
627  return time;
628 }
629 
630 bool robot::checkJointCommands(const double *i_commands)
631 {
632  if (!m_dt) return false;
633  if (!m_commandOld.size()) return false;
634 
635  int state;
636  for (unsigned int i=0; i<numJoints(); i++){
637  read_servo_state(i, &state);
638  if (state == ON){
639  double command_old=m_commandOld[i], command=i_commands[i];
640  double v = (command - command_old)/m_dt;
641  if (fabs(v) > joint(i)->uvlimit){
642  std::cerr << time_string()
643  << ": joint command velocity limit over: joint = "
644  << joint(i)->name
645  << ", vlimit = " << joint(i)->uvlimit/M_PI*180
646  << "[deg/s], v = "
647  << v/M_PI*180 << "[deg/s]" << std::endl;
648  return true;
649  }
650  double a = (v - m_velocityOld[i])/m_dt;
651  if (m_accLimit && fabs(a) > m_accLimit){
652  std::cerr << time_string()
653  << ": joint command acceleration limit over: joint = "
654  << joint(i)->name
655  << ", alimit = " << m_accLimit/M_PI*180
656  << "[deg/s^2], v = "
657  << a/M_PI*180 << "[deg/s^2]" << std::endl;
658  return true;
659  }
660  }
661  }
662  return false;
663 }
664 
665 bool robot::checkEmergency(emg_reason &o_reason, int &o_id)
666 {
667  int state;
668  for (unsigned int i=0; i<numJoints(); i++){
669  read_servo_state(i, &state);
670  if (state == ON && m_servoErrorLimit[i] != 0){
671  double angle, command;
672  read_actual_angle(i, &angle);
673  read_command_angle(i, &command);
674  if (fabs(angle-command) > m_servoErrorLimit[i]){
675  std::cerr << time_string()
676  << ": servo error limit over: joint = "
677  << joint(i)->name
678  << ", qRef = " << command/M_PI*180 << "[deg], q = "
679  << angle/M_PI*180 << "[deg]" << std::endl;
680  o_reason = EMG_SERVO_ERROR;
681  o_id = i;
682  return true;
683  }
684  }
685  }
686 
687  if (m_rLegForceSensorId >= 0){
688  double force[6];
690  if (force[FZ] > totalMass()*G(2)*m_fzLimitRatio){
691  std::cerr << time_string() << ": right Fz limit over: Fz = " << force[FZ] << std::endl;
692  o_reason = EMG_FZ;
693  o_id = m_rLegForceSensorId;
694  return true;
695  }
696  }
697  if (m_lLegForceSensorId >= 0){
698  double force[6];
700  if (force[FZ] > totalMass()*G(2)*m_fzLimitRatio){
701  std::cerr << time_string() << ": left Fz limit over: Fz = " << force[FZ] << std::endl;
702  o_reason = EMG_FZ;
703  o_id = m_lLegForceSensorId;
704  return true;
705  }
706  }
707  int alarm;
708  for (unsigned int i=0; i<numJoints(); i++){
709  if (!read_servo_alarm(i, &alarm)) continue;
710  if (alarm & SS_EMERGENCY) {
711  if (!m_reportedEmergency) {
712  m_reportedEmergency = true;
713  o_reason = EMG_SERVO_ALARM;
714  o_id = i;
715  }
716  return true;
717  }
718  }
719  m_reportedEmergency = false;
720  // Power state check
722  int pstate, sstate;
723  for (unsigned int i=0; i<numJoints(); i++){
724  read_power_state(i, &pstate);
725  read_servo_state(i, &sstate);
726  // If power OFF while servo ON
727  if (!m_reportedEmergency && (pstate == OFF) && (sstate == ON) ) {
728  m_reportedEmergency = true;
729  o_reason = EMG_POWER_OFF;
730  o_id = i;
731  std::cerr << time_string() << ": power off detected : joint = " << joint(i)->name << std::endl;
732  return true;
733  }
734  }
735  m_reportedEmergency = false;
736  }
737  return false;
738 }
739 
740 bool robot::setServoGainPercentage(const char *i_jname, double i_percentage)
741 {
742  if ( i_percentage < 0 || 100 < i_percentage ) {
743  std::cerr << "[RobotHardware] Invalid percentage " << i_percentage << "[%] for setServoGainPercentage. Percentage should be in (0, 100)[%]." << std::endl;
744  return false;
745  }
746  Link *l = NULL;
747  if (strcmp(i_jname, "all") == 0 || strcmp(i_jname, "ALL") == 0){
748  for (unsigned int i=0; i<numJoints(); i++){
749  if (!read_pgain(i, &old_pgain[i])) old_pgain[i] = pgain[i];
750  pgain[i] = default_pgain[i] * i_percentage/100.0;
751  if (!read_dgain(i, &old_dgain[i])) old_dgain[i] = dgain[i];
752  dgain[i] = default_dgain[i] * i_percentage/100.0;
753 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
754  if (!read_torque_pgain(i, &old_tqpgain[i])) old_tqpgain[i] = tqpgain[i];
755  if (!read_torque_dgain(i, &old_tqdgain[i])) old_tqdgain[i] = tqdgain[i];
756 #endif
757  gain_counter[i] = 0;
758  }
759  std::cerr << "[RobotHardware] setServoGainPercentage " << i_percentage << "[%] for all joints" << std::endl;
760  }else if ((l = link(i_jname)) && (l->jointId >= 0)){
761  if (!read_pgain(l->jointId, &old_pgain[l->jointId])) old_pgain[l->jointId] = pgain[l->jointId];
762  pgain[l->jointId] = default_pgain[l->jointId] * i_percentage/100.0;
763  if (!read_dgain(l->jointId, &old_dgain[l->jointId])) old_dgain[l->jointId] = dgain[l->jointId];
764  dgain[l->jointId] = default_dgain[l->jointId] * i_percentage/100.0;
765 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
766  if (!read_torque_pgain(l->jointId, &old_tqpgain[l->jointId])) old_tqpgain[l->jointId] = tqpgain[l->jointId];
767  if (!read_torque_dgain(l->jointId, &old_tqdgain[l->jointId])) old_tqdgain[l->jointId] = tqdgain[l->jointId];
768 #endif
769  gain_counter[l->jointId] = 0;
770  std::cerr << "[RobotHardware] setServoGainPercentage " << i_percentage << "[%] for " << i_jname << std::endl;
771  }else{
772  char *s = (char *)i_jname; while(*s) {*s=toupper(*s);s++;}
773  const std::vector<int> jgroup = m_jointGroups[i_jname];
774  if (jgroup.size()==0) return false;
775  for (unsigned int i=0; i<jgroup.size(); i++){
776  if (!read_pgain(jgroup[i], &old_pgain[jgroup[i]])) old_pgain[jgroup[i]] = pgain[jgroup[i]];
777  pgain[jgroup[i]] = default_pgain[jgroup[i]] * i_percentage/100.0;
778  if (!read_dgain(jgroup[i], &old_dgain[jgroup[i]])) old_dgain[jgroup[i]] = dgain[jgroup[i]];
779  dgain[jgroup[i]] = default_dgain[jgroup[i]] * i_percentage/100.0;
780 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
781  if (!read_torque_pgain(jgroup[i], &old_tqpgain[jgroup[i]])) old_tqpgain[jgroup[i]] = tqpgain[jgroup[i]];
782  if (!read_torque_dgain(jgroup[i], &old_tqdgain[jgroup[i]])) old_tqdgain[jgroup[i]] = tqdgain[jgroup[i]];
783 #endif
784  gain_counter[jgroup[i]] = 0;
785  }
786  std::cerr << "[RobotHardware] setServoGainPercentage " << i_percentage << "[%] for " << i_jname << std::endl;
787  }
788  return true;
789 }
790 
791 bool robot::setServoTorqueGainPercentage(const char *i_jname, double i_percentage)
792 {
793  if ( i_percentage < 0 && 100 < i_percentage ) {
794  std::cerr << "[RobotHardware] Invalid percentage " << i_percentage << "[%] for setServoTorqueGainPercentage. Percentage should be in (0, 100)[%]." << std::endl;
795  return false;
796  }
797  Link *l = NULL;
798  if (strcmp(i_jname, "all") == 0 || strcmp(i_jname, "ALL") == 0){
799  for (int i=0; i<numJoints(); i++){
800 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
801  if (!read_torque_pgain(i, &old_tqpgain[i])) old_tqpgain[i] = tqpgain[i];
802  tqpgain[i] = default_tqpgain[i] * i_percentage/100.0;
803  if (!read_torque_dgain(i, &old_tqdgain[i])) old_tqdgain[i] = tqdgain[i];
804  tqdgain[i] = default_tqdgain[i] * i_percentage/100.0;
805 #endif
806  if (!read_pgain(i, &old_pgain[i])) old_pgain[i] = pgain[i];
807  if (!read_dgain(i, &old_dgain[i])) old_dgain[i] = dgain[i];
808  gain_counter[i] = 0;
809  }
810  std::cerr << "[RobotHardware] setServoTorqueGainPercentage " << i_percentage << "[%] for all joints" << std::endl;
811  }else if ((l = link(i_jname)) && (l->jointId >= 0)){
812 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
813  if (!read_torque_pgain(l->jointId, &old_tqpgain[l->jointId])) old_tqpgain[l->jointId] = tqpgain[l->jointId];
814  tqpgain[l->jointId] = default_tqpgain[l->jointId] * i_percentage/100.0;
815  if (!read_torque_dgain(l->jointId, &old_tqdgain[l->jointId])) old_tqdgain[l->jointId] = tqdgain[l->jointId];
816  tqdgain[l->jointId] = default_tqdgain[l->jointId] * i_percentage/100.0;
817 #endif
818  if (!read_pgain(l->jointId, &old_pgain[l->jointId])) old_pgain[l->jointId] = pgain[l->jointId];
819  if (!read_dgain(l->jointId, &old_dgain[l->jointId])) old_dgain[l->jointId] = dgain[l->jointId];
820  gain_counter[l->jointId] = 0;
821  std::cerr << "[RobotHardware] setServoTorqueGainPercentage " << i_percentage << "[%] for " << i_jname << std::endl;
822  }else{
823  char *s = (char *)i_jname; while(*s) {*s=toupper(*s);s++;}
824  const std::vector<int> jgroup = m_jointGroups[i_jname];
825  if (jgroup.size()==0) return false;
826  for (unsigned int i=0; i<jgroup.size(); i++){
827 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 4
828  if (!read_torque_pgain(jgroup[i], &old_tqpgain[jgroup[i]])) old_tqpgain[jgroup[i]] = tqpgain[jgroup[i]];
829  tqpgain[jgroup[i]] = default_tqpgain[jgroup[i]] * i_percentage/100.0;
830  if (!read_torque_dgain(jgroup[i], &old_tqdgain[jgroup[i]])) old_tqdgain[jgroup[i]] = tqdgain[jgroup[i]];
831  tqdgain[jgroup[i]] = default_tqdgain[jgroup[i]] * i_percentage/100.0;
832 #endif
833  if (!read_pgain(jgroup[i], &old_pgain[jgroup[i]])) old_pgain[jgroup[i]] = pgain[jgroup[i]];
834  if (!read_dgain(jgroup[i], &old_dgain[jgroup[i]])) old_dgain[jgroup[i]] = dgain[jgroup[i]];
835  gain_counter[jgroup[i]] = 0;
836  }
837  std::cerr << "[RobotHardware] setServoTorqueGainPercentage " << i_percentage << "[%] for " << i_jname << std::endl;
838  }
839  return true;
840 }
841 
842 bool robot::setServoErrorLimit(const char *i_jname, double i_limit)
843 {
844  Link *l = NULL;
845  if (strcmp(i_jname, "all") == 0 || strcmp(i_jname, "ALL") == 0){
846  for (unsigned int i=0; i<numJoints(); i++){
847  m_servoErrorLimit[i] = i_limit;
848  }
849  }else if ((l = link(i_jname)) && (l->jointId >= 0)){
850  m_servoErrorLimit[l->jointId] = i_limit;
851  }else{
852  char *s = (char *)i_jname; while(*s) {*s=toupper(*s);s++;}
853  const std::vector<int> jgroup = m_jointGroups[i_jname];
854  if (jgroup.size()==0) return false;
855  for (unsigned int i=0; i<jgroup.size(); i++){
856  m_servoErrorLimit[jgroup[i]] = i_limit;
857  }
858  }
859  return true;
860 }
861 
862 void robot::setProperty(const char *i_key, const char *i_value)
863 {
864  std::istringstream iss(i_value);
865  std::string key(i_key);
866  bool isKnownKey = true;
867  if (key == "sensor_id.right_leg_force_sensor"){
868  iss >> m_rLegForceSensorId;
869  }else if (key == "sensor_id.left_leg_force_sensor"){
870  iss >> m_lLegForceSensorId;
871  }else if (key == "pdgains.file_name"){
872  iss >> m_pdgainsFilename;
873  }else if (key == "enable_poweroff_check"){
874  std::string tmp;
875  iss >> tmp;
876  m_enable_poweroff_check = (tmp=="true");
877  }else{
878  isKnownKey = false;
879  }
880  if (isKnownKey) std::cout << i_key << ": " << i_value << std::endl;
881 }
882 
883 bool robot::names2ids(const std::vector<std::string> &i_names,
884  std::vector<int> &o_ids)
885 {
886  bool ret = true;
887  for (unsigned int i=0; i<i_names.size(); i++){
888  Link *l = link(i_names[i].c_str());
889  if (!l){
890  std::cout << "joint named [" << i_names[i] << "] not found"
891  << std::endl;
892  ret = false;
893  }else{
894  o_ids.push_back(l->jointId);
895  }
896  }
897  return ret;
898 }
899 
900 bool robot::addJointGroup(const char *gname, const std::vector<std::string>& jnames)
901 {
902  char *s = (char *)gname; while(*s) {*s=toupper(*s);s++;}
903  std::vector<int> jids;
904  bool ret = names2ids(jnames, jids);
905  m_jointGroups[gname] = jids;
906  return ret;
907 }
908 
910 {
911  return length_of_extra_servo_state(id);
912 }
913 
914 void robot::readExtraServoState(int id, int *state)
915 {
916  read_extra_servo_state(id, state);
917 }
918 
919 bool robot::readDigitalInput(char *o_din)
920 {
921 #ifndef NO_DIGITAL_INPUT
922  return read_digital_input(o_din);
923 #else
924  return false;
925 #endif
926 }
927 
929 {
930 #ifndef NO_DIGITAL_INPUT
931  return length_digital_input();
932 #else
933  return 0;
934 #endif
935 }
936 
937 bool robot::writeDigitalOutput(const char *i_dout)
938 {
939  return write_digital_output(i_dout);
940 }
941 
942 bool robot::writeDigitalOutputWithMask(const char *i_dout, const char *i_mask)
943 {
944  return write_digital_output_with_mask(i_dout, i_mask);
945 }
946 
948 {
949  return length_digital_output();
950 }
951 
952 bool robot::readDigitalOutput(char *o_dout)
953 {
954  return read_digital_output(o_dout);
955 }
956 
957 void robot::readBatteryState(unsigned int i_rank, double &voltage,
958  double &current, double &soc)
959 {
960 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2
961  read_battery(i_rank, &voltage, &current, &soc);
962 #else
963  voltage=0; current=0; soc=0;
964 #endif
965 }
966 
968 {
969 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2
970  return number_of_batteries();
971 #else
972  return 0;
973 #endif
974 }
975 
976 void robot::readThermometer(unsigned int i_rank, double &o_temp)
977 {
978 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2
979  read_temperature(i_rank, &o_temp);
980 #else
981  o_temp=0;
982 #endif
983 }
984 
986 {
987 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 2
988  return number_of_thermometers();
989 #else
990  return 0;
991 #endif
992 }
993 
994 bool robot::setJointInertia(const char *jname, double mn)
995 {
996 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
997  Link *l = link(jname);
998  if (!l) return false;
999  int jid = l->jointId;
1000  if (jid < 0) return false;
1001  return write_joint_inertia(jid, mn);
1002 #else
1003  return false;
1004 #endif
1005 }
1006 
1007 void robot::setJointInertias(const double *mns)
1008 {
1009 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
1010  write_joint_inertias(mns);
1011 #endif
1012 }
1013 
1014 int robot::readPDControllerTorques(double *o_torques)
1015 {
1016 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
1017  return read_pd_controller_torques(o_torques);
1018 #else
1019  return 0;
1020 #endif
1021 }
1022 
1024 {
1025 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
1026  write_disturbance_observer(ON);
1027 #endif
1028 }
1029 
1031 {
1032 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
1033  write_disturbance_observer(OFF);
1034 #endif
1035 }
1036 
1038 {
1039 #if defined(ROBOT_IOB_VERSION) && ROBOT_IOB_VERSION >= 3
1040  write_disturbance_observer_gain(gain);
1041 #endif
1042 }
1043 
1044 bool robot::setJointControlMode(const char *i_jname, joint_control_mode mode)
1045 {
1046  Link *l = NULL;
1047  if (strcmp(i_jname, "all") == 0 || strcmp(i_jname, "ALL") == 0) {
1048  for (int i=0; i < numJoints(); i++) {
1049  write_control_mode(i, mode);
1050  }
1051  std::cerr << "[RobotHardware] setJointControlMode for all joints : " << mode << std::endl;
1052  } else if ((l = link(i_jname)) && (l->jointId >= 0)) {
1053  write_control_mode(l->jointId, mode);
1054  std::cerr << "[RobotHardware] setJointControlMode for " << i_jname << " : " << mode << std::endl;
1055  } else {
1056  char *s = (char *)i_jname; while(*s) { *s=toupper(*s); s++; }
1057  const std::vector<int> jgroup = m_jointGroups[i_jname];
1058  if (jgroup.size()==0) return false;
1059  for (unsigned int i=0; i<jgroup.size(); i++) {
1060  write_control_mode(jgroup[i], mode);
1061  }
1062  std::cerr << "[RobotHardware] setJointControlMode for " << i_jname << " : " << mode << std::endl;
1063  }
1064  return true;
1065 }
void oneStep()
all processings for one sampling period
unsigned int numSensors(int sensorType) const
int write_dgain(int id, double gain)
write D gain[Nm/(rad/s)]
Definition: iob.cpp:291
int read_servo_state(int id, int *s)
read servo status
Definition: iob.cpp:179
std::vector< double > dgain
void enableDisturbanceObserver()
enable disturbance observer
int read_attitude_sensor(int id, double *att)
read output of attitude sensor
Definition: iob.cpp:330
std::vector< double > m_commandOld
int write_power_command(int id, int com)
turn on/off power supply for motor driver
Definition: iob.cpp:165
int read_command_angle(int id, double *angle)
read command angle[rad]
Definition: iob.cpp:246
void readThermometer(unsigned int i_rank, double &o_temp)
read thermometer
std::vector< double > tqdgain
int set_number_of_gyro_sensors(int num)
set the number of gyro sensors
Definition: iob.cpp:116
int read_dgain(int id, double *gain)
read D gain[Nm/(rad/s)]
Definition: iob.cpp:286
int read_calib_state(int id, int *s)
read callibration state of joint
Definition: iob.cpp:485
bool servo(int jid, bool turnon)
turn on/off joint servo
std::vector< double > old_pgain
#define FALSE
Definition: iob.h:19
void readPowerStatus(double &o_voltage, double &o_current)
read voltage and current of the robot power source
std::string m_calibJointName
state
unsigned int numJoints() const
int read_command_torques(double *torques)
read array of command torques[Nm]
Definition: iob.cpp:236
std::vector< double > pgain
int read_extra_servo_state(int id, int *state)
read extra servo states
Definition: iob.cpp:692
void writeVelocityCommands(const double *i_commands)
write array of reference velocities of joint servo
int numBatteries()
get the number of batteries
bool readDigitalInput(char *o_din)
int write_digital_output_with_mask(const char *doutput, const char *mask)
write_digital_output, non-applicable bits are nop
Definition: iob.cpp:729
double m_accLimit
std::vector< double > gain_counter
void startForceSensorCalibration()
start force sensor calibration and wait until finish
int close_iob(void)
close connection with joint servo process
Definition: iob.cpp:413
double m_servoOnDelay
int read_force_sensor(int id, double *forces)
read output of force sensor
Definition: iob.cpp:296
bool isBusy() const
check if a calibration process is running or not if one of calibration processes is running...
int number_of_accelerometers()
get the number of accelerometers
Definition: iob.cpp:80
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
int readPowerState(int i)
read power status of a joint servo
std::vector< boost::array< double, 6 > > force_sum
std::vector< boost::array< double, 3 > > att_sum
bool checkJointCommands(const double *i_commands)
check joint commands are valid or not
void calibrateForceSensorOneStep()
calibrate force sensor for one sampling period
int read_power(double *voltage, double *current)
read status of power source
Definition: iob.cpp:563
Link * link(int index) const
int readServoState(int i)
read servo status of a joint servo
std::vector< double > old_dgain
int number_of_gyro_sensors()
get the number of gyro sensors
Definition: iob.cpp:75
#define SS_EMERGENCY
Definition: iob.h:51
std::vector< boost::array< double, 3 > > gyro_sum
bool m_calibRequested
std::vector< double > default_pgain
png_uint_32 i
int read_actual_angle(int id, double *angle)
read current joint angle[rad]
Definition: iob.cpp:206
int open_iob(void)
open connection with joint servo process
Definition: iob.cpp:401
bool m_reportedEmergency
Matrix33 localR
int write_control_mode(int id, joint_control_mode s)
write joint control mode
Definition: iob.cpp:200
#define CALIB_COUNT
int length_digital_input()
get_digital_input_length
Definition: iob.cpp:719
int write_gyro_sensor_offset(int id, double *offset)
write offset values for gyro sensor output
Definition: iob.cpp:440
void setJointInertias(const double *i_mn)
set joint inertias
~robot()
destructor
double totalMass() const
int readDriverTemperature(int i)
read temperature of motor driver
size_t length_of_extra_servo_state(int id)
get length of extra servo states
Definition: iob.cpp:687
int length_digital_output()
get_digital_output_length
Definition: iob.cpp:734
Eigen::Vector3d Vector3
Definition: defs.h:7
int read_power_state(int id, int *s)
read power status of motor driver
Definition: iob.cpp:158
Eigen::Matrix3d Matrix33
std::map< std::string, std::vector< int > > m_jointGroups
int read_command_angles(double *angles)
read array of command angles[rad]
Definition: iob.cpp:260
int write_pgain(int id, double gain)
write P gain[Nm/rad]
Definition: iob.cpp:281
int set_number_of_accelerometers(int num)
set the number of accelerometers
Definition: iob.cpp:131
int gettimeofday(struct timeval *tv, struct timezone *tz)
int write_attitude_sensor_offset(int id, double *offset)
Definition: iob.cpp:480
std::string m_pdgainsFilename
Sensor * sensor(int sensorType, int sensorId) const
char * time_string()
const std::string & name()
double m_dt
Definition: Beeper.cpp:24
bool names2ids(const std::vector< std::string > &i_names, std::vector< int > &o_ids)
void setProperty(const char *key, const char *value)
int write_digital_output(const char *doutput)
write_digital_output, non-applicable bits are nop
Definition: iob.cpp:724
void readJointCommands(double *o_commands)
read array of reference angles of joint servo
std::vector< boost::array< double, 3 > > accel_sum
std::vector< double > m_velocityOld
int read_actual_velocities(double *vels)
read actual angular velocities[rad/s]
Definition: iob.cpp:370
int read_gyro_sensor(int id, double *rates)
read output of gyro sensor
Definition: iob.cpp:305
int m_lLegForceSensorId
int number_of_force_sensors()
get the number of force sensors
Definition: iob.cpp:70
emg_reason
reasons of emergency
int number_of_joints()
get the number of joints
Definition: iob.cpp:65
int m_rLegForceSensorId
int read_driver_temperature(int id, unsigned char *v)
read temperature of motor driver[Celsius]
Definition: iob.cpp:649
#define JID_ALL
Definition: iob.h:54
void startInertiaSensorCalibration()
start inertia sensor calibration and wait until finish
void readAccelerometer(unsigned int i_rank, double *o_accs)
read accelerometer output
robot()
constructor
int read_temperature(int id, double *v)
read thermometer
Definition: iob.cpp:385
int readPDControllerTorques(double *o_torques)
read array of all pd controller torques[Nm]
bool checkEmergency(emg_reason &o_reason, int &o_id)
check occurrence of emergency state
int read_accelerometer(int id, double *accels)
read output of accelerometer
Definition: iob.cpp:315
void writeJointCommands(const double *i_commands)
write array of reference angles of joint servo
bool addJointGroup(const char *gname, const std::vector< std::string > &jnames)
bool setJointControlMode(const char *i_jname, joint_control_mode mode)
set control mode of joint
int write_force_offset(int id, double *offsets)
write offset values for force sensor output
Definition: iob.cpp:472
#define M_PI
int readServoAlarm(int i)
read alarm information of a joint servo
int force_calib_counter
std::vector< double > default_dgain
void writeAccelerationCommands(const double *i_commands)
write array of reference accelerations of joint servo
void readJointVelocities(double *o_velocities)
read array of all joint velocities[rad/s]
int numThermometers()
get the number of thermometers
bool writeDigitalOutput(const char *i_dout)
std::string sprintf(char const *__restrict fmt,...)
void readGyroSensor(unsigned int i_rank, double *o_rates)
read gyro sensor output
std::vector< double > m_servoErrorLimit
std::vector< double > tqpgain
joint_control_mode
Definition: iob.h:61
int read_servo_alarm(int id, int *a)
read servo alarms
Definition: iob.cpp:186
int readJointCommandTorques(double *o_torques)
read array of all commanded joint torques[Nm]
int read_digital_output(char *doutput)
read_digital_output, non-applicable bits are nop
Definition: iob.cpp:739
int readCalibState(int i)
read calibration status of a joint servo
bool readDigitalOutput(char *o_dout)
std::vector< double > old_tqpgain
int lengthDigitalOutput()
bool setServoGainPercentage(const char *i_jname, double i_percentage)
set the parcentage to the default servo gain
bool writeDigitalOutputWithMask(const char *i_dout, const char *i_mask)
void readExtraServoState(int id, int *state)
read extra servo states
std::vector< double > default_tqpgain
#define GAIN_COUNT
void setDisturbanceObserverGain(double gain)
set disturbance observer gain
bool setServoErrorLimit(const char *i_jname, double i_limit)
set servo error limit value for specific joint or joint group
JSAMPIMAGE data
std::vector< double > default_tqdgain
int read_digital_input(char *dinput)
read_digital_input, non-applicable bits are nop
Definition: iob.cpp:714
int lengthDigitalInput()
bool loadGain()
load PD gains
int set_number_of_joints(int num)
set the number of joints
Definition: iob.cpp:90
#define DEFAULT_ANGLE_ERROR_LIMIT
void removeForceSensorOffset()
remove offsets on force sensor outputs
bool power(int jid, bool turnon)
turn on/off power for joint servo
static std::vector< double > command
Definition: iob.cpp:8
size_t lengthOfExtraServoState(int id)
get length of extra servo states
int write_servo(int id, int com)
turn on/off joint servo
Definition: iob.cpp:390
int inertia_calib_counter
bool m_enable_poweroff_check
void gain_control()
#define OFF
Definition: iob.h:9
#define ON
Definition: iob.h:8
bool setServoTorqueGainPercentage(const char *i_jname, double i_percentage)
set the parcentage to the default servo torque gain
void readJointAngles(double *o_angles)
read array of all joint angles[rad]
void calibrateInertiaSensorOneStep()
calibrate inertia sensor for one sampling period
void initializeJointAngle(const char *name, const char *option)
initialize joint angle
int set_number_of_force_sensors(int num)
set the number of force sensors
Definition: iob.cpp:101
std::vector< double > old_tqdgain
void readForceSensor(unsigned int i_rank, double *o_forces)
read force sensor output
std::string m_calibOptions
int readJointTorques(double *o_torques)
read array of all joint torques[Nm]
int write_command_velocities(const double *vels)
write command angular velocities[rad/s]
Definition: iob.cpp:380
void writeTorqueCommands(const double *i_commands)
write array of reference torques of joint servo
double m_fzLimitRatio
Link * joint(int id) const
void readBatteryState(unsigned int i_rank, double &o_voltage, double &o_current, double &o_soc)
read battery state
bool setJointInertia(const char *i_jname, double i_mn)
set joint inertia
int write_command_angle(int id, double angle)
write command angle[rad]
Definition: iob.cpp:253
int read_actual_angles(double *angles)
read array of current joint angles[rad]
Definition: iob.cpp:213
int usleep(useconds_t usec)
void disableDisturbanceObserver()
disable disturbance observer
hrp::Vector3 G
int write_command_torques(const double *torques)
write array of command torques[Nm]
Definition: iob.cpp:241
int write_command_angles(const double *angles)
write array of command angles[rad]
Definition: iob.cpp:268
int read_actual_torques(double *torques)
read array of current joint torques[Nm]
Definition: iob.cpp:221
#define DEFAULT_MAX_ZMP_ERROR
#define JID_INVALID
Definition: iob.h:55
int read_pgain(int id, double *gain)
read P gain[Nm/rad]
Definition: iob.cpp:276
int write_accelerometer_offset(int id, double *offset)
write offset values for accelerometer output
Definition: iob.cpp:456


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Sat Dec 17 2022 03:52:21