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.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, Shutdown, RegisterEventHandler
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction, Shutdown, RegisterEventHandler, TimerAction
|
||||
from launch.conditions import IfCondition
|
||||
from launch.event_handlers import OnProcessExit
|
||||
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
|
||||
import os
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Declare launch arguments
|
||||
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_strat = LaunchConfiguration('with_strat')
|
||||
|
||||
# Conditionally include RPLIDAR launch
|
||||
rplidar_launch = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('rplidar_ros'),
|
||||
'launch',
|
||||
'rplidar_a1_launch.py'
|
||||
# Function to launch RPLIDAR node with a delay
|
||||
def launch_rplidar_with_delay(context, *args, **kwargs):
|
||||
if context.launch_configurations.get('with_rplidar') == 'true':
|
||||
# TimerAction to delay the start of RPLIDAR
|
||||
start_rplidar = TimerAction(
|
||||
period=5.0, # Delay of 10 seconds before launching RPLIDAR
|
||||
actions=[
|
||||
Node(
|
||||
package='rplidar_ros',
|
||||
executable='rplidar_node',
|
||||
name='rplidar_node',
|
||||
output='screen'
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
condition=IfCondition(with_rplidar)
|
||||
)
|
||||
return [start_rplidar]
|
||||
return []
|
||||
|
||||
# Function to launch GUI and shutdown handler
|
||||
def launch_gui(context, *args, **kwargs):
|
||||
@@ -77,7 +82,9 @@ def generate_launch_description():
|
||||
with_com_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_com),
|
||||
OpaqueFunction(function=launch_strat),
|
||||
|
||||
Reference in New Issue
Block a user