samplespecialjointrobot_auto_balancer.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 try:
4  from hrpsys.hrpsys_config import *
5  import OpenHRP
6 except:
7  print "import without hrpsys"
8  import rtm
9  from rtm import *
10  from OpenHRP import *
11  import waitInput
12  from waitInput import *
13  import socket
14  import time
15 
16 import math
17 
18 def init ():
19  global hcf, initial_pose, hrpsys_version
20  hcf = HrpsysConfigurator()
21  hcf.getRTCList = hcf.getRTCListUnstable
22  hcf.init ("SampleSpecialJointRobot(Robot)0", "$(PROJECT_DIR)/../model/sample_special_joint_robot.wrl")
23  initial_pose = [0.0, -0.20944, -0.20944, 0.0, 0.523599, 0.523599, -0.314159, -0.314159, 0.0, 0.0,
24  0.0, -0.20944, -0.20944, 0.0, 0.523599, 0.523599, -0.314159, -0.314159, 0.0, 0.0,
25  0.0, 0.0, 0.0]
26  hcf.seq_svc.setJointAngles(initial_pose, 2.0)
27  hcf.waitInterpolation()
28  hcf.startAutoBalancer()
29  hrpsys_version = hcf.seq.ref.get_component_profile().version
30  print("hrpsys_version = %s"%hrpsys_version)
31 
33  rpy = rtm.readDataPort(hcf.rh.port("WAIST")).data.orientation
34  ret = math.degrees(rpy.r) < 0.1 and math.degrees(rpy.p) < 0.1
35  print >> sys.stderr, " actual base rpy = ", ret, "(", rpy, ")"
36  assert (ret)
37  return ret
38 
40  print >> sys.stderr, "1. Do not use toe heel contact"
41  hcf.abc_svc.goPos(0.3, 0, 0);
42  hcf.abc_svc.waitFootSteps()
44  print >> sys.stderr, " No toe heel contact=>OK"
45 
47  print >> sys.stderr, "2. Use toe heel contact"
48  ggp=hcf.abc_svc.getGaitGeneratorParam()[1];
49  ggp.toe_pos_offset_x = 1e-3*182.0;
50  ggp.heel_pos_offset_x = 1e-3*-72.0;
51  ggp.toe_zmp_offset_x = 1e-3*182.0;
52  ggp.heel_zmp_offset_x = 1e-3*-72.0;
53  ggp.toe_angle = 35;
54  ggp.heel_angle = 10;
55  ggp.use_toe_joint = False;
56  hcf.abc_svc.setGaitGeneratorParam(ggp);
57  hcf.abc_svc.goPos(0.3, 0, 0);
58  hcf.abc_svc.waitFootSteps()
59  ggp.toe_angle = 0;
60  ggp.heel_angle = 0;
61  hcf.abc_svc.setGaitGeneratorParam(ggp);
63  print >> sys.stderr, " Toe heel contact=>OK"
64 
66  print >> sys.stderr, "3. Use toe heel contact with toe joint"
67  ggp=hcf.abc_svc.getGaitGeneratorParam()[1];
68  ggp.toe_pos_offset_x = 1e-3*182.0;
69  ggp.heel_pos_offset_x = 1e-3*-72.0;
70  ggp.toe_zmp_offset_x = 1e-3*182.0;
71  ggp.heel_zmp_offset_x = 1e-3*-72.0;
72  ggp.toe_angle = 35;
73  ggp.heel_angle = 10;
74  ggp.use_toe_joint = True;
75  hcf.abc_svc.setGaitGeneratorParam(ggp);
76  hcf.abc_svc.goPos(0.3, 0, 0);
77  hcf.abc_svc.waitFootSteps()
78  ggp.toe_angle = 0;
79  ggp.heel_angle = 0;
80  hcf.abc_svc.setGaitGeneratorParam(ggp);
82  print >> sys.stderr, " Toe heel contact with toe joint =>OK"
83 
84 
85 def demo():
86  init()
90 
91 if __name__ == '__main__':
92  demo()
def readDataPort(port, timeout=1.0)
read data from a data port
Definition: jython/rtm.py:574


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51