@@ -58,6 +58,26 @@ def apply_tf_to_pose(pose, pose2d):
58
58
th = pose [2 ] + pose2d [2 ]
59
59
return np .array ([xy [0 ], xy [1 ], th ])
60
60
61
+ def apply_tf_to_poses (poses , pose2d ):
62
+ """
63
+ Parameters
64
+ ----------
65
+ poses: np.array
66
+ Array of shape (N, 3), x, y, theta components of tfs of frame C in frame B)
67
+ pose2d : np.array
68
+ Array of shape (3,), x, y, theta components of the tf of frame B in frame A
69
+ Returns
70
+ -------
71
+ result: np.array
72
+ Array of shape (N, 3), x, y theta components of the tf of frame C in frame A
73
+ """
74
+ result = np .zeros_like (poses )
75
+ xy = rotate (poses [:, :2 ], pose2d [2 ]) + pose2d [:2 ][None , :]
76
+ th = poses [:, 2 ] + pose2d [2 ]
77
+ result [:, :2 ] = xy
78
+ result [:, 2 ] = th
79
+ return result
80
+
61
81
def apply_tf_to_vel (vel , pose2d ):
62
82
# same as apply_tf but assumes vel is xdot ydot thetadot instead of x y
63
83
# for xdot ydot frame transformation applies,
@@ -78,7 +98,7 @@ def rotate(x, th):
78
98
rotmat = np .array ([
79
99
[np .cos (th ), - np .sin (th )],
80
100
[np .sin (th ), np .cos (th )],
81
- ])
101
+ ])
82
102
return np .matmul (rotmat , x .T ).T
83
103
84
104
def inverse_pose2d (pose2d ):
0 commit comments