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