sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_ffSubscriber.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 
6 from dynamic_graph.sot_talos_balance.utils.gazebo_utils import GazeboLinkStatePublisher
7 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
8  evalCommandClient,
9  run_test,
10  runCommandClient,
11 )
12 
13 try:
14  # Python 2
15  input = raw_input # noqa
16 except NameError:
17  pass
18 
19 pub = GazeboLinkStatePublisher("base_link", 1000)
20 print("Starting Gazebo link state publisher...")
21 pub.start()
22 print("Gazebo link state publisher started")
23 input("Wait before running the test")
24 
25 run_test("appli_ffSubscriber.py")
26 
27 sleep(2.0)
28 runCommandClient("robot.comTrajGen.move(1,-0.025,4.0)")
29 sleep(5.0)
30 runCommandClient("robot.comTrajGen.startSinusoid(1,0.05,8.0)")
31 sleep(5.0)
32 runCommandClient("dump_tracer(robot.tracer)")
33 
34 # --- DISPLAY
35 com_data = np.loadtxt("/tmp/dg_" + evalCommandClient("robot.dynamic.name") + "-com.dat")
36 pos_data = np.loadtxt(
37  "/tmp/dg_" + evalCommandClient("robot.subscriber.name") + "-position.dat"
38 )
39 vel_data = np.loadtxt(
40  "/tmp/dg_" + evalCommandClient("robot.subscriber.name") + "-velocity.dat"
41 )
42 
43 plt.ion()
44 
45 plt.figure()
46 plt.plot(com_data[:, 1], "b-")
47 plt.plot(com_data[:, 2], "r-")
48 plt.plot(com_data[:, 3], "g-")
49 plt.title("COM")
50 plt.legend(["x", "y", "z"])
51 
52 plt.figure()
53 plt.plot(pos_data[:, 1], "b-")
54 plt.plot(pos_data[:, 2], "r-")
55 plt.plot(pos_data[:, 3], "g-")
56 plt.title("Position measure")
57 plt.legend(["x", "y", "z"])
58 
59 plt.figure()
60 plt.plot(pos_data[:, 4], "b-")
61 plt.plot(pos_data[:, 5], "r-")
62 plt.plot(pos_data[:, 6], "g-")
63 plt.title("Orientation measure")
64 plt.legend(["yaw", "pitch", "roll"])
65 
66 plt.figure()
67 plt.plot(vel_data[:, 1], "b-")
68 plt.plot(vel_data[:, 2], "r-")
69 plt.plot(vel_data[:, 3], "g-")
70 plt.title("Linear velocity measure")
71 plt.legend(["x", "y", "z"])
72 
73 plt.figure()
74 plt.plot(vel_data[:, 4], "b-")
75 plt.plot(vel_data[:, 5], "r-")
76 plt.plot(vel_data[:, 6], "g-")
77 plt.title("Angular velocity measure")
78 plt.legend(["x", "y", "z"])
79 
80 input("Wait before leaving the simulation")
81 print("Stopping Gazebo link state publisher...")
82 pub.stop()
83 sleep(0.1)
84 print("Gazebo link state publisher stopped")
sot_talos_balance.test.test_ffSubscriber.input
input
Definition: test_ffSubscriber.py:15
sot_talos_balance.utils.run_test_utils.runCommandClient
runCommandClient
Definition: run_test_utils.py:23
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_test
def run_test(appli, verbosity=1, interactive=True)
Definition: run_test_utils.py:83