mirror of
https://github.com/modelec/modelec-marcel-ROS.git
synced 2026-01-18 16:47:43 +01:00
launch file with sone param
This commit is contained in:
@@ -1,28 +1,48 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import RegisterEventHandler, Shutdown, IncludeLaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, RegisterEventHandler, Shutdown, IncludeLaunchDescription
|
||||
from launch.conditions import IfCondition
|
||||
from launch.event_handlers import OnProcessExit
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import Node
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
import os
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Qt GUI node
|
||||
# Declare arguments
|
||||
with_gui_arg = DeclareLaunchArgument(
|
||||
'with_gui',
|
||||
default_value='true',
|
||||
description='Whether to launch the GUI'
|
||||
)
|
||||
|
||||
with_rplidar_arg = DeclareLaunchArgument(
|
||||
'with_rplidar',
|
||||
default_value='true',
|
||||
description='Whether to launch the RPLIDAR'
|
||||
)
|
||||
|
||||
with_gui = LaunchConfiguration('with_gui')
|
||||
with_rplidar = LaunchConfiguration('with_rplidar')
|
||||
|
||||
# GUI node
|
||||
gui_node = Node(
|
||||
package='modelec_gui',
|
||||
executable='modelec_gui',
|
||||
name='modelec_gui'
|
||||
name='modelec_gui',
|
||||
condition=IfCondition(with_gui)
|
||||
)
|
||||
|
||||
# Shut down all nodes when GUI exits
|
||||
shutdown_on_gui_exit = RegisterEventHandler(
|
||||
OnProcessExit(
|
||||
target_action=gui_node,
|
||||
on_exit=[Shutdown()]
|
||||
on_exit=[Shutdown()],
|
||||
condition=IfCondition(with_gui)
|
||||
)
|
||||
)
|
||||
|
||||
# Include the RPLIDAR launch file
|
||||
# RPLIDAR node
|
||||
rplidar_launch = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
@@ -30,47 +50,21 @@ def generate_launch_description():
|
||||
'launch',
|
||||
'rplidar_a1_launch.py'
|
||||
)
|
||||
)
|
||||
),
|
||||
condition=IfCondition(with_rplidar)
|
||||
)
|
||||
|
||||
return LaunchDescription([
|
||||
with_gui_arg,
|
||||
with_rplidar_arg,
|
||||
rplidar_launch,
|
||||
|
||||
Node(
|
||||
package='modelec_com',
|
||||
executable='serial_listener',
|
||||
name='serial_listener'
|
||||
),
|
||||
Node(
|
||||
package='modelec_com',
|
||||
executable='pcb_odo_interface',
|
||||
name='pcb_odo_interface'
|
||||
),
|
||||
Node(
|
||||
package='modelec_com',
|
||||
executable='pcb_alim_interface',
|
||||
name='pcb_alim_interface'
|
||||
),
|
||||
Node(
|
||||
package='modelec_com',
|
||||
executable='pcb_action_interface',
|
||||
name='pcb_action_interface'
|
||||
),
|
||||
gui_node,
|
||||
shutdown_on_gui_exit,
|
||||
Node(
|
||||
package='modelec_strat',
|
||||
executable='strat_fsm',
|
||||
name='strat_fsm'
|
||||
),
|
||||
Node(
|
||||
package='modelec_strat',
|
||||
executable='pami_manager',
|
||||
name='pami_manager'
|
||||
),
|
||||
Node(
|
||||
package='modelec_strat',
|
||||
executable='enemy_manager',
|
||||
name='enemy_manager'
|
||||
)
|
||||
Node(package='modelec_com', executable='serial_listener', name='serial_listener'),
|
||||
Node(package='modelec_com', executable='pcb_odo_interface', name='pcb_odo_interface'),
|
||||
Node(package='modelec_com', executable='pcb_alim_interface', name='pcb_alim_interface'),
|
||||
Node(package='modelec_com', executable='pcb_action_interface', name='pcb_action_interface'),
|
||||
Node(package='modelec_strat', executable='strat_fsm', name='strat_fsm'),
|
||||
Node(package='modelec_strat', executable='pami_manager', name='pami_manager'),
|
||||
Node(package='modelec_strat', executable='enemy_manager', name='enemy_manager')
|
||||
])
|
||||
|
||||
@@ -54,7 +54,10 @@ namespace Modelec
|
||||
|
||||
timer_ = this->create_wall_timer(
|
||||
std::chrono::seconds(1),
|
||||
std::bind(&EnemyManager::TimerCallback, this)
|
||||
[this]()
|
||||
{
|
||||
TimerCallback();
|
||||
}
|
||||
);
|
||||
|
||||
last_publish_time_ = this->now();
|
||||
|
||||
Reference in New Issue
Block a user