sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcmZmpFootControl.py
Go to the documentation of this file.
1 """Test CoM admittance control as described in paper."""
2 
3 from time import sleep
4 
5 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
6  ask_for_confirmation,
7  run_ft_calibration,
8  run_test,
9  runCommandClient,
10 )
11 
12 try:
13  # Python 2
14  input = raw_input # noqa
15 except NameError:
16  pass
17 
18 run_test("appli_dcmZmpFootControl.py")
19 
20 run_ft_calibration("robot.ftc")
21 input("Wait before running the test")
22 
23 # Connect ZMP reference and reset controllers
24 print("Set controller")
25 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
27  "plug(robot.distribute.emergencyStop,robot.cm.emergencyStop_distribute)"
28 )
29 runCommandClient("plug(robot.distribute.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 
37 input("Wait before activating foot force difference control")
38 runCommandClient("robot.ffdc.dfzAdmittance.value = dfzAdmittance")
39 runCommandClient("robot.ffdc.vdcFrequency.value = vdcFrequency")
40 runCommandClient("robot.ffdc.vdcDamping.value = vdcDamping")
41 
42 c = ask_for_confirmation("Execute a sinusoid?")
43 if c:
44  print("Putting the robot in position...")
45  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
46  sleep(1.0)
47  print("Robot is in position!")
48 
49  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
50  if c2:
51  print("Executing the sinusoid...")
52  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
53  print("Sinusoid started!")
54  else:
55  print("Not executing the sinusoid")
56 
57  c3 = ask_for_confirmation("Put the robot back?")
58  if c3:
59  print("Stopping the robot...")
60  runCommandClient("robot.comTrajGen.stop(1)")
61  sleep(5.0)
62  print("Putting the robot back...")
63  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
64  sleep(1.0)
65  print("The robot is back in position!")
66  else:
67  print("Not putting the robot back")
68 else:
69  print("Not executing the sinusoid")
70 
71 c = ask_for_confirmation("Raise the foot?")
72 if c:
73  print("Putting the robot in position...")
74  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
75  runCommandClient("robot.rhoTrajGen.move(0,0.4,10.0)")
76  sleep(10.0)
77  print("Robot is in position!")
78 
79  c2 = ask_for_confirmation("Confirm raising the foot?")
80  if c2:
81  print("Raising the foot...")
82  runCommandClient("robot.phaseTrajGen.set(0,-1)")
83  runCommandClient("h = robot.dynamic.LF.value[2][3]")
84  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
85  runCommandClient("robot.contactLF.gain.setConstant(300)")
86  sleep(10.0)
87  print("Foot has been raised!")
88  c3 = ask_for_confirmation("Put the foot back?")
89  else:
90  print("Not raising the foot")
91  c3 = False
92 
93  if c3:
94  print("Putting the foot back...")
95  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
96  sleep(10.0)
97  runCommandClient("robot.contactLF.gain.setConstant(1)")
98  runCommandClient("robot.phaseTrajGen.set(0,0)")
99  print("The foot is back in position!")
100  else:
101  print("Not putting the foot back")
102 
103  if c3 or not c2:
104  c4 = ask_for_confirmation("Put the robot back?")
105  else:
106  c4 = False
107 
108  if c4:
109  print("Putting the robot back...")
110  runCommandClient("robot.comTrajGen.move(1,0.0,10.0)")
111  runCommandClient("robot.rhoTrajGen.move(0,0.5,10.0)")
112  sleep(10.0)
113  print("The robot is back in position!")
114 else:
115  print("Not raising the foot")
116 
117 # input("Wait before dumping the data")
118 
119 # runCommandClient('dump_tracer(robot.tracer)')
def run_ft_calibration(sensor_name, force=False)
def run_test(appli, verbosity=1, interactive=True)