sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcmZmpCopControl.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_dcmZmpCopControl.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.rightAnkleController.gainsXY.value = Kp_ankles")
35 runCommandClient("robot.leftAnkleController.gainsXY.value = Kp_ankles")
36 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
37 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
38 
39 c = ask_for_confirmation("Execute a sinusoid?")
40 if c:
41  print("Putting the robot in position...")
42  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
43  sleep(1.0)
44  print("Robot is in position!")
45 
46  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
47  if c2:
48  print("Executing the sinusoid...")
49  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
50  print("Sinusoid started!")
51  else:
52  print("Not executing the sinusoid")
53 
54  c3 = ask_for_confirmation("Put the robot back?")
55  if c3:
56  print("Stopping the robot...")
57  runCommandClient("robot.comTrajGen.stop(1)")
58  sleep(5.0)
59  print("Putting the robot back...")
60  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
61  sleep(1.0)
62  print("The robot is back in position!")
63  else:
64  print("Not putting the robot back")
65 else:
66  print("Not executing the sinusoid")
67 
68 c = ask_for_confirmation("Raise the foot?")
69 if c:
70  print("Putting the robot in position...")
71  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
72  runCommandClient("robot.rhoTrajGen.move(0,0.4,10.0)")
73  sleep(10.0)
74  print("Robot is in position!")
75 
76  c2 = ask_for_confirmation("Confirm raising the foot?")
77  if c2:
78  print("Raising the foot...")
79  runCommandClient("robot.distribute.phase.value = -1")
80  runCommandClient("h = robot.dynamic.LF.value[2][3]")
81  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
82  sleep(10.0)
83  print("Foot has been raised!")
84  c3 = ask_for_confirmation("Put the foot back?")
85  else:
86  print("Not raising the foot")
87  c3 = False
88 
89  if c3:
90  print("Putting the foot back...")
91  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
92  sleep(10.0)
93  runCommandClient("robot.distribute.phase.value = 0")
94  print("The foot is back in position!")
95  else:
96  print("Not putting the foot back")
97 
98  if c3 or not c2:
99  c4 = ask_for_confirmation("Put the robot back?")
100  else:
101  c4 = False
102 
103  if c4:
104  print("Putting the robot back...")
105  runCommandClient("robot.comTrajGen.move(1,0.0,10.0)")
106  runCommandClient("robot.rhoTrajGen.move(0,0.5,10.0)")
107  sleep(10.0)
108  print("The robot is back in position!")
109 else:
110  print("Not raising the foot")
111 
112 # raw_input("Wait before dumping the data")
113 
114 # runCommandClient('dump_tracer(robot.tracer)')
def run_ft_calibration(sensor_name, force=False)
def run_test(appli, verbosity=1, interactive=True)