11from __future__ import annotations
22
3+ import warnings
34from dataclasses import dataclass
45from pathlib import Path
56from typing import Any , Iterable
@@ -309,8 +310,9 @@ def _convert_action_to_joint_space(self, row: pd.Series) -> np.ndarray:
309310 target_pose , observation_joints_vec , tcp_offset = self .tcp_offset
310311 )
311312 if ik_joints is None :
312- msg = f"IK failed for robot '{ robot_key } ' at step { row ['step' ]} "
313- raise ValueError (msg )
313+ msg = f"IK failed for robot '{ robot_key } ' at step { row ['step' ]} , ignoring step"
314+ warnings .warn (msg , stacklevel = 1 )
315+ return None
314316 arm_action_vec = np .asarray (ik_joints , dtype = np .float32 )
315317
316318 actions .append (np .concatenate ([arm_action_vec , action_gripper_vec ]).astype (np .float32 ))
@@ -329,11 +331,13 @@ def _prepare_transition_table(self, table: pd.DataFrame) -> pd.DataFrame:
329331 df ["observation_state" ] = df .apply (self ._build_observation_state , axis = 1 )
330332 df ["action_vector" ] = df .apply (self ._convert_action_to_joint_space , axis = 1 )
331333
334+ df = df [df ["action_vector" ].notna ()] # noqa: PD901
335+
332336 prev_action : np .ndarray | None = None
333337 keep_mask = []
334338 for action_vec in df ["action_vector" ]:
335339 assert isinstance (action_vec , np .ndarray )
336- keep_mask .append (prev_action is None or not np .array_equal (action_vec , prev_action ))
340+ keep_mask .append (prev_action is None or not np .allclose (action_vec , prev_action , atol = 1e-4 , rtol = 0 ))
337341 prev_action = action_vec
338342
339343 return df .loc [keep_mask ].reset_index (drop = True )
0 commit comments