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