I want my service node to run when Turtlebot boots up.
I have tried editing the bot's bringup files to add a call to launch file of my robot, but that didn't work and just broke the bringup completely.
Edited bringup launch file:
from ament_index_python.packages import get_package_share_directory
from launch import LaunchContext, LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import EnvironmentVariable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import PushRosNamespace
from nav2_common.launch import RewrittenYaml
def generate_launch_description():
lc = LaunchContext()
ld = LaunchDescription()
diagnostics_enable = EnvironmentVariable('TURTLEBOT4_DIAGNOSTICS', default_value='1')
namespace = EnvironmentVariable('ROBOT_NAMESPACE', default_value='')
pkg_turtlebot4_bringup = get_package_share_directory('turtlebot4_bringup')
pkg_turtlebot4_diagnostics = get_package_share_directory('turtlebot4_diagnostics')
pkg_turtlebot4_description = get_package_share_directory('turtlebot4_description')
pkg_local_navigation = get_package_share_directory('navigation_node') # MY PACKAGE
param_file_cmd = DeclareLaunchArgument(
'param_file',
default_value=PathJoinSubstitution(
[pkg_turtlebot4_bringup, 'config', 'turtlebot4.yaml']),
description='Turtlebot4 Robot param file'
)
param_file = LaunchConfiguration('param_file')
namespaced_param_file = RewrittenYaml(
source_file=param_file,
root_key=namespace,
param_rewrites={},
convert_types=True)
# Launch files
turtlebot4_robot_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_bringup, 'launch', 'robot.launch.py'])
joy_teleop_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_bringup, 'launch', 'joy_teleop.launch.py'])
diagnostics_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_diagnostics, 'launch', 'diagnostics.launch.py'])
rplidar_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_bringup, 'launch', 'rplidar.launch.py'])
oakd_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_bringup, 'launch', 'oakd.launch.py'])
description_launch_file = PathJoinSubstitution(
[pkg_turtlebot4_description, 'launch', 'robot_description.launch.py'])
# MY LAUNCH FILE PATH
navigation_launch_file = PathJoinSubstitution(
[pkg_local_navigation, 'launch', 'local_navigaton.launch.py'])
actions = [
PushRosNamespace(namespace),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([turtlebot4_robot_launch_file]),
launch_arguments=[('model', 'standard'),
('param_file', namespaced_param_file)]),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([joy_teleop_launch_file]),
launch_arguments=[('namespace', namespace)]),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([rplidar_launch_file])),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([oakd_launch_file]),
launch_arguments=[('camera', 'oakd_pro')]),
IncludeLaunchDescription(
PythonLaunchDescriptionSource([description_launch_file]),
launch_arguments=[('model', 'standard')]),
# MY LAUNCH DESCRIPTION
IncludeLaunchDescription(
PythonLaunchDescriptionSource([navigation_launch_file]),
launch_arguments=[('namespace',namespace),
('map', home/ubuntu/map_aula.yaml)])
]
if (diagnostics_enable.perform(lc)) == '1':
actions.append(IncludeLaunchDescription(
PythonLaunchDescriptionSource([diagnostics_launch_file]),
launch_arguments=[('namespace', namespace)]))
turtlebot4_standard = GroupAction(actions)
ld = LaunchDescription()
ld.add_action(param_file_cmd)
ld.add_action(turtlebot4_standard)
return ld
Is there a proper way to do this or am I doomed to some hack?