sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcmAnkleControl.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_dcmAnkleControl.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.rightRollAnkleController.Kp.value = KpRoll")
30 runCommandClient("robot.rightPitchAnkleController.Kp.value = KpPitch")
31 runCommandClient("robot.leftRollAnkleController.Kp.value = KpRoll")
32 runCommandClient("robot.leftPitchAnkleController.Kp.value = KpPitch")
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...")
77  'robot.leftAnklePitchTask.task.controlSelec.value="0"*robot.sot.getSize()'
78  )
80  'robot.leftAnkleRollTask.task.controlSelec.value="0"*robot.sot.getSize()'
81  )
82  runCommandClient("robot.distribute.phase.value = -1")
83  runCommandClient("h = robot.dynamic.LF.value[2][3]")
84  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
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.distribute.phase.value = 0")
98  'robot.leftAnklePitchTask.task.controlSelec.value="1"*robot.sot.getSize()'
99  )
101  'robot.leftAnkleRollTask.task.controlSelec.value="1"*robot.sot.getSize()'
102  )
103  print("The foot is back in position!")
104  else:
105  print("Not putting the foot back")
106 
107  if c3 or not c2:
108  c4 = ask_for_confirmation("Put the robot back?")
109  else:
110  c4 = False
111 
112  if c4:
113  print("Putting the robot back...")
114  runCommandClient("robot.comTrajGen.move(1,0.0,10.0)")
115  runCommandClient("robot.rhoTrajGen.move(0,0.5,10.0)")
116  sleep(10.0)
117  print("The robot is back in position!")
118 else:
119  print("Not raising the foot")
120 
121 # input("Wait before dumping the data")
122 
123 # 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_dcmAnkleControl.input
input
Definition: test_dcmAnkleControl.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