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