Skip to content

Commit c2d89ad

Browse files
committed
feat(drive): add "lidar_to_laserscan" node
1 parent bdb59bf commit c2d89ad

3 files changed

Lines changed: 96 additions & 13 deletions

File tree

src/drive_launcher/launch/ebox.launch.py

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
This file runs all required nodes to speak with the Ebox.
33
"""
44

5+
from ament_index_python.packages import get_package_share_directory
56
from launch import LaunchDescription
6-
from launch.actions import OpaqueFunction
7+
from launch.actions import IncludeLaunchDescription
8+
from launch.launch_description_sources import PythonLaunchDescriptionSource
9+
from launch.substitutions import PathJoinSubstitution
710
from launch_ros.actions.node import Node
8-
from rclpy.impl.rcutils_logger import RcutilsLogger
9-
from rclpy.node import get_logger
1011

1112

1213
def generate_launch_description() -> LaunchDescription:
@@ -38,13 +39,38 @@ def generate_launch_description() -> LaunchDescription:
3839
executable="sensors_node",
3940
)
4041

41-
# TODO: implement the camera launch files, then replace this!
42-
camera_warning: OpaqueFunction = OpaqueFunction(function=_warn_about_camera_todos)
43-
44-
return LaunchDescription([wheels_node, lights_node, sensors_node, camera_warning])
42+
# Unitree L2 LiDAR bridge package.
43+
pkg_soro_lidar: str = get_package_share_directory("soro_lidar")
44+
lidar_launch: IncludeLaunchDescription = IncludeLaunchDescription(
45+
PythonLaunchDescriptionSource(
46+
[
47+
PathJoinSubstitution(
48+
[
49+
pkg_soro_lidar,
50+
"launch",
51+
"launch.py",
52+
]
53+
)
54+
]
55+
)
56+
)
4557

58+
# See3CAM color stream for ArUco marker detection.
59+
pkg_see3cam: str = get_package_share_directory("see3cam")
60+
see3cam_launch: IncludeLaunchDescription = IncludeLaunchDescription(
61+
PythonLaunchDescriptionSource(
62+
[
63+
PathJoinSubstitution(
64+
[
65+
pkg_see3cam,
66+
"launch",
67+
"see3cam.launch.py",
68+
]
69+
)
70+
]
71+
)
72+
)
4673

47-
def _warn_about_camera_todos(_):
48-
# we'll emit a diagnostic to remind ourselves lol
49-
logger: RcutilsLogger = get_logger("ebox.launch.py")
50-
_ = logger.error("TODO: implement cameras in launch file!")
74+
return LaunchDescription(
75+
[wheels_node, lights_node, sensors_node, lidar_launch, see3cam_launch]
76+
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from launch import LaunchDescription
2+
from launch.actions import DeclareLaunchArgument
3+
from launch.substitutions import LaunchConfiguration
4+
from launch_ros.actions import ComposableNodeContainer
5+
from launch_ros.descriptions import ComposableNode
6+
7+
8+
def generate_launch_description() -> LaunchDescription:
9+
use_sim_time: LaunchConfiguration = LaunchConfiguration(
10+
"use_sim_time", default="false"
11+
)
12+
13+
pointcloud_to_laserscan: ComposableNode = ComposableNode(
14+
name="lidar_pointcloud_to_laserscan",
15+
package="pointcloud_to_laserscan",
16+
plugin="pointcloud_to_laserscan::PointCloudToLaserScanNode",
17+
remappings=[
18+
("cloud_in", "/unilidar/cloud"),
19+
("scan", "/scan"),
20+
],
21+
parameters=[
22+
{
23+
"use_sim_time": use_sim_time,
24+
"target_frame": "base_link",
25+
"transform_tolerance": 0.2,
26+
"min_height": -0.5,
27+
"max_height": 2.5,
28+
"angle_min": -3.1415926535,
29+
"angle_max": 3.1415926535,
30+
"angle_increment": 0.0058,
31+
"scan_time": 0.1,
32+
"range_min": 0.3,
33+
"range_max": 100.0,
34+
"use_inf": True,
35+
}
36+
],
37+
)
38+
39+
container: ComposableNodeContainer = ComposableNodeContainer(
40+
name="lidar_scan_container",
41+
namespace="",
42+
package="rclcpp_components",
43+
executable="component_container_mt",
44+
composable_node_descriptions=[pointcloud_to_laserscan],
45+
output="screen",
46+
)
47+
48+
return LaunchDescription(
49+
[
50+
DeclareLaunchArgument("use_sim_time", default_value="false"),
51+
container,
52+
]
53+
)

src/drive_launcher/launch/rover.launch.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def generate_launch_description() -> LaunchDescription:
5353
# directly by our Navigator).
5454
robot_localization: IncludeLaunchDescription = _robot_localization(use_sim_time)
5555

56+
# Convert Unitree LiDAR point clouds into LaserScan for scan-based nodes
57+
# (e.g., slam_toolbox and collision monitor).
58+
lidar_to_laserscan: IncludeLaunchDescription = _lidar_to_laserscan(use_sim_time)
5659

5760
# ok, so this part launches a few different things...
5861
#
@@ -111,6 +114,7 @@ def generate_launch_description() -> LaunchDescription:
111114
utm_conversion_node,
112115
robot_state_publisher,
113116
robot_localization,
117+
lidar_to_laserscan,
114118
navigation_stack,
115119
ros2_control,
116120
Node(
@@ -187,7 +191,7 @@ def _navigation_bringup(
187191
)
188192

189193

190-
def _depthimage_to_laserscan(
194+
def _lidar_to_laserscan(
191195
use_sim_time: LaunchConfiguration,
192196
) -> IncludeLaunchDescription:
193197
pkg_drive_launcher: str = get_package_share_directory("drive_launcher")
@@ -199,7 +203,7 @@ def _depthimage_to_laserscan(
199203
pkg_drive_launcher,
200204
"launch",
201205
"helpers",
202-
"depthimage_to_laserscan.launch.py",
206+
"lidar_to_laserscan.launch.py",
203207
]
204208
)
205209
]

0 commit comments

Comments
 (0)