Skip to content

Commit

Permalink
Add toggle on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Sep 30, 2024
1 parent 7699e46 commit 99c5a45
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 38 deletions.
2 changes: 1 addition & 1 deletion basic_travel_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 LEIDOS.
# Copyright (C) 2024 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
Expand Down
9 changes: 6 additions & 3 deletions basic_travel_simulator/config/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# Recommended: Match with controller's frequency
pose_pub_rate: 30.0

# Increase more to help avoid going back and forth
# when speed is low and keeps getting same trajectory
# better tracks trajectory if kept low [0, inf]
# When speed is low, the simulator struggles to
# move the car forward consistently and the
# car may oscillate back and forth. Increase to help
# avoid this issue.It means to consider
# the next trajectory point that is traj_idx_buffer
# further ahead in the trajectory. [0, inf]
traj_idx_buffer: 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 LEIDOS.
* Copyright (C) 2024 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
/*
* Copyright (C) 2022 LEIDOS.
* Copyright (C) 2024 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
48 changes: 23 additions & 25 deletions basic_travel_simulator/launch/ basic_travel_simulator.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 LEIDOS.
# Copyright (C) 2024 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
Expand All @@ -23,46 +23,44 @@
import os


'''
"""
This file is can be used to launch the CARMA basic_travel_simulator node.
Though in carma-platform it may be launched directly from the base launch file.
'''
"""


def generate_launch_description():

# Declare the log_level launch argument
log_level = LaunchConfiguration('log_level')
log_level = LaunchConfiguration("log_level")
declare_log_level_arg = DeclareLaunchArgument(
name ='log_level', default_value='WARN')

name="log_level", default_value="WARN"
)

# Get parameter file path
param_file_path = os.path.join(
get_package_share_directory('basic_travel_simulator'), 'config/parameters.yaml')
get_package_share_directory("basic_travel_simulator"), "config/parameters.yaml"
)


# Launch node(s) in a carma container to allow logging to be configured
container = ComposableNodeContainer(
package='carma_ros2_utils',
name='basic_travel_simulator_container',
package="carma_ros2_utils",
name="basic_travel_simulator_container",
namespace=GetCurrentNamespace(),
executable='carma_component_container_mt',
executable="carma_component_container_mt",
composable_node_descriptions=[

# Launch the core node(s)
ComposableNode(
package='basic_travel_simulator',
plugin='basic_travel_simulator::Node',
name='basic_travel_simulator',
extra_arguments=[
{'use_intra_process_comms': True},
{'--log-level' : log_level }
],
parameters=[ ]
package="basic_travel_simulator",
plugin="basic_travel_simulator::Node",
name="basic_travel_simulator",
extra_arguments=[
{"use_intra_process_comms": True},
{"--log-level": log_level},
],
parameters=[],
),
]
],
)

return LaunchDescription([
declare_log_level_arg,
container
])
return LaunchDescription([declare_log_level_arg, container])
2 changes: 1 addition & 1 deletion basic_travel_simulator/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>

<!--
Copyright (C) 2022 LEIDOS.
Copyright (C) 2024 LEIDOS.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
Expand Down
2 changes: 1 addition & 1 deletion basic_travel_simulator/src/basic_travel_simulator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 LEIDOS.
* Copyright (C) 2024 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
2 changes: 1 addition & 1 deletion basic_travel_simulator/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 LEIDOS.
* Copyright (C) 2024 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
2 changes: 1 addition & 1 deletion basic_travel_simulator/test/TestMain.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 LEIDOS.
* Copyright (C) 2024 LEIDOS.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down
12 changes: 11 additions & 1 deletion carma/launch/carma_src.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def generate_launch_description():
description = "Path to file containing unique vehicle characteristics"
)

# Enables/disables the basic travel simulator in carma-platform only local simulation environment
enable_basic_travel_simulator = LaunchConfiguration('enable_basic_travel_simulator')
declare_enable_basic_travel_simulator_arg = DeclareLaunchArgument(
'enable_basic_travel_simulator',
default_value='false',
description='Enable or disable the basic travel simulator'
)

# Declare the vehicle_config_param_file launch argument
vehicle_config_param_file = LaunchConfiguration('vehicle_config_param_file')
declare_vehicle_config_param_file_arg = DeclareLaunchArgument(
Expand Down Expand Up @@ -250,7 +258,8 @@ def generate_launch_description():
'arealist_path' : arealist_path,
'vector_map_file' : vector_map_file,
'vehicle_calibration_dir': vehicle_calibration_dir,
'use_sim_time' : use_sim_time
'use_sim_time' : use_sim_time,
'enable_basic_travel_simulator': enable_basic_travel_simulator
}.items()
)
]
Expand Down Expand Up @@ -352,6 +361,7 @@ def generate_launch_description():
declare_arealist_path,
declare_vector_map_file,
declare_is_ros2_tracing_enabled,
declare_enable_basic_travel_simulator_arg,
drivers_group,
transform_group,
environment_group,
Expand Down
14 changes: 12 additions & 2 deletions carma/launch/localization.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument


import os

from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import GroupAction
from launch_ros.actions import set_remap
from launch.conditions import IfCondition
from launch.conditions import UnlessCondition
from launch.substitutions import LaunchConfiguration, PythonExpression

Expand All @@ -51,8 +53,14 @@ def generate_launch_description():
description = "Path to file containing override parameters for the subsystem controller"
)

enable_basic_travel_simulator = LaunchConfiguration('enable_basic_travel_simulator')
declare_enable_basic_travel_simulator_arg = DeclareLaunchArgument(
'enable_basic_travel_simulator',
default_value='false',
description='Enable or disable the basic travel simulator'
)

# Nodes
# TODO add ROS2 localization nodes here

gnss_to_map_convertor_param_file = os.path.join(
get_package_share_directory('gnss_to_map_convertor'), 'config/parameters.yaml')
Expand Down Expand Up @@ -134,6 +142,7 @@ def generate_launch_description():
])

basic_travel_simulator_container = ComposableNodeContainer(
condition=IfCondition(enable_basic_travel_simulator),
package='carma_ros2_utils',
name='basic_travel_simulator_container',
executable='carma_component_container_mt',
Expand All @@ -152,7 +161,7 @@ def generate_launch_description():
("current_pose", [ EnvironmentVariable('CARMA_LOCZ_NS', default_value=''), "/selected_pose" ] ),
("plan_trajectory", [ EnvironmentVariable('CARMA_GUIDE_NS', default_value=''), "/plan_trajectory" ] ),
],
parameters=[ ]
parameters=[ basic_travel_simulator_param_file ]
)
])

Expand Down Expand Up @@ -407,6 +416,7 @@ def generate_launch_description():
declare_arealist_path,
declare_map_file,
declare_use_sim_time_arg,
declare_enable_basic_travel_simulator_arg,
gnss_to_map_convertor_container,
basic_travel_simulator_container,
localization_manager_container,
Expand Down

0 comments on commit 99c5a45

Please sign in to comment.