sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcm_zmp_control_flex.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 flexi = ask_for_confirmation("Compensate flexibility?")
23 if flexi:
24  print("Compensating flexibility")
25  runCommandClient("flexi = False")
26 else:
27  print("Not compensating flexibility")
28  runCommandClient("flexi = False")
29 
30 run_test("appli_dcm_zmp_control_flex.py")
31 
32 run_ft_calibration("robot.ftc")
33 
34 if flexi:
35  input("Wait before activating flexibility")
36  cmd_l = "robot.hipComp.K_l.value = hipFlexCompConfig.flexibility_left"
37  cmd_r = "robot.hipComp.K_r.value = hipFlexCompConfig.flexibility_right"
38  runCommandClient(cmd_l + "; " + cmd_r)
39 
40 input("Wait before running the test")
41 
42 # Connect ZMP reference and reset controllers
43 print("Connect ZMP reference")
44 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
45 runCommandClient("plug(robot.dcm_control.zmpRef,robot.com_admittance_control.zmpDes)")
47  "robot.com_admittance_control.setState(robot.wp.comDes.value,[0.0,0.0,0.0])"
48 )
49 runCommandClient("robot.com_admittance_control.Kp.value = Kp_adm")
50 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
51 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
52 runCommandClient("robot.dcm_control.Kz.value = Kz_dcm")
53 
54 if test_folder is not None:
55  c = ask_for_confirmation("Execute trajectory?")
56  if c:
57  print("Executing the trajectory")
58  runCommandClient("set_trigger(robot, True)")
59  else:
60  print("Not executing the trajectory")
61 else:
62  c = ask_for_confirmation("Execute a sinusoid?")
63  if c:
64  print("Putting the robot in position...")
65  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
66  sleep(1.0)
67  print("Robot is in position!")
68 
69  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
70  if c2:
71  print("Executing the sinusoid...")
72  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
73  print("Sinusoid started!")
74  else:
75  print("Not executing the sinusoid")
76 
77  c3 = ask_for_confirmation("Put the robot back?")
78  if c3:
79  print("Stopping the robot...")
80  runCommandClient("robot.comTrajGen.stop(1)")
81  sleep(5.0)
82  print("Putting the robot back...")
83  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
84  sleep(1.0)
85  print("The robot is back in position!")
86  else:
87  print("Not putting the robot back")
88  else:
89  print("Not executing the sinusoid")
90 
91  c = ask_for_confirmation("Raise the foot?")
92  if c:
93  print("Putting the robot in position...")
94  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
95  sleep(10.0)
96  print("Robot is in position!")
97 
98  foot_on_ground = True
99 
100  c2 = ask_for_confirmation("Confirm raising the foot?")
101  if c2:
102  print("Raising the foot...")
103  runCommandClient("robot.phaseTrajGen.set(0,-1)")
104  runCommandClient("h = robot.dynamic.LF.value[2][3]")
105  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
106  sleep(10.0)
107  print("Foot has been raised!")
108  foot_on_ground = False
109  c3 = ask_for_confirmation("Put the foot back?")
110  if c3:
111  print("Putting the foot back...")
112  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
113  sleep(10.0)
114  runCommandClient("robot.phaseTrajGen.set(0,0)")
115  print("The foot is back in position!")
116  foot_on_ground = True
117  else:
118  print("Not putting the foot back")
119  else:
120  print("Not raising the foot")
121 
122  if foot_on_ground:
123  c4 = ask_for_confirmation("Put the robot back?")
124  if c4:
125  print("Putting the robot back...")
126  runCommandClient("robot.comTrajGen.move(1,0.0,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)