-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlandmark_renderer.py
72 lines (60 loc) · 2.42 KB
/
landmark_renderer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import numpy as np
import matplotlib.pyplot as plt
import sys
from pose_tools.pose_utils import *
from pathlib import Path
import shutil
from argparse import ArgumentParser
import settings
def render_landmarks(params):
landmarks_path = params.landmarks_path
figure_path = landmarks_path + "figs/"
output_path = Path(figure_path)
if output_path.exists() and output_path.is_dir():
shutil.rmtree(output_path)
output_path.mkdir(parents=True)
# th = 0
# th = np.pi / 4 + np.pi # roughly the angle the radar is offset by
# rotation_matrix = np.array([[np.cos(th), -np.sin(th)], [np.sin(th), np.cos(th)]])
for i in range(params.num_samples):
folder_path = landmarks_path + "landmarks_" + str(i)
print(folder_path)
landmarks = np.genfromtxt(folder_path + ".csv", delimiter=",")
# print(landmarks)
# landmarks = landmarks @ rotation_matrix
# landmarks[:, 0] = -landmarks[:, 0]
landmarks[:, 0], landmarks[:, 1] = np.array(landmarks[:, 1]), np.array(landmarks[:, 0])
# landmarks[:, 0], landmarks[:, 1] = b, a
plt.figure(figsize=(20, 20))
dim = 200
plt.xlim(-dim, dim)
plt.ylim(-dim, dim)
plt.plot(landmarks[:, 0], landmarks[:, 1], "*")
plt.grid()
plt.savefig("%s%s%i%s" % (output_path, "/landmarks_", i, ".png"))
plt.close()
def plot_velocity_estimates():
poses_path = "/workspace/data/radar-tmp/ro_relative_poses.monolithic"
se3s, timestamps = get_poses_from_file(poses_path)
x_velocities, y_velocities, th_velocities = get_x_y_th_velocities_from_poses(se3s, timestamps)
plt.figure(figsize=(10, 10))
plt.plot(x_velocities, '.-', label="x")
plt.plot(y_velocities, '.-', label="y")
plt.plot(th_velocities, '.-', label="th")
plt.grid()
plt.legend()
plt.title("RO velocity estimates")
plt.xlabel("Sample index")
plt.ylabel("Velocity (m/s)")
plt.savefig("speeds.png")
plt.close()
def main():
parser = ArgumentParser(add_help=False)
parser.add_argument('--landmarks_path', type=str, default="",
help='Path to landmarks that were exported for processing')
parser.add_argument('--num_samples', type=int, default=settings.TOTAL_SAMPLES, help='Number of samples to process')
params = parser.parse_args()
print("Running landmark renderer...")
render_landmarks(params)
if __name__ == "__main__":
main()