Skip to content

Commit

Permalink
[xs_modules] Reject NaN joint commands (#83)
Browse files Browse the repository at this point in the history
* Reject arm commands with NaNs

* Reject NaNs in single joint command
  • Loading branch information
lukeschmitt-tr authored Dec 30, 2024
1 parent 8ae347e commit d7be6ad
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ def _check_joint_limits(self, positions: List[float]) -> bool:
:return: `True` if all positions are within limits; `False` otherwise
"""
self.core.get_node().logdebug(f'Checking joint limits for {positions=}')

# Reject any commands containing NaN values
if any(math.isnan(elem) for elem in positions):
self.core.get_node().logwarn('Rejecting NaN values in position command')
return False

theta_list = [int(elem * 1000) / 1000.0 for elem in positions]
speed_list = [
abs(goal - current) / float(self.moving_time)
Expand Down Expand Up @@ -354,6 +360,12 @@ def _check_single_joint_limit(self, joint_name: str, position: float) -> bool:
self.core.get_node().logdebug(
f"Checking joint '{joint_name}' limits for {position=}"
)

# Reject any commands containing NaN values
if math.isnan(position):
self.core.get_node().logwarn('Rejecting NaN value in position command')
return False

theta = int(position * 1000) / 1000.0
speed = abs(
theta - self.joint_commands[self.info_index_map[joint_name]]
Expand Down

0 comments on commit d7be6ad

Please sign in to comment.