Skip to content

Commit becaaad

Browse files
Jelmerdwrosalievanark
authored andcommitted
Add basis for beamagine.
Signed-off-by: Jelmer de Wolde <jelmer.de.wolde@alliander.com>
1 parent e77cd22 commit becaaad

16 files changed

Lines changed: 3539 additions & 7 deletions

File tree

.devcontainer/dev/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"kylinideteam.cmake-intellisence",
4646
"redhat.vscode-yaml",
4747
"github.vscode-pull-request-github",
48-
"davidanson.vscode-markdownlint"
48+
"davidanson.vscode-markdownlint",
49+
"redhat.vscode-xml"
4950
]
5051
}
5152
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
ARG BASE_IMAGE=ubuntu:latest
5+
FROM $BASE_IMAGE
6+
7+
ARG COLCON_BUILD_SEQUENTIAL
8+
ENV ROS_DISTRO=jazzy
9+
10+
# Install L3Cam SDK:
11+
ARG TEMP_DIR="/tmp/beamagine_install"
12+
ARG RUN_FILE="$TEMP_DIR/l3cam_sdk.run"
13+
RUN mkdir -p "$TEMP_DIR"
14+
RUN if [ $(dpkg --print-architecture) = "amd64" ]; \
15+
then wget -O "$RUN_FILE" "https://github.com/beamaginelidar/libl3cam/releases/download/0.2.1R/libl3cam_0.2.1-1_amd64.deb"; \
16+
elif [ $(dpkg --print-architecture) = "arm64" ]; \
17+
then wget -O "$RUN_FILE" "https://github.com/beamaginelidar/libl3cam/releases/download/0.2.1R/libl3cam_0.2.1-1_arm64.deb"; \
18+
else echo "Unsupported architecture: $(dpkg --print-architecture)"; exit 1; fi
19+
RUN dpkg -i "${RUN_FILE}"
20+
21+
# Install ROS driver:
22+
WORKDIR /$WORKDIR/external
23+
RUN apt update \
24+
&& git clone -b humble https://github.com/beamaginelidar/l3cam_ros2.git src/l3cam_ros2 \
25+
&& cd /$WORKDIR/external \
26+
&& rosdep update --rosdistro $ROS_DISTRO \
27+
&& rosdep install --from-paths src -y -i
28+
RUN /$WORKDIR/colcon_build.sh
29+
30+
# Install repo package:
31+
WORKDIR /$WORKDIR/ros
32+
COPY alliander_robotics/alliander_core/src/ /$WORKDIR/ros/src
33+
COPY alliander_robotics/alliander_beamagine/src/ /$WORKDIR/ros/src
34+
RUN /$WORKDIR/colcon_build.sh
35+
36+
# Install python dependencies:
37+
WORKDIR $WORKDIR
38+
COPY pyproject.toml /$WORKDIR/pyproject.toml
39+
RUN uv sync \
40+
&& echo "export PYTHONPATH=\"$(dirname $(dirname $(uv python find)))/lib/python3.12/site-packages:\$PYTHONPATH\"" >> /root/.bashrc \
41+
&& echo "export PATH=\"$(dirname $(dirname $(uv python find)))/bin:\$PATH\"" >> /root/.bashrc
42+
43+
# Finalize
44+
WORKDIR /$WORKDIR
45+
ENTRYPOINT ["/entrypoint.sh"]
46+
CMD ["sleep", "infinity"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
services:
5+
alliander_beamagine:
6+
image: allianderrobotics/beamagine
7+
container_name: alliander_beamagine
8+
runtime: nvidia
9+
network_mode: host
10+
privileged: true
11+
mem_limit: 6gb
12+
tty: true
13+
env_file:
14+
- .env
15+
volumes:
16+
- "/tmp/.X11-unix:/tmp/.X11-unix"
17+
- "/dev:/dev"
18+
command:
19+
["/bin/bash", "-c", "ros2 launch alliander_beamagine beamagine.launch.py"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.5)
6+
project(alliander_beamagine)
7+
8+
# CMake dependencies:
9+
find_package(ament_cmake REQUIRED)
10+
find_package(ament_cmake_python REQUIRED)
11+
12+
# Shared folders:
13+
install(
14+
DIRECTORY launch
15+
DESTINATION share/${PROJECT_NAME}
16+
)
17+
18+
# Default test:
19+
if(BUILD_TESTING)
20+
find_package(ament_lint_auto REQUIRED)
21+
ament_lint_auto_find_test_dependencies()
22+
endif()
23+
24+
ament_package()
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from alliander_utilities.config_objects import Beamagine
6+
from alliander_utilities.launch_argument import LaunchArgument
7+
from alliander_utilities.launch_utils import SKIP, state_publisher_node, static_tf_node
8+
from alliander_utilities.register import Register, RegisteredLaunchDescription
9+
from alliander_utilities.ros_utils import get_file_path
10+
from launch import LaunchContext, LaunchDescription
11+
from launch.actions import OpaqueFunction
12+
from launch_ros.actions import Node
13+
14+
platform_arg = LaunchArgument("platform_config", "")
15+
16+
17+
def launch_setup(context: LaunchContext) -> list:
18+
"""The launch setup.
19+
20+
Args:
21+
context (LaunchContext): The launch context.
22+
23+
Returns:
24+
list: The actions to start.
25+
"""
26+
beamagine_config = Beamagine.from_str(platform_arg.string_value(context))
27+
28+
state_publisher = state_publisher_node(
29+
namespace=beamagine_config.namespace,
30+
platform="beamagine",
31+
xacro="l3cam.urdf.xacro",
32+
xacro_arguments={
33+
"namespace": beamagine_config.namespace,
34+
"parent": "" if beamagine_config.parent.link else "world",
35+
"use_sim": str(beamagine_config.simulation),
36+
},
37+
)
38+
39+
parent = beamagine_config.parent
40+
static_tf = static_tf_node(
41+
parent_frame=f"{parent.namespace}/{parent.link}" if parent.link else "map",
42+
child_frame=f"{beamagine_config.namespace}/{parent.connects_to}",
43+
position=beamagine_config.position,
44+
orientation=beamagine_config.orientation,
45+
)
46+
47+
hardware = RegisteredLaunchDescription(
48+
get_file_path("alliander_beamagine", ["launch"], "hardware.launch.py"),
49+
{"platform_config": beamagine_config.to_str()},
50+
)
51+
52+
convert_32FC1_to_16UC1 = Node( # noqa: N806
53+
package="alliander_utilities",
54+
executable="convert_32FC1_to_16UC1",
55+
namespace=beamagine_config.namespace,
56+
)
57+
58+
return [
59+
Register.on_start(state_publisher, context),
60+
Register.on_start(static_tf, context),
61+
Register.on_start(convert_32FC1_to_16UC1, context)
62+
if beamagine_config.simulation
63+
else SKIP,
64+
Register.group(hardware, context) if not beamagine_config.simulation else SKIP,
65+
]
66+
67+
68+
def generate_launch_description() -> LaunchDescription:
69+
"""Generate the launch description.
70+
71+
Returns:
72+
LaunchDescription: The launch description.
73+
"""
74+
return LaunchDescription(
75+
[
76+
platform_arg.declaration,
77+
OpaqueFunction(function=launch_setup),
78+
]
79+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-FileCopyrightText: Alliander N. V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
from alliander_utilities.config_objects import Beamagine
5+
from alliander_utilities.launch_argument import LaunchArgument
6+
from alliander_utilities.register import Register
7+
from launch import LaunchContext, LaunchDescription
8+
from launch.actions import OpaqueFunction
9+
from launch_ros.actions import Node
10+
11+
platform_arg = LaunchArgument("platform_config", "")
12+
13+
14+
def launch_setup(context: LaunchContext) -> list:
15+
"""The launch setup.
16+
17+
Args:
18+
context (LaunchContext): The launch context.
19+
20+
Returns:
21+
list: The actions to start.
22+
"""
23+
beamagine_config = Beamagine.from_str(platform_arg.string_value(context))
24+
25+
l3cam_node = Node(
26+
package="l3cam_ros2",
27+
executable="l3cam_ros2_node",
28+
namespace=beamagine_config.namespace,
29+
)
30+
31+
return [
32+
Register.on_start(l3cam_node, context),
33+
]
34+
35+
36+
def generate_launch_description() -> LaunchDescription:
37+
"""Generate the launch description.
38+
39+
Returns:
40+
LaunchDescription: The launch description.
41+
"""
42+
return LaunchDescription(
43+
[
44+
platform_arg.declaration,
45+
OpaqueFunction(function=launch_setup),
46+
]
47+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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>alliander_beamagine</name>
12+
<version>0.1.0</version>
13+
<description>Contains the integration for Beamagine L3Cam.</description>
14+
<maintainer email="robots@alliander.com">Alliander Robotics</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+
<test_depend>ament_lint_auto</test_depend>
21+
22+
<export>
23+
<build_type>ament_cmake</build_type>
24+
</export>
25+
</package>

alliander_robotics/alliander_core/src/alliander_description/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ find_package(ament_cmake_python REQUIRED)
1111

1212
# Shared folders:
1313
install(
14-
DIRECTORY ewellix franka husarion nmea_gps ouster realsense seekthermal velodyne xsens zed
14+
DIRECTORY beamagine ewellix franka husarion nmea_gps ouster realsense seekthermal velodyne xsens zed
1515
DESTINATION share/${PROJECT_NAME}
1616
)
1717

0 commit comments

Comments
 (0)