Skip to content

Commit

Permalink
Closes #143 - Catch RTDE exceptions in constructor (#148)
Browse files Browse the repository at this point in the history
* Retry RTDE connection multiple times upon failure
    * Break from loop on successful connection
    * Sleep on failure, to give connection attempt some time to reset
  • Loading branch information
m-decoster authored Oct 25, 2024
1 parent 9104221 commit 6fc4a67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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

0 comments on commit 6fc4a67

Please sign in to comment.