Skip to content

Commit 5442c8b

Browse files
[xs_modules] Reject NaN joint commands (#83)
* Reject arm commands with NaNs * Reject NaNs in single joint command
1 parent 6ffa922 commit 5442c8b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • interbotix_xs_toolbox/interbotix_xs_modules/interbotix_xs_modules/xs_robot

interbotix_xs_toolbox/interbotix_xs_modules/interbotix_xs_modules/xs_robot/arm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ def _check_joint_limits(self, positions: List[float]) -> bool:
326326
:return: `True` if all positions are within limits; `False` otherwise
327327
"""
328328
self.core.get_node().logdebug(f'Checking joint limits for {positions=}')
329+
330+
# Reject any commands containing NaN values
331+
if any(math.isnan(elem) for elem in positions):
332+
self.core.get_node().logwarn('Rejecting NaN values in position command')
333+
return False
334+
329335
theta_list = [int(elem * 1000) / 1000.0 for elem in positions]
330336
speed_list = [
331337
abs(goal - current) / float(self.moving_time)
@@ -354,6 +360,12 @@ def _check_single_joint_limit(self, joint_name: str, position: float) -> bool:
354360
self.core.get_node().logdebug(
355361
f"Checking joint '{joint_name}' limits for {position=}"
356362
)
363+
364+
# Reject any commands containing NaN values
365+
if math.isnan(position):
366+
self.core.get_node().logwarn('Rejecting NaN value in position command')
367+
return False
368+
357369
theta = int(position * 1000) / 1000.0
358370
speed = abs(
359371
theta - self.joint_commands[self.info_index_map[joint_name]]

0 commit comments

Comments
 (0)