sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_zmpEstimator.py
Go to the documentation of this file.
1 from time import sleep
2 
3 import matplotlib.pyplot as plt
4 import numpy as np
5 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
6  evalCommandClient,
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_zmpEstimator.py")
19 
20 run_ft_calibration("robot.ftc")
21 input("Wait before running the test")
22 
23 # plug ZMP emergency signal
24 runCommandClient("plug(robot.zmp_estimator.emergencyStop,robot.cm.emergencyStop_zmp)")
25 sleep(2.0)
26 runCommandClient("robot.comTrajGen.move(1,-0.025,1.0)")
27 sleep(20.0)
28 runCommandClient("robot.comTrajGen.startSinusoid(1,0.05,2.0)")
29 sleep(20.0)
30 
31 runCommandClient("dump_tracer(robot.tracer)")
32 
33 # --- DISPLAY
34 zmpEst_data = np.loadtxt(
35  "/tmp/dg_" + evalCommandClient("robot.zmp_estimator.name") + "-zmp.dat"
36 )
37 zmpDyn_data = np.loadtxt(
38  "/tmp/dg_" + evalCommandClient("robot.dynamic.name") + "-zmp.dat"
39 )
40 com_data = np.loadtxt("/tmp/dg_" + evalCommandClient("robot.dynamic.name") + "-com.dat")
41 forceRLEG_data = np.loadtxt(
42  "/tmp/dg_" + evalCommandClient("robot.device.name") + "-forceRLEG.dat"
43 )
44 forceLLEG_data = np.loadtxt(
45  "/tmp/dg_" + evalCommandClient("robot.device.name") + "-forceLLEG.dat"
46 )
47 
48 plt.ion()
49 
50 plt.figure()
51 plt.plot(zmpEst_data[:, 1], "b-")
52 plt.plot(zmpDyn_data[:, 1], "b--")
53 plt.plot(com_data[:, 1], "b:")
54 plt.plot(zmpEst_data[:, 2], "r-")
55 plt.plot(zmpDyn_data[:, 2], "r--")
56 plt.plot(com_data[:, 2], "r:")
57 plt.title("ZMP estimate vs dynamic vs CoM (planar)")
58 plt.legend(["x estimate", "x dynamic", "x CoM", "y estimate", "y dynamic", "y CoM"])
59 
60 plt.figure()
61 plt.plot(com_data[:, 1], "b-")
62 plt.plot(com_data[:, 2], "r-")
63 plt.plot(com_data[:, 3], "g-")
64 plt.title("COM")
65 plt.legend(["x", "y", "z"])
66 
67 plt.figure()
68 plt.plot(zmpDyn_data[:, 1], "b-")
69 plt.plot(zmpDyn_data[:, 2], "r-")
70 plt.plot(zmpDyn_data[:, 3], "g-")
71 plt.title("ZMP dynamic")
72 plt.legend(["x", "y", "z"])
73 
74 plt.figure()
75 plt.plot(zmpEst_data[:, 1], "b-")
76 plt.plot(zmpEst_data[:, 2], "r-")
77 plt.plot(zmpEst_data[:, 3], "g-")
78 plt.title("ZMP estimate")
79 plt.legend(["x", "y", "z"])
80 
81 plt.figure()
82 plt.plot(forceLLEG_data[:, 1], "b-")
83 plt.plot(forceLLEG_data[:, 2], "r-")
84 plt.plot(forceLLEG_data[:, 3], "g-")
85 plt.plot(forceLLEG_data[:, 4], "b--")
86 plt.plot(forceLLEG_data[:, 5], "r--")
87 plt.plot(forceLLEG_data[:, 6], "g--")
88 plt.title("forceLLEG")
89 plt.legend(["fx", "fy", "fz", "tx", "ty", "tz"])
90 
91 plt.figure()
92 plt.plot(forceRLEG_data[:, 1], "b-")
93 plt.plot(forceRLEG_data[:, 2], "r-")
94 plt.plot(forceRLEG_data[:, 3], "g-")
95 plt.plot(forceRLEG_data[:, 4], "b--")
96 plt.plot(forceRLEG_data[:, 5], "r--")
97 plt.plot(forceRLEG_data[:, 6], "g--")
98 plt.title("forceRLEG")
99 plt.legend(["fx", "fy", "fz", "tx", "ty", "tz"])
100 
101 input("Wait before leaving the simulation")
sot_talos_balance.utils.run_test_utils.runCommandClient
runCommandClient
Definition: run_test_utils.py:23
sot_talos_balance.test.test_zmpEstimator.input
input
Definition: test_zmpEstimator.py:14
sot_talos_balance.utils.run_test_utils.evalCommandClient
def evalCommandClient(code)
Definition: run_test_utils.py:49
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