samplerobot_terrain_walk.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 def init ():
17  global hcf
18  hcf = HrpsysConfigurator()
19  hcf.getRTCList = hcf.getRTCListUnstable
20  hcf.init ("SampleRobot(Robot)0", "$(PROJECT_DIR)/../model/sample1.wrl")
21 
22 def initPose():
23  # set initial pose from base 90mm down pose of sample/controller/SampleController/etc/Sample.pos
24  initial_pose=[-0.000181,-0.614916,-0.000239,1.36542,-0.749643,0.000288,0.31129,-0.159481,-0.115399,-0.636277,0.0,0.0,0.0,-0.000181,-0.614916,-0.000239,1.36542,-0.749643,0.000288,0.31129,0.159481,0.115399,-0.636277,0.0,0.0,0.0,0.0,0.0,0.0]
25  hcf.seq_svc.setJointAngles(initial_pose, 1.0)
26  hcf.seq_svc.waitInterpolation()
27  hcf.startAutoBalancer();
28 
29 def demo():
30  init()
31  initPose()
32 
33 def setupGaitGeneratorParam(set_step_height=False):
34  ggp = hcf.abc_svc.getGaitGeneratorParam()
35  ggp[1].default_double_support_ratio = 0.3
36  ggp[1].default_step_time = 1.2
37  if set_step_height:
38  ggp[1].default_step_height = 0.1
39  #ggp[1].swing_trajectory_delay_time_offset = 0.2;
40  ggp[1].default_orbit_type = OpenHRP.AutoBalancerService.STAIR;
41  hcf.abc_svc.setGaitGeneratorParam(ggp[1])
42 
43 def stairWalk(stair_height = 0.1524):
44  stair_stride_x = 0.25
45  floor_stride_x = 0.16
46  init_step_x = 0
47  init_step_z = 0
48  ret = []
50  for step_idx in [1,2,3,4]:
51  ret = ret + [OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([init_step_x, -0.09, init_step_z], [1,0,0,0], "rleg")]),
52  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([init_step_x+stair_stride_x, 0.09, init_step_z+stair_height], [1,0,0,0], "lleg")]),
53  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([init_step_x+stair_stride_x, -0.09, init_step_z+stair_height], [1,0,0,0], "rleg")]),
54  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([init_step_x+stair_stride_x+floor_stride_x, 0.09, init_step_z+stair_height], [1,0,0,0], "lleg")])]
55  init_step_x = init_step_x + stair_stride_x + floor_stride_x
56  init_step_z = init_step_z + stair_height
57  hcf.setFootSteps(ret)
58  hcf.abc_svc.waitFootSteps()
59 
60 # sample for SampleRobot.TerrainFloor.SlopeUpDown.xml
62  print "Start stlop up down"
64  hcf.abc_svc.startAutoBalancer(["rleg", "lleg"]);
65  fsList=[OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([0.8,-0.09,0.0], [1.0,0.0,2.775558e-17,0.0], "rleg")]),
66  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.0953,0.09,0.030712], [0.991445,0.0,-0.130526,0.0], "lleg")]),
67  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.28848,-0.09,0.082475], [0.991445,0.0,-0.130526,0.0], "rleg")]),
68  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.38508,0.09,0.108357], [0.991445,0.0,-0.130526,0.0], "lleg")]),
69  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.38508,-0.09,0.108357], [0.991445,0.0,-0.130526,0.0], "rleg")]),
70  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.54959,0.09,0.125863], [0.991445,0.0,0.130526,0.0], "lleg")]),
71  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.74277,-0.09,0.074099], [0.991445,0.0,0.130526,0.0], "rleg")]),
72  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([1.79107,0.09,0.061158], [0.991445,0.0,0.130526,0.0], "lleg")]),
73  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([2.05,-0.09,0.0], [1.0,0.0,0.0,0.0], "rleg")]),
74  OpenHRP.AutoBalancerService.Footsteps([OpenHRP.AutoBalancerService.Footstep([2.05,0.09,0.0], [1.0,0.0,0.0,0.0], "lleg")])]
75  # set st Parameter
76  # stp1 = hcf.st_svc.getParameter()
77  # stp1.k_tpcc_p=[0.05, 0.05]
78  # stp1.k_tpcc_x=[4.0, 4.0]
79  # stp1.k_brot_p=[0.0, 0.0]
80  # hcf.st_svc.setParameter(stp1)
81  # hcf.st_svc.startStabilizer ()
82  for idx in range(len(fsList)-1):
83  hcf.setFootSteps([fsList[idx],fsList[idx+1]])
84  hcf.abc_svc.waitFootSteps()
85  hcf.abc_svc.stopAutoBalancer();
86 
87 # sample for SampleRobot.TerrainFloor.StairUp.xml
89  print "Start stair up"
90  stairWalk()
91 
92 # sample for SampleRobot.TerrainFloor.StairDown.xml
94  print "Start stair down"
95  hcf.abc_svc.goPos(0.05, 0.0, 0.0)
96  hcf.abc_svc.waitFootSteps()
97  stairWalk(-0.1524)
98 
100  print "Start stair up"
101  stairWalk()
102  hcf.abc_svc.goPos(0.05, 0.0, 0.0)
103  hcf.abc_svc.waitFootSteps()
104  print "Start stair down"
105  stairWalk(-0.1524)
106 
107 if __name__ == '__main__':
108  demo()
def stairWalk(stair_height=0.1524)
def setupGaitGeneratorParam(set_step_height=False)


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