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