Skip to content

Commit 21de58d

Browse files
committed
Make a ros wrapper.
Signed-off-by: Jelmer de Wolde <[email protected]>
1 parent 1d9f11a commit 21de58d

File tree

22 files changed

+1048
-146
lines changed

22 files changed

+1048
-146
lines changed

dockerfiles/install_scripts/dev_packages.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
set -e
88
source /home/$UNAME/.bashrc
99
apt update
10-

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ dependencies = [
2222
"mashumaro>=3.16",
2323
"myst-parser>=4.0.1",
2424
"numpy<2.0",
25-
"opencv-python>=4.11.0.86",
2625
"pillow>=11.3.0",
2726
"pre-commit>=4.2.0",
2827
"psutil>=7.0.0",
@@ -42,9 +41,9 @@ dependencies = [
4241
"tornado>=6.5.1",
4342
"transforms3d>=0.4.2",
4443
"waitress>=3.0.2",
45-
"xmltodict>=1.0.2",
4644
"pandas>=2.2.0",
4745
"trimesh>=4.8.2",
46+
"xmltodict>=1.0.2",
4847
]
4948

5049
[dependency-groups]

ros2_ws/src/rcdt_gazebo/launch/gazebo_robot.launch.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55

6+
import math
67
import xml.etree.ElementTree as ET
78

89
from launch import LaunchContext, LaunchDescription
@@ -16,6 +17,7 @@
1617
world_arg = LaunchArgument("world", "walls.sdf")
1718
robots_arg = LaunchArgument("robots", "")
1819
positions_arg = LaunchArgument("positions", "")
20+
orientation_arg = LaunchArgument("orientation", "0,0,0,1")
1921
bridge_topics_arg = LaunchArgument("bridge_topics", "")
2022

2123

@@ -35,6 +37,7 @@ def launch_setup(context: LaunchContext) -> list:
3537
world = world_arg.string_value(context)
3638
robots = robots_arg.string_value(context).split()
3739
positions = positions_arg.string_value(context).split()
40+
orientations = orientation_arg.string_value(context).split()
3841
bridge_topics = bridge_topics_arg.string_value(context).split()
3942

4043
sdf_file = get_file_path("rcdt_gazebo", ["worlds"], world)
@@ -61,9 +64,21 @@ def launch_setup(context: LaunchContext) -> list:
6164
)
6265

6366
spawn_robots: list[Node] = []
64-
for robot, position in zip(robots, positions, strict=False):
67+
for robot, position, orientation in zip(
68+
robots, positions, orientations, strict=False
69+
):
6570
namespace = "" if not robot else f"/{robot}"
6671
x, y, z = position.split(",")
72+
qx, qy, qz, qw = orientation.split(",")
73+
roll, pitch, yaw = 0, 0, 0
74+
if robot in {"realsense1", "realsense"}:
75+
roll = 0
76+
pitch = math.radians(90)
77+
yaw = 0
78+
79+
print(
80+
f"Spawning robot '{robot}' at position {position} with orientation {roll, pitch, yaw} in world '{world_name}'"
81+
)
6782
spawn_robot = Node(
6883
package="ros_gz_sim",
6984
executable="create",
@@ -78,6 +93,12 @@ def launch_setup(context: LaunchContext) -> list:
7893
str(y),
7994
"-z",
8095
str(z),
96+
"-P",
97+
str(pitch),
98+
"-R",
99+
str(roll),
100+
"-Y",
101+
str(yaw),
81102
],
82103
output="screen",
83104
)
@@ -125,6 +146,7 @@ def generate_launch_description() -> LaunchDescription:
125146
world_arg.declaration,
126147
robots_arg.declaration,
127148
positions_arg.declaration,
149+
orientation_arg.declaration,
128150
bridge_topics_arg.declaration,
129151
OpaqueFunction(function=launch_setup),
130152
]

ros2_ws/src/rcdt_gazebo/worlds/table_with_1_brick.sdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ SPDX-License-Identifier: Apache-2.0
6969
</model>
7070

