mirror of
https://github.com/modelec/modelec-marcel-ROS.git
synced 2026-01-18 16:47:43 +01:00
delay lidar
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
from launch import LaunchDescription
|
from launch import LaunchDescription
|
||||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, Shutdown, RegisterEventHandler
|
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, Shutdown, RegisterEventHandler, TimerAction
|
||||||
from launch.conditions import IfCondition
|
from launch.conditions import IfCondition
|
||||||
from launch.event_handlers import OnProcessExit
|
from launch.event_handlers import OnProcessExit
|
||||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||||
@@ -8,7 +8,6 @@ from launch_ros.actions import Node
|
|||||||
from ament_index_python.packages import get_package_share_directory
|
from ament_index_python.packages import get_package_share_directory
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def generate_launch_description():
|
def generate_launch_description():
|
||||||
# Declare launch arguments
|
# Declare launch arguments
|
||||||
with_gui_arg = DeclareLaunchArgument('with_gui', default_value='true', description='Launch GUI?')
|
with_gui_arg = DeclareLaunchArgument('with_gui', default_value='true', description='Launch GUI?')
|
||||||
@@ -22,17 +21,23 @@ def generate_launch_description():
|
|||||||
with_com = LaunchConfiguration('with_com')
|
with_com = LaunchConfiguration('with_com')
|
||||||
with_strat = LaunchConfiguration('with_strat')
|
with_strat = LaunchConfiguration('with_strat')
|
||||||
|
|
||||||
# Conditionally include RPLIDAR launch
|
# Function to launch RPLIDAR node with a delay
|
||||||
rplidar_launch = IncludeLaunchDescription(
|
def launch_rplidar_with_delay(context, *args, **kwargs):
|
||||||
PythonLaunchDescriptionSource(
|
if context.launch_configurations.get('with_rplidar') == 'true':
|
||||||
os.path.join(
|
# TimerAction to delay the start of RPLIDAR
|
||||||
get_package_share_directory('rplidar_ros'),
|
start_rplidar = TimerAction(
|
||||||
'launch',
|
period=5.0, # Delay of 10 seconds before launching RPLIDAR
|
||||||
'rplidar_a1_launch.py'
|
actions=[
|
||||||
|
Node(
|
||||||
|
package='rplidar_ros',
|
||||||
|
executable='rplidar_node',
|
||||||
|
name='rplidar_node',
|
||||||
|
output='screen'
|
||||||
|
)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
),
|
return [start_rplidar]
|
||||||
condition=IfCondition(with_rplidar)
|
return []
|
||||||
)
|
|
||||||
|
|
||||||
# Function to launch GUI and shutdown handler
|
# Function to launch GUI and shutdown handler
|
||||||
def launch_gui(context, *args, **kwargs):
|
def launch_gui(context, *args, **kwargs):
|
||||||
@@ -77,7 +82,9 @@ def generate_launch_description():
|
|||||||
with_com_arg,
|
with_com_arg,
|
||||||
with_strat_arg,
|
with_strat_arg,
|
||||||
|
|
||||||
rplidar_launch,
|
# Launch the RPLIDAR node with a delay
|
||||||
|
OpaqueFunction(function=launch_rplidar_with_delay),
|
||||||
|
|
||||||
OpaqueFunction(function=launch_gui),
|
OpaqueFunction(function=launch_gui),
|
||||||
OpaqueFunction(function=launch_com),
|
OpaqueFunction(function=launch_com),
|
||||||
OpaqueFunction(function=launch_strat),
|
OpaqueFunction(function=launch_strat),
|
||||||
|
|||||||
Reference in New Issue
Block a user