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 from sys import argv
3 from time import sleep
4 
5 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
6  ask_for_confirmation,
7  get_file_folder,
8  run_ft_calibration,
9  run_test,
10  runCommandClient,
11 )
12 
13 try:
14  # Python 2
15  input = raw_input # noqa
16 except NameError:
17  pass
18 
19 test_folder, sot_talos_balance_folder = get_file_folder(argv)
20 
21 flexi = ask_for_confirmation("Compensate flexibility?")
22 if flexi:
23  print("Compensating flexibility")
24  runCommandClient("flexi = False")
25 else:
26  print("Not compensating flexibility")
27  runCommandClient("flexi = False")
28 
29 run_test("appli_dcm_zmp_control_flex.py")
30 
31 run_ft_calibration("robot.ftc")
32 
33 if flexi:
34  input("Wait before activating flexibility")
35  cmd_l = "robot.hipComp.K_l.value = hipFlexCompConfig.flexibility_left"
36  cmd_r = "robot.hipComp.K_r.value = hipFlexCompConfig.flexibility_right"
37  runCommandClient(cmd_l + "; " + cmd_r)
38 
39 input("Wait before running the test")
40 
41 # Connect ZMP reference and reset controllers
42 print("Connect ZMP reference")
43 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
44 runCommandClient("plug(robot.dcm_control.zmpRef,robot.com_admittance_control.zmpDes)")
46  "robot.com_admittance_control.setState(robot.wp.comDes.value,[0.0,0.0,0.0])"
47 )
48 runCommandClient("robot.com_admittance_control.Kp.value = Kp_adm")
49 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
50 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
51 runCommandClient("robot.dcm_control.Kz.value = Kz_dcm")
52 
53 if test_folder is not None:
54  c = ask_for_confirmation("Execute trajectory?")
55  if c:
56  print("Executing the trajectory")
57  runCommandClient("set_trigger(robot, True)")
58  else:
59  print("Not executing the trajectory")
60 else:
61  c = ask_for_confirmation("Execute a sinusoid?")
62  if c:
63  print("Putting the robot in position...")
64  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
65  sleep(1.0)
66  print("Robot is in position!")
67 
68  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
69  if c2:
70  print("Executing the sinusoid...")
71  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
72  print("Sinusoid started!")
73  else:
74  print("Not executing the sinusoid")
75 
76  c3 = ask_for_confirmation("Put the robot back?")
77  if c3:
78  print("Stopping the robot...")
79  runCommandClient("robot.comTrajGen.stop(1)")
80  sleep(5.0)
81  print("Putting the robot back...")
82  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
83  sleep(1.0)
84  print("The robot is back in position!")
85  else:
86  print("Not putting the robot back")
87  else:
88  print("Not executing the sinusoid")
89 
90  c = ask_for_confirmation("Raise the foot?")
91  if c:
92  print("Putting the robot in position...")
93  runCommandClient("robot.comTrajGen.move(1,-0.08,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  sleep(10.0)
127  print("The robot is back in position!")
128  else:
129  print("Not putting the robot back")
130  else:
131  print("Not raising the foot")
132 
133 input("Wait before dumping the data")
134 
135 runCommandClient("dump_tracer(robot.tracer)")
136 
137 print("Bye!")
sot_talos_balance.utils.run_test_utils.get_file_folder
def get_file_folder(argv, send=True)
Definition: run_test_utils.py:152
sot_talos_balance.utils.run_test_utils.runCommandClient
runCommandClient
Definition: run_test_utils.py:23
sot_talos_balance.utils.run_test_utils.ask_for_confirmation
def ask_for_confirmation(text)
Definition: run_test_utils.py:110
sot_talos_balance.test.test_dcm_zmp_control_flex.input
input
Definition: test_dcm_zmp_control_flex.py:15
sot_talos_balance.utils.run_test_utils.run_ft_calibration
def run_ft_calibration(sensor_name, force=False)
Definition: run_test_utils.py:118
sot_talos_balance.utils.run_test_utils.run_test
def run_test(appli, verbosity=1, interactive=True)
Definition: run_test_utils.py:83