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