Technical Implementation

AV-centric Rotation code

# AV's theta at frame 49
theta = torch.tensor(av_df[49]['theta'], dtype=torch.float64)
rotate_mat = torch.tensor([[torch.cos(theta), -torch.sin(theta)],
                           [torch.sin(theta), torch.cos(theta)]])
# Transform ALL coordinates to AV-aligned frame
x[node_idx, node_steps] = torch.matmul(xy - origin, rotate_mat)

$$ (xR)^T = R^Tx^T $$

Transform entire scene to AV-centric coordinates, since x is a column vector.

rotate_angles = torch.zeros(num_nodes, dtype=torch.float64)
# For each actor:
rotate_angles[node_idx] = actor_hist_df['theta'].values[-1]  # Each agent's OWN headin

in hivt.py

if self.rotate:
	rotate_mat = torch.empty(data.num_nodes, 2, 2)
	sin_vals = torch.sin(data['rotate_angles'])  # Per-agent!
	cos_vals = torch.cos(data['rotate_angles'])
	rotate_mat[:, 0, 0] = cos_vals
	# ... builds N rotation matrices, one per agent
	data.y = torch.bmm(data.y, rotate_mat)  # Rotate GT to each agent's local frame

BOS mask

# bos_mask is True if time step t is valid and time step t-1 is invalid
bos_mask[:, 0] = ~padding_mask[:, 0]
bos_mask[:, 1: 50] = padding_mask[:, : 49] & ~padding_mask[:, 1: 50]
Condition bos_mask_value
Agent appears for the first time at timestep t True
Agent was already present at t-1 False