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