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 
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_dcmAnkleControl.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)")
26 # runCommandClient('robot.distribute.phase.value = -1')
28  "plug(robot.distribute.emergencyStop,robot.cm.emergencyStop_distribute)"
29 )
30 runCommandClient("robot.rightRollAnkleController.Kp.value = KpRoll")
31 runCommandClient("robot.rightPitchAnkleController.Kp.value = KpPitch")
32 runCommandClient("robot.leftRollAnkleController.Kp.value = KpRoll")
33 runCommandClient("robot.leftPitchAnkleController.Kp.value = KpPitch")
34 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
35 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
36 
37 c = ask_for_confirmation("Execute a sinusoid?")
38 if c:
39  print("Putting the robot in position...")
40  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
41  sleep(1.0)
42  print("Robot is in position!")
43 
44  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
45  if c2:
46  print("Executing the sinusoid...")
47  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
48  print("Sinusoid started!")
49  else:
50  print("Not executing the sinusoid")
51 
52  c3 = ask_for_confirmation("Put the robot back?")
53  if c3:
54  print("Stopping the robot...")
55  runCommandClient("robot.comTrajGen.stop(1)")
56  sleep(5.0)
57  print("Putting the robot back...")
58  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
59  sleep(1.0)
60  print("The robot is back in position!")
61  else:
62  print("Not putting the robot back")
63 else:
64  print("Not executing the sinusoid")
65 
66 c = ask_for_confirmation("Raise the foot?")
67 if c:
68  print("Putting the robot in position...")
69  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
70  runCommandClient("robot.rhoTrajGen.move(0,0.4,10.0)")
71  sleep(10.0)
72  print("Robot is in position!")
73 
74  c2 = ask_for_confirmation("Confirm raising the foot?")
75  if c2:
76  print("Raising the foot...")
78  'robot.leftAnklePitchTask.task.controlSelec.value="0"*robot.sot.getSize()'
79  )
81  'robot.leftAnkleRollTask.task.controlSelec.value="0"*robot.sot.getSize()'
82  )
83  runCommandClient("robot.distribute.phase.value = -1")
84  runCommandClient("h = robot.dynamic.LF.value[2][3]")
85  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
86  sleep(10.0)
87  print("Foot has been raised!")
88  c3 = ask_for_confirmation("Put the foot back?")
89  else:
90  print("Not raising the foot")
91  c3 = False
92 
93  if c3:
94  print("Putting the foot back...")
95  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
96  sleep(10.0)
97  runCommandClient("robot.distribute.phase.value = 0")
99  'robot.leftAnklePitchTask.task.controlSelec.value="1"*robot.sot.getSize()'
100  )
102  'robot.leftAnkleRollTask.task.controlSelec.value="1"*robot.sot.getSize()'
103  )
104  print("The foot is back in position!")
105  else:
106  print("Not putting the foot back")
107 
108  if c3 or not c2:
109  c4 = ask_for_confirmation("Put the robot back?")
110  else:
111  c4 = False
112 
113  if c4:
114  print("Putting the robot back...")
115  runCommandClient("robot.comTrajGen.move(1,0.0,10.0)")
116  runCommandClient("robot.rhoTrajGen.move(0,0.5,10.0)")
117  sleep(10.0)
118  print("The robot is back in position!")
119 else:
120  print("Not raising the foot")
121 
122 # input("Wait before dumping the data")
123 
124 # runCommandClient('dump_tracer(robot.tracer)')
def run_ft_calibration(sensor_name, force=False)
def run_test(appli, verbosity=1, interactive=True)