Skip to content

Commit

Permalink
[xs_modules] More verbose errors (#63)
Browse files Browse the repository at this point in the history
* [xs_modules] Add more descriptive errors

* Fix linting issue
  • Loading branch information
lukeschmitt-tr committed Feb 26, 2024
1 parent 279a732 commit 11ddeee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import math
from threading import Thread
import sys
import time
from typing import Any, List, Tuple, Union

Expand Down Expand Up @@ -178,7 +179,7 @@ def shutdown(self) -> None:
time.sleep(0.5)
else:
self.core.get_logger().error(
"Cannot perform shutdown due to lack of ownership"
'Cannot perform shutdown due to lack of ownership'
)


Expand Down Expand Up @@ -227,16 +228,23 @@ def __init__(
rclpy.spin_once(self.core)

self.group_info: RobotInfo.Response = self.future_group_info.result()
if self.group_info.num_joints != self.robot_des.Slist.shape[1]:
self.core.get_logger().fatal(
f"Number of joints in group '{group_name}' does not match Modern Robotics "
f"description for arm model '{robot_model}' ({self.group_info.num_joints} != "
f'{self.robot_des.Slist.shape[1]}).'
)
sys.exit(1)
if self.group_info.profile_type != 'time':
self.core.get_logger().error(
"Please set the group's 'profile_type' to 'time'."
)
exit(1)
sys.exit(1)
if self.group_info.mode != 'position':
self.core.get_logger().error(
"Please set the group's 'operating mode' to 'position'."
)
exit(1)
sys.exit(1)

# initialize initial IK guesses
self.initial_guesses = [[0.0] * self.group_info.num_joints for _ in range(3)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"""Contains the `InterbotixRobotXSCore` class that interfaces with the interbotix_xs_sdk."""

import copy
import sys
from threading import Lock
from typing import Dict, List

Expand Down Expand Up @@ -130,14 +129,13 @@ def __init__(
)

# Check for xs_sdk by looking for set_operating_modes
if not self.srv_set_op_modes.wait_for_service(timeout_sec=10.0):
while not self.srv_set_op_modes.wait_for_service(timeout_sec=5.0) and rclpy.ok():
self.get_logger().error(
(
f"Failed to find services under namespace '{self.robot_name}'. Is the xs_sdk "
'running? Shutting down...'
'running under that namespace?'
)
)
sys.exit(1)
self.srv_set_pids.wait_for_service()
self.srv_set_reg.wait_for_service()
self.srv_get_reg.wait_for_service()
Expand Down

0 comments on commit 11ddeee

Please sign in to comment.