MCPcopy Create free account
hub / github.com/TeleHuman/TextOp / motion_anchor_pos_b_future

Function motion_anchor_pos_b_future

TextOpTracker/scripts/deploy_mujoco.py:390–426  ·  view source on GitHub ↗

Future N-step motion anchor position in body frame - matching Isaac Lab order

(sim_data, motion_loader, t)

Source from the content-addressed store, hash-verified

388
389
390def motion_anchor_pos_b_future(sim_data, motion_loader, t):
391 """Future N-step motion anchor position in body frame - matching Isaac Lab order"""
392 if t < 0:
393 return np.zeros(15, dtype=np.float32) # 3 * 5 = 15
394
395 # Get robot anchor pose
396 robot_pos = sim_data.body(motion_loader.anchor_body_name).xpos.copy().reshape(1, 3)
397 robot_quat = sim_data.body(motion_loader.anchor_body_name).xquat.copy().reshape(1, 4)
398
399 # Get future motion anchor poses - batch process like Isaac Lab
400 future_positions = []
401 future_orientations = []
402 for i in range(motion_loader.future_steps):
403 step_idx = min(t + i, motion_loader.T - 1)
404 ref_pos = motion_loader.body_pos[step_idx][motion_loader.anchor_body_index].reshape(1, 3)
405 ref_quat = motion_loader.body_ori[step_idx][motion_loader.anchor_body_index].reshape(1, 4)
406 future_positions.append(ref_pos)
407 future_orientations.append(ref_quat)
408
409 # Stack to create [future_steps, 1, 3] then reshape to [future_steps, 3]
410 future_anchor_pos_w = np.stack(future_positions, axis=0).squeeze(1) # [5, 3]
411 future_anchor_quat_w = np.stack(future_orientations, axis=0).squeeze(1) # [5, 4]
412
413 # Expand robot anchor for broadcasting: [future_steps, 3] and [future_steps, 4]
414 robot_anchor_pos_w_exp = robot_pos.repeat(motion_loader.future_steps, axis=0) # [5, 3]
415 robot_anchor_quat_w_exp = robot_quat.repeat(motion_loader.future_steps, axis=0) # [5, 4]
416
417 # Transform all future steps at once
418 pos_b, _ = subtract_frame_transforms(
419 torch.from_numpy(robot_anchor_pos_w_exp).float(),
420 torch.from_numpy(robot_anchor_quat_w_exp).float(),
421 torch.from_numpy(future_anchor_pos_w).float(),
422 torch.from_numpy(future_anchor_quat_w).float(),
423 )
424
425 pos_b_flat = np.array(pos_b, dtype=np.float32).flatten() # [15]
426 return pos_b_flat # [15]
427
428
429def motion_anchor_ori_b_future(sim_data, motion_loader, t):

Callers 2

compute_observationFunction · 0.70
compute_observationMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected