Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #143 - Catch RTDE exceptions in constructor #148

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This project uses a [CalVer](https://calver.org/) versioning scheme with monthly
- `coco-to-yolo` conversion now creates a single polygon of all disconnected parts of the mask instead of simply taking the first polygon of the list.
- Dropped support for python 3.8 and added 3.11 to the testing matrix [#103](https://github.com/airo-ugent/airo-mono/issues/103).
- Set python version to 3.10 because of an issue with the `ur_rtde` wheels [#121](https://github.com/airo-ugent/airo-mono/issues/121). Updated README.md to reflect this change.
- `URrtde` will now try connecting to do control interface up to 3 times before raising a `RuntimeError`.

### Fixed
- Fixed bug in `get_colored_point_cloud()` that removed some points see issue #25.
Expand Down
24 changes: 17 additions & 7 deletions airo-robots/airo_robots/manipulators/hardware/ur_rtde.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from airo_robots.manipulators.position_manipulator import ManipulatorSpecs, PositionManipulator
from airo_spatial_algebra import SE3Container
from airo_typing import HomogeneousMatrixType, JointConfigurationType
from loguru import logger
from rtde_control import RTDEControlInterface
from rtde_receive import RTDEReceiveInterface

Expand Down Expand Up @@ -44,14 +45,23 @@ def __init__(
) -> None:
super().__init__(manipulator_specs, gripper)
self.ip_address = ip_address
try:
self.rtde_control = RTDEControlInterface(self.ip_address)
self.rtde_receive = RTDEReceiveInterface(self.ip_address)

except RuntimeError:
raise RuntimeError(
"Could not connect to the robot. Is the robot in remote control? Is the IP correct? Is the network connection ok?"
)
max_connection_attempts = 3
for connection_attempt in range(max_connection_attempts):
try:
self.rtde_control = RTDEControlInterface(self.ip_address)
self.rtde_receive = RTDEReceiveInterface(self.ip_address)
break
except RuntimeError as e:
logger.warning(
f"Failed to connect to RTDE. Retrying... (Attempt {connection_attempt + 1}/{max_connection_attempts}). Error:\n{e}"
)
if connection_attempt == max_connection_attempts - 1:
raise RuntimeError(
"Could not connect to the robot. Is the robot in remote control? Is the IP correct? Is the network connection ok?"
)
else:
time.sleep(1.0)

self.default_linear_acceleration = 1.2 # m/s^2
self.default_leading_axis_joint_acceleration = 1.2 # rad/s^2
Expand Down
Loading