sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_dcmZmpControl_distribute.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_dcmZmpControl_distribute.py")
19 
20 run_ft_calibration("robot.ftc")
21 
22 use_force_distribution = ask_for_confirmation("Use output of force distribution?")
23 if use_force_distribution:
24  print("Using output of force distribution")
25 else:
26  print("Not using output of force distribution")
27 
28 input("Wait before running the test")
29 
30 # Connect ZMP reference and reset controllers
31 print("Connect ZMP reference")
32 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
33 if use_force_distribution:
35  "plug(robot.distribute.emergencyStop,robot.cm.emergencyStop_distribute)"
36  )
38  "plug(robot.distribute.zmpRef,robot.com_admittance_control.zmpDes)"
39  )
40 else:
42  "plug(robot.dcm_control.zmpRef,robot.com_admittance_control.zmpDes)"
43  )
45  "robot.com_admittance_control.setState(robot.wp.comDes.value,[0.0,0.0,0.0])"
46 )
47 runCommandClient("robot.com_admittance_control.Kp.value = Kp_adm")
48 runCommandClient("robot.dcm_control.resetDcmIntegralError()")
49 runCommandClient("robot.dcm_control.Ki.value = Ki_dcm")
50 
51 c = ask_for_confirmation("Execute a sinusoid?")
52 if c:
53  print("Putting the robot in position...")
54  runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
55  sleep(1.0)
56  print("Robot is in position!")
57 
58  c2 = ask_for_confirmation("Confirm executing the sinusoid?")
59  if c2:
60  print("Executing the sinusoid...")
61  runCommandClient("robot.comTrajGen.startSinusoid(1,0.025,2.0)")
62  print("Sinusoid started!")
63  else:
64  print("Not executing the sinusoid")
65 
66  c3 = ask_for_confirmation("Put the robot back?")
67  if c3:
68  print("Stopping the robot...")
69  runCommandClient("robot.comTrajGen.stop(1)")
70  sleep(5.0)
71  print("Putting the robot back...")
72  runCommandClient("robot.comTrajGen.move(1,0.0,1.0)")
73  sleep(1.0)
74  print("The robot is back in position!")
75  else:
76  print("Not putting the robot back")
77 else:
78  print("Not executing the sinusoid")
79 
80 c = ask_for_confirmation("Raise the foot?")
81 if c:
82  print("Putting the robot in position...")
83  runCommandClient("robot.comTrajGen.move(1,-0.08,10.0)")
84  runCommandClient("robot.rhoTrajGen.move(0,0.4,10.0)")
85  sleep(10.0)
86  print("Robot is in position!")
87 
88  c2 = ask_for_confirmation("Confirm raising the foot?")
89  if c2:
90  print("Raising the foot...")
91  runCommandClient("robot.phaseTrajGen.set(0,-1)")
92  runCommandClient("h = robot.dynamic.LF.value[2][3]")
93  runCommandClient("robot.lfTrajGen.move(2,h+0.05,10.0)")
94  sleep(10.0)
95  print("Foot has been raised!")
96  c3 = ask_for_confirmation("Put the foot back?")
97  else:
98  print("Not raising the foot")
99  c3 = False
100 
101  if c3:
102  print("Putting the foot back...")
103  runCommandClient("robot.lfTrajGen.move(2,h,10.0)")
104  sleep(10.0)
105  runCommandClient("robot.phaseTrajGen.set(0,0)")
106  print("The foot is back in position!")
107  c4 = ask_for_confirmation("Put the robot back?")
108  else:
109  print("Not putting the foot back")
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)")
def run_ft_calibration(sensor_name, force=False)
def run_test(appli, verbosity=1, interactive=True)