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

Issue with calling service spawn_entity after some successful attempts. #427

Open
MagdalenaKotynia opened this issue Feb 19, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@MagdalenaKotynia
Copy link
Member

MagdalenaKotynia commented Feb 19, 2025

Describe the bug
The issue related to rai_sim package, commit: f243525
When running scene_setup method of O3DExROS2Bridge in a loop the following error occurs after some successful attempts:

Exception in thread Thread-1 (spin):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 294, in spin
    self.spin_once()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 794, in spin_once
    self._spin_once_impl(timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 791, in _spin_once_impl
    future.result()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 94, in result
    raise self.exception()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 430, in handler
    arg = take_from_wait_list(entity)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 354, in _take_subscription
    with sub.handle:
rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested

The number of attempts after the error occurs is different each time.

The errors occurs here when
trying to call service spawn_entity and is not being catched through try-except (when trying to do so).

To Reproduce
Steps to reproduce the behavior:

  1. Go to f243525
  2. Setup RAI (follow the README)
  3. Setup RAI manipulation demo (follow the README)
  4. Download binary
  5. Save the following content as base_config1.yaml:
entities:
  - name: cube1
    prefab_name: green_cube
    pose:
      translation:
        x: 0.5
        y: 0.3
        z: 0.06
      rotation:
        x: 0.0
        y: 0.0
        z: 0.0
        w: 1.0

  - name: cube2
    prefab_name: green_cube
    pose:
      translation:
        x: 0.5
        y: 0.4
        z: 0.06
      rotation:
        x: 0.0
        y: 0.0
        z: 0.0
        w: 1.0
  1. Save the following content as o3de_config.yaml (adjust path to binary and launch file if needed):
binary_path: RAIManipulationDemoBenchmark_jammyhumble/RAIManipulationDemo/RAIManipulationDemo.GameLauncher
robotic_stack_command: ros2 launch examples/manipulation-demo-no-binary.launch.py 
  1. Run the following python script (adjust paths to yaml configs if needed):
import rclpy
from rai_sim.o3de.o3de_bridge import O3DExROS2Bridge, O3DExROS2SimulationConfig
from rai.communication.ros2.connectors import ROS2ARIConnector
import time

from pathlib import Path

if __name__ == "__main__":

    try:
        rclpy.init()
        connector = ROS2ARIConnector()
        o3de = O3DExROS2Bridge(connector)
        for i in range(300):
            print("ATTEMPT NUMBER: ", i)
            scene_config  = O3DExROS2SimulationConfig.load_config(base_config_path=Path("base_config1.yaml"), connector_config_path=Path("o3de_config.yaml"))
            o3de.setup_scene(scene_config)
    except Exception as e:
        raise e
    finally:
        o3de.shutdown()
        
        
        connector.shutdown()
        rclpy.shutdown()

Expected behavior
After i-th attempt it is expected to have the following error:

Exception in thread Thread-1 (spin):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 294, in spin
    self.spin_once()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 794, in spin_once
    self._spin_once_impl(timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 791, in _spin_once_impl
    future.result()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 94, in result
    raise self.exception()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 430, in handler
    arg = take_from_wait_list(entity)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 354, in _take_subscription
    with sub.handle:
rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested

Platform

  • OS: 22.04
  • ROS 2 Version: Humble

Version
f243525

@MagdalenaKotynia MagdalenaKotynia added the bug Something isn't working label Feb 19, 2025
@rachwalk
Copy link
Contributor

Has been addressed in #428, this issue should be closed after #415 is merged.

@rachwalk rachwalk reopened this Feb 27, 2025
@rachwalk
Copy link
Contributor

Since #415 has been changed from the feature branch to be based on #435, close this issue after the latter is merged to develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants