Views
No views yet
observation.state: Shape (batch, 1, 7) - Joint positions (7 DOF arm)observation.goal: Shape (batch, 1, 3) - Goal cartesian position (X, Y, Z)observation.images.table_camera: Shape (batch, 1, 3, 480, 640) - Table camera RGB imagesaction: Shape (batch, 16, 7) - Joint positions (7 DOF) for 16-step horizon (next positions along trajectory)select_action() to get the first step (batch, 7), or predict_action_chunk() to get the full horizon (batch, 16, 7).observation.images.table_camera):[0, 255] to [0, 1] by dividing by 255.0observation.state):(state - min) / (max - min) using dataset statistics (handled by preprocessor)observation.goal):(goal - min) / (max - min) using dataset statistics (handled by preprocessor)action):action * (max - min) + min using dataset statistics (handled by postprocessor)1from lerobot.policies.diffusion.modeling_diffusion import DiffusionPolicy
2from lerobot.policies.factory import make_pre_post_processors
3
4# Load model
5policy = DiffusionPolicy.from_pretrained("calebescobedo/sensor-diffusion-policy-v1")
6
7# Load preprocessor and postprocessor from the same repo
8preprocessor, postprocessor = make_pre_post_processors(
9 policy_cfg=policy.config,
10 pretrained_path="calebescobedo/sensor-diffusion-policy-v1"
11)
12
13# Prepare inputs
14batch = {
15 'observation.state': state_tensor, # (batch, 1, 7) - raw joint positions
16 'observation.goal': goal_tensor, # (batch, 1, 3) - raw goal xyz
17 'observation.images.table_camera': table_img, # (batch, 1, 3, 480, 640) - uint8 [0,255] or float [0,1]
18}
19
20# Inference
21policy.eval()
22with torch.no_grad():
23 batch = preprocessor(batch) # Normalizes inputs
24 actions = policy.select_action(batch) # Returns normalized actions
25 actions = postprocessor(actions) # Unnormalizes to raw joint positions[0.454, -0.133, 0.522] (constant)