|
4 | 4 | author: Atsushi Sakai |
5 | 5 | """ |
6 | 6 |
|
7 | | -import math |
8 | | -import os |
9 | 7 | import sys |
| 8 | +import os |
| 9 | +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../utils/") |
| 10 | + |
| 11 | +import math |
10 | 12 | from enum import IntEnum |
11 | 13 |
|
12 | 14 | import numpy as np |
13 | | -from scipy.spatial.transform import Rotation as Rot |
14 | 15 | import matplotlib.pyplot as plt |
15 | 16 |
|
| 17 | +from utils.angle import rot_mat_2d |
| 18 | + |
16 | 19 | sys.path.append(os.path.dirname(os.path.abspath(__file__)) + |
17 | 20 | "/../../Mapping/") |
18 | 21 |
|
@@ -148,16 +151,14 @@ def convert_grid_coordinate(ox, oy, sweep_vec, sweep_start_position): |
148 | 151 | tx = [ix - sweep_start_position[0] for ix in ox] |
149 | 152 | ty = [iy - sweep_start_position[1] for iy in oy] |
150 | 153 | th = math.atan2(sweep_vec[1], sweep_vec[0]) |
151 | | - rot = Rot.from_euler('z', th).as_matrix()[0:2, 0:2] |
152 | | - converted_xy = np.stack([tx, ty]).T @ rot |
| 154 | + converted_xy = np.stack([tx, ty]).T @ rot_mat_2d(th) |
153 | 155 |
|
154 | 156 | return converted_xy[:, 0], converted_xy[:, 1] |
155 | 157 |
|
156 | 158 |
|
157 | 159 | def convert_global_coordinate(x, y, sweep_vec, sweep_start_position): |
158 | 160 | th = math.atan2(sweep_vec[1], sweep_vec[0]) |
159 | | - rot = Rot.from_euler('z', -th).as_matrix()[0:2, 0:2] |
160 | | - converted_xy = np.stack([x, y]).T @ rot |
| 161 | + converted_xy = np.stack([x, y]).T @ rot_mat_2d(-th) |
161 | 162 | rx = [ix + sweep_start_position[0] for ix in converted_xy[:, 0]] |
162 | 163 | ry = [iy + sweep_start_position[1] for iy in converted_xy[:, 1]] |
163 | 164 | return rx, ry |
|
0 commit comments