sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcm_zmp_control_distribute.py
Go to the documentation of this file.
1 """Test CoM admittance control as described in paper"""
2 
3 from sys import argv
4 from time import sleep
5 
6 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
7  ask_for_confirmation,
8  get_file_folder,
9  run_ft_calibration,
10  run_test,
11  runCommandClient,
12 )
13 
14 try:
15  # Python 2
16  input = raw_input # noqa
17 except NameError:
18  pass
19 
20 test_folder, sot_talos_balance_folder = get_file_folder(argv)
21 
22 use_distribute = ask_for_confirmation("Use output of force distribution?")
23 print(("Using" if use_distribute else "Not using") + " output of force distribution")
24 
25 run_test("appli_dcm_zmp_control_distribute.py")
26 
27 run_ft_calibration("robot.ftc")
28 input("Wait before running the test")
29 
30 # Connect ZMP reference and reset controllers
31 print("Connect ZMP reference")
32 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
33 if use_distribute:
35  "plug(robot.distribute.emergencyStop,robot.cm.emergencyStop_distribute)"
36  )
38  "plug(robot.distribute.zmpRef,robot.com_admittance_control.zmpDes)"
39  )
40 else:
42  "plug(robot.dcm_control.zmpRef,robot.com_admittance_control.zmpDes)"
43  )
45  "robot.com_admittance_control.setState(robot.wp.comDes.value,[0.0,0.0,0.0])"
46 )
47 runCommandClient("robot.com_admittance_control.Kp.value = Kp_adm")
48 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
49 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
50 runCommandClient("robot.dcm_control.Kz.value = Kz_dcm")
51 
52 if test_folder is not None:
53  c = ask_for_confirmation("Execute trajectory?")
54  if c:
55  print("Executing the trajectory")
56  runCommandClient("robot.triggerTrajGen.sin.value = 1")
57  else:
58  print("Not executing the trajectory")
59 else:
60  c = ask_for_confirmation("Execute a sinusoid?")
61  if c:
62  print("Putting the robot in position...")
63  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
64  sleep(1.0)
65  print("Robot is in position!")
66 
67  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
68  if c2:
69  print("Executing the sinusoid...")
70  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
71  print("Sinusoid started!")
72  else:
73  print("Not executing the sinusoid")
74 
75  c3 = ask_for_confirmation("Put the robot back?")
76  if c3:
77  print("Stopping the robot...")
78  runCommandClient("robot.comTrajGen.stop(1)")
79  sleep(5.0)
80  print("Putting the robot back...")
81  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
82  sleep(1.0)
83  print("The robot is back in position!")
84  else:
85  print("Not putting the robot back")
86  else:
87  print("Not executing the sinusoid")
88 
89  c = ask_for_confirmation("Raise the foot?")
90  if c:
91  print("Putting the robot in position...")
92  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
93  runCommandClient("robot.rhoTrajGen.move(0,0.4,10.0)")
94  sleep(10.0)
95  print("Robot is in position!")
96 
97  foot_on_ground = True
98 
99  c2 = ask_for_confirmation("Confirm raising the foot?")
100  if c2:
101  print("Raising the foot...")
102  runCommandClient("robot.phaseTrajGen.set(0,-1)")
103  runCommandClient("h = robot.dynamic.LF.value[2][3]")
104  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
105  sleep(10.0)
106  print("Foot has been raised!")
107  foot_on_ground = False
108  c3 = ask_for_confirmation("Put the foot back?")
109  if c3:
110  print("Putting the foot back...")
111  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
112  sleep(10.0)
113  runCommandClient("robot.phaseTrajGen.set(0,0)")
114  print("The foot is back in position!")
115  foot_on_ground = True
116  else:
117  print("Not putting the foot back")
118  else:
119  print("Not raising the foot")
120 
121  if foot_on_ground:
122  c4 = ask_for_confirmation("Put the robot back?")
123  if c4:
124  print("Putting the robot back...")
125  runCommandClient("robot.comTrajGen.move(1,0.0,10.0)")
126  runCommandClient("robot.rhoTrajGen.move(0,0.5,10.0)")
127  sleep(10.0)
128  print("The robot is back in position!")
129  else:
130  print("Not putting the robot back")
131  else:
132  print("Not raising the foot")
133 
134 # input("Wait before dumping the data")
135 
136 # runCommandClient('dump_tracer(robot.tracer)')
137 
138 print("Bye!")
def run_ft_calibration(sensor_name, force=False)
def run_test(appli, verbosity=1, interactive=True)