11#!/usr/bin/env python3
2- # Copyright (c) 2025 Carologistics
2+ # Copyright (c) 2025-2026 Carologistics
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
1212# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313# See the License for the specific language governing permissions and
1414# limitations under the License.
15+ import os
16+
17+ from ament_index_python .packages import get_package_share_directory
1518from launch import LaunchDescription
1619from launch .actions import DeclareLaunchArgument
1720from launch .actions import GroupAction
1821from launch .actions import OpaqueFunction
1922from launch .conditions import IfCondition
2023from launch .substitutions import LaunchConfiguration
24+ from launch .substitutions import TextSubstitution
2125from launch_ros .actions import Node
26+ from launch_ros .parameter_descriptions import ParameterValue
2227
2328
2429def launch_nodes_withconfig (context , * args , ** kwargs ):
@@ -42,8 +47,11 @@ def launch_nodes_withconfig(context, *args, **kwargs):
4247
4348 rangeMin = LaunchConfiguration ("rangeMin" )
4449 rangeMax = LaunchConfiguration ("rangeMax" )
45-
50+ start_mapper = LaunchConfiguration ( "start_mapper" )
4651 launch_configuration = {}
52+
53+ config_file = os .path .join (get_package_share_directory ("laser_scan_mapper" ), "config" , "offset.yaml" )
54+
4755 for argname , argval in context .launch_configurations .items ():
4856 launch_configuration [argname ] = argval
4957
@@ -86,14 +94,21 @@ def launch_nodes_withconfig(context, *args, **kwargs):
8694 output = "screen" ,
8795 respawn = True ,
8896 respawn_delay = 2 ,
89- condition = IfCondition (LaunchConfiguration ( " start_mapper" ) ),
97+ condition = IfCondition (start_mapper ),
9098 parameters = [
99+ config_file ,
91100 {
92101 "frameID" : launch_configuration ["namespace" ],
93- "position_tolerance" : launch_configuration ["position_tolerance" ],
94- "angle_tolerance" : launch_configuration ["angle_tolerance" ],
95- "machine_names" : launch_configuration ["machine_names" ],
96- }
102+ "position_tolerance" : ParameterValue (
103+ LaunchConfiguration ("position_tolerance" ), value_type = float
104+ ),
105+ "angle_tolerance" : ParameterValue (LaunchConfiguration ("angle_tolerance" ), value_type = float ),
106+ },
107+ ],
108+ arguments = [
109+ "--ros-args" ,
110+ "-p" ,
111+ LaunchConfiguration ("machine_names" ),
97112 ],
98113 ),
99114 ]
@@ -108,11 +123,11 @@ def generate_launch_description():
108123 )
109124 declare_integratedtopic_argument = DeclareLaunchArgument (
110125 "integratedTopic" ,
111- default_value = "/robotinobase1/scan " ,
126+ default_value = "" ,
112127 description = "Integrated topic to publish the laserscan to" ,
113128 )
114129 declare_integratedframe_argument = DeclareLaunchArgument (
115- "integratedFrameId" , default_value = "robotinobase1/laser_link " , description = "Integrated Frame ID"
130+ "integratedFrameId" , default_value = "" , description = "Integrated Frame ID"
116131 )
117132 declare_scantopic1_argument = DeclareLaunchArgument (
118133 "scanTopic1" , default_value = "/front/sick_scan/scan" , description = "Scan topic of the first laserscan"
@@ -152,37 +167,34 @@ def generate_launch_description():
152167 declare_rangeMax_argument = DeclareLaunchArgument ("rangeMax" , default_value = "100.0" , description = "rangeMax" )
153168
154169 declare_start_mapper_argument = DeclareLaunchArgument (
155- "start_mapper" , default_value = "false " , description = 'Set this value on "true", to start the mapper node'
170+ "start_mapper" , default_value = "true " , description = 'Set this value on "true", to start the mapper node'
156171 )
157172 declare_machine_names_argument = DeclareLaunchArgument (
158173 "machine_names" ,
159174 default_value = [
160- "M-DS" ,
161- "M-SS" ,
162- "M-BS" ,
163- "M-CS1" ,
164- "M-CS2" ,
165- "M-RS1" ,
166- "M-RS2" ,
167- "C-DS" ,
168- "C-BS" ,
169- "C-SS" ,
170- "C-RS1" ,
171- "C-RS2" ,
172- "C-CS1" ,
173- "C-CS2" ,
175+ TextSubstitution (text = "machine_names:=" ),
176+ TextSubstitution (
177+ text = '["M-DS","M-DS-I","M-DS-O","M-SS","M-BS","M-CS1","M-CS2",'
178+ '"M-RS1","M-RS2","C-DS","C-BS","C-SS","C-RS1","C-RS2","C-CS1","C-CS2",'
179+ '"M-SS-I","M-BS-I","M-CS1-I","M-CS2-I","M-RS1-I","M-RS2-I",'
180+ '"C-DS-I","C-BS-I","C-SS-I","C-RS1-I","C-RS2-I","C-CS1-I","C-CS2-I",'
181+ '"M-SS-O","M-BS-O","M-CS1-O","M-CS2-O","M-RS1-O","M-RS2-O",'
182+ '"C-DS-O","C-BS-O","C-SS-O","C-RS1-O","C-RS2-O","C-CS1-O","C-CS2-O"]'
183+ ),
174184 ],
175185 description = "List of machine frame IDs used by the mapper node to retrieve their static transforms (TFs)." ,
176186 )
177187 declare_position_tolerance_argument = DeclareLaunchArgument (
178188 "position_tolerance" ,
179- default_value = "0.3" ,
180- description = "Maximum allowed distance (in meters) between a laser segment and a machine for association." ,
189+ default_value = "1" ,
190+ description = "Maximum allowed distance (in meters) between the callculated machine mid point based on the laser segment "
191+ " and a the machine frame from the refbox" ,
181192 )
182193 declare_angle_tolerance_argument = DeclareLaunchArgument (
183194 "angle_tolerance" ,
184- default_value = "0.5" ,
185- description = "Maximum allowed angular deviation (in radians) between a laser segment and a machine orientation." ,
195+ default_value = "3.14" ,
196+ description = "Maximum allowed angular deviation (in radians) between the callculated machine mid point based on the laser segment"
197+ " and a the machine frame from the refbox" ,
186198 )
187199
188200 # Erstellen des LaunchDescription-Objekts und Hinzufügen der Aktionen
0 commit comments