7171
<model name='brick0'>
72-
<pose>0.5 0 0 0 0 0</pose>
72+
<pose>0.5 0 0.03 0 0 0</pose>
7373
<include>
7474
<uri>model://rcdt_gazebo/models/brick</uri>
7575
</include>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.5)
6+
project(rcdt_grasping)
7+
8+
# CMake dependencies:
9+
find_package(ament_cmake REQUIRED)
10+
find_package(ament_cmake_python REQUIRED)
11+
12+
# Other dependencies:
13+
find_package(rclpy REQUIRED)
14+
find_package(rcdt_utilities REQUIRED)
15+
16+
ament_python_install_package(${PROJECT_NAME})
17+
18+
# Python executables:
19+
install(
20+
DIRECTORY src_py/
21+
DESTINATION lib/${PROJECT_NAME}
22+
)
23+
24+
# Shared folders:
25+
install(
26+
DIRECTORY launch
27+
DESTINATION share/${PROJECT_NAME}
28+
)
29+
30+
# Default test:
31+
if(BUILD_TESTING)
32+
find_package(ament_lint_auto REQUIRED)
33+
ament_lint_auto_find_test_dependencies()
34+
endif()
35+
36+
ament_package()
11.9 MB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Alliander N. V.
2+
3+
SPDX-License-Identifier: Apache-2.0
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from launch import LaunchContext, LaunchDescription
6+
from launch.actions import OpaqueFunction
7+
from launch_ros.actions import Node
8+
from rcdt_utilities.launch_utils import LaunchArgument
9+
from rcdt_utilities.register import Register
10+
11+
namespace_arm_arg = LaunchArgument("namespace_arm", "")
12+
namespace_camera_arg = LaunchArgument("namespace_camera", "")
13+
14+
15+
def launch_setup(context: LaunchContext) -> list:
16+
"""Setup the launch description for the grasping node.
17+
18+
Args:
19+
context (LaunchContext): The launch context.
20+
21+
Returns:
22+
list: A list of actions to be executed in the launch description.
23+
"""
24+
namespace_arm = namespace_arm_arg.string_value(context)
25+
namespace_camera = namespace_camera_arg.string_value(context)
26+
27+
graspnet_node = Node(
28+
package="rcdt_grasping",
29+
executable="generate_grasp.py",
30+
)
31+
32+
grasping_logic = Node(
33+
package="rcdt_grasping",
34+
executable="grasp_logic.py",
35+
parameters=[
36+
{"namespace_arm": namespace_arm, "namespace_camera": namespace_camera}
37+
],
38+
)
39+
40+
return [
41+
Register.on_log(
42+
graspnet_node, "GraspNet model initialized and weights loaded", context
43+
),
44+
Register.on_log(grasping_logic, "GraspLogicNode initialized!", context),
45+
]
46+
47+
48+
def generate_launch_description() -> LaunchDescription:
49+
"""Generate the launch description for the grasping node.
50+
51+
Returns:
52+
LaunchDescription: The launch description containing the grasping node.
53+
"""
54+
return LaunchDescription(
55+
[
56+
namespace_arm_arg.declaration,
57+
namespace_camera_arg.declaration,
58+
OpaqueFunction(function=launch_setup),
59+
]
60+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
4+
<!--
5+
SPDX-FileCopyrightText: Alliander N. V.
6+
7+
SPDX-License-Identifier: Apache-2.0
8+
-->
9+
10+
<package format="3">
11+
<name>rcdt_grasping</name>
12+
<version>0.1.0</version>
13+
<description>Package that contains functionality for grasping objects.</description>
14+
<maintainer email="[email protected]">RCDT</maintainer>
15+
<license>Apache 2.0</license>
16+
17+
<buildtool_depend>ament_cmake</buildtool_depend>
18+
<buildtool_depend>ament_cmake_python</buildtool_depend>
19+
20+
<depend>rcdt_utilities</depend>
21+
22+
<exec_depend>rclpy</exec_depend>
23+
24+
<export>
25+
<build_type>ament_cmake</build_type>
26+
</export>
27+
</package>

ros2_ws/src/rcdt_grasping/rcdt_grasping/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)