Skip to content

Commit

Permalink
feat: rai_sim (#415)
Browse files Browse the repository at this point in the history
Signed-off-by: Kacper Dąbrowski <[email protected]>
Signed-off-by: Piotr Jaroszek <[email protected]>
Co-authored-by: Jakub Matejczyk <[email protected]>
Co-authored-by: Kacper Dąbrowski <[email protected]>
Co-authored-by: Piotr Jaroszek <[email protected]>
  • Loading branch information
4 people authored Feb 26, 2025
1 parent 0119d2b commit ff0585e
Show file tree
Hide file tree
Showing 9 changed files with 561 additions and 5 deletions.
59 changes: 59 additions & 0 deletions examples/manipulation-demo-no-binary.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import (
IncludeLaunchDescription,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


# TODO (mkotynia) think about separation of launches
def generate_launch_description():
launch_moveit = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
"src/examples/rai-manipulation-demo/Project/Examples/panda_moveit_config_demo.launch.py",
]
)
)

launch_robotic_manipulation = Node(
package="robotic_manipulation",
executable="robotic_manipulation",
# name="robotic_manipulation_node",
output="screen",
parameters=[
{"use_sim_time": True},
],
)

launch_openset = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
FindPackageShare("rai_bringup"),
"/launch/openset.launch.py",
]
),
)

return LaunchDescription(
[
launch_openset,
launch_moveit,
launch_robotic_manipulation,
]
)
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ python = "^3.10, <3.13"
rai = {path = "src/rai_core", develop = true}
rai_asr = {path = "src/rai_asr", develop = true}
rai_tts = {path = "src/rai_tts", develop = true}
rai_sim = {path = "src/rai_sim", develop = true}

langchain-core = "^0.3"
langchain = "*"
Expand Down
8 changes: 4 additions & 4 deletions src/rai_core/rai/communication/ros2/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
self._topic_api = ROS2TopicAPI(self._node)
self._service_api = ROS2ServiceAPI(self._node)
self._actions_api = ROS2ActionAPI(self._node)
self._tf_buffer = Buffer(node=self._node)

self._executor = MultiThreadedExecutor()
self._executor.add_node(self._node)
Expand Down Expand Up @@ -179,16 +180,15 @@ def get_transform(
source_frame: str,
timeout_sec: float = 5.0,
) -> TransformStamped:
tf_buffer = Buffer(node=self._node)
tf_listener = TransformListener(tf_buffer, self._node)
tf_listener = TransformListener(self._tf_buffer, self._node)
transform_available = self.wait_for_transform(
tf_buffer, target_frame, source_frame, timeout_sec
self._tf_buffer, target_frame, source_frame, timeout_sec
)
if not transform_available:
raise LookupException(
f"Could not find transform from {source_frame} to {target_frame} in {timeout_sec} seconds"
)
transform: TransformStamped = tf_buffer.lookup_transform(
transform: TransformStamped = self._tf_buffer.lookup_transform(
target_frame,
source_frame,
rclpy.time.Time(),
Expand Down
17 changes: 17 additions & 0 deletions src/rai_sim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## RAI Sim

## Description

The RAI Sim is a package providing interface to implement connection with a specific simulation.

### Components

- `SimulationConnector` - An interface for connecting with a specific simulation. It manages scene setup, spawning, despawning objects, getting current state of the scene.

- `SimulationConfig` - base config class to specify the entities to be spawned. For each simulation connector there should be specified custom simulation config specifying additional parameters needed to run and connect with the simulation.

- `SceneState` - stores the current info about spawned entities

### Example implementation

- `O3DExROS2Connector` - An implementation of SimulationConnector for working with simulation based on O3DE and ROS2.
23 changes: 23 additions & 0 deletions src/rai_sim/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.poetry]
name = "rai-sim"
version = "0.0.1"
description = "Package to run simulations"
authors = ["Magdalena Kotynia <[email protected]>", "Kacper Dąbrowski <[email protected]>", "Jakub Matejczyk <[email protected]>"]
readme = "README.md"
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
]
packages = [
{ include = "rai_sim", from = "." },
]

[tool.poetry.dependencies]
python = "^3.10, <3.13"
PyYAML = "*"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
15 changes: 15 additions & 0 deletions src/rai_sim/rai_sim/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2025 Robotec.AI
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""RAI Simulations package."""
Loading

0 comments on commit ff0585e

Please sign in to comment.