From 9f2e63ce3a08192a83b2c0c26d08ca993e55e193 Mon Sep 17 00:00:00 2001 From: Tomoya Kimura Date: Tue, 14 Dec 2021 12:38:34 +0900 Subject: [PATCH] feat: add simulator_launch package (#166) * Add simulator_launch package (#459) * Add simulator_launch package * add argument * fix depend order * add argument * move dummy_perception_publisher * add arg for dummy_perception_publisher * Update simulator_launch/launch/simulator.launch.xml Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> * Move simple_planning_simulator to simulator_launch (#462) * move simple_planning_simulator * add simulation arg to logging_simulator.launch * delete unused argument * add arguments for logging simulation * change default value * update README * add default value to simulator arg * restore vehicle_simulation arg * Fix/revert initial engage state (#484) * Fix args Signed-off-by: Kenji Miyake * Add initial_engage_state to vehicle.launch.xml Signed-off-by: Kenji Miyake * Update vehicle.launch.xml * Change formatter to black (#488) * Update pre-commit settings * Apply Black * Replace ament_lint_common with autoware_lint_common * Update build_depends.repos * Fix build_depends * Auto/fix launch (#110) * fix namespace * remove dynamic_object_visualization * fix rviz * add default vehicle param file Signed-off-by: tomoya.kimura * ci(pre-commit): autofix * fix typo Signed-off-by: tomoya.kimura Co-authored-by: Keisuke Shima <19993104+KeisukeShima@users.noreply.github.com> Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Co-authored-by: Kenji Miyake Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: taikitanaka3 <65527974+taikitanaka3@users.noreply.github.com> --- launch/simulator_launch/CMakeLists.txt | 14 ++ launch/simulator_launch/README.md | 20 +++ .../launch/simulator.launch.xml | 40 ++++++ launch/simulator_launch/package.xml | 23 ++++ .../simulator_launch.drawio.svg | 4 + .../simple_planning_simulator.launch.py | 124 ++++++++++++------ 6 files changed, 183 insertions(+), 42 deletions(-) create mode 100644 launch/simulator_launch/CMakeLists.txt create mode 100644 launch/simulator_launch/README.md create mode 100644 launch/simulator_launch/launch/simulator.launch.xml create mode 100644 launch/simulator_launch/package.xml create mode 100644 launch/simulator_launch/simulator_launch.drawio.svg diff --git a/launch/simulator_launch/CMakeLists.txt b/launch/simulator_launch/CMakeLists.txt new file mode 100644 index 0000000000000..bbabec7ab1e8d --- /dev/null +++ b/launch/simulator_launch/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.5) +project(simulator_launch) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_auto_package(INSTALL_TO_SHARE + launch +) diff --git a/launch/simulator_launch/README.md b/launch/simulator_launch/README.md new file mode 100644 index 0000000000000..f53ac31f19376 --- /dev/null +++ b/launch/simulator_launch/README.md @@ -0,0 +1,20 @@ +# simulator_launch + +## Structure + +![simulator_launch](./simulator_launch.drawio.svg) + +## Package Dependencies + +Please see `` in `package.xml`. + +## Usage + +```xml + + + + +``` + +The simulator model used in simple_planning_simulator is loaded from "config/simulator_model.param.yaml" in the "`VEHICLE_MODEL`\_description" package. diff --git a/launch/simulator_launch/launch/simulator.launch.xml b/launch/simulator_launch/launch/simulator.launch.xml new file mode 100644 index 0000000000000..0bec3d13b6a35 --- /dev/null +++ b/launch/simulator_launch/launch/simulator.launch.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launch/simulator_launch/package.xml b/launch/simulator_launch/package.xml new file mode 100644 index 0000000000000..03d415a7a8eac --- /dev/null +++ b/launch/simulator_launch/package.xml @@ -0,0 +1,23 @@ + + + + simulator_launch + 0.1.0 + The simulator_launch package + + Keisuke Shima + Apache License 2.0 + + ament_cmake_auto + + dummy_perception_publisher + fault_injection + simple_planning_simulator + + ament_lint_auto + autoware_lint_common + + + ament_cmake + + diff --git a/launch/simulator_launch/simulator_launch.drawio.svg b/launch/simulator_launch/simulator_launch.drawio.svg new file mode 100644 index 0000000000000..d86b068066ab5 --- /dev/null +++ b/launch/simulator_launch/simulator_launch.drawio.svg @@ -0,0 +1,4 @@ + + + +
simulator.launch.xml

package: simulator_launch
simulator.launch.xml...
fault_injection.launch.xml

package: fault_injection
fault_injection.launch.xm...
simple_planning_simulator.launch.xml

package: simple_planning_simulator
simple_planning_simulator.launch.xml...
True
True
$(var vehicle_simulation)
$(var vehicle_simulation)
launch name

package: package name
launch name...
ex:
ex:
node name

package: package name
node name...
$(var scenario_simulation)
$(var scenario_simulation)
False
False
other name

package: package name
other name...
True
True
$(var scenario_simulation)
$(var scenario_simulation)
False
False
dummy_perception_publisher.launch.xml

package: dummy_perception_publisher
dummy_perception_publisher.launch.xml...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/simulator/simple_planning_simulator/launch/simple_planning_simulator.launch.py b/simulator/simple_planning_simulator/launch/simple_planning_simulator.launch.py index 3c46303bc6bd7..18593745a58da 100644 --- a/simulator/simple_planning_simulator/launch/simple_planning_simulator.launch.py +++ b/simulator/simple_planning_simulator/launch/simple_planning_simulator.launch.py @@ -12,53 +12,49 @@ # See the License for the specific language governing permissions and # limitations under the License. -import ament_index_python -import launch -import launch_ros.actions +import os +from ament_index_python.packages import get_package_share_directory +import launch from launch.actions import DeclareLaunchArgument +from launch.actions import GroupAction +from launch.actions import IncludeLaunchDescription +from launch.actions import OpaqueFunction +from launch.actions import SetLaunchConfiguration +from launch.conditions import IfCondition +from launch.conditions import UnlessCondition from launch.substitutions import LaunchConfiguration -from ament_index_python import get_package_share_directory - -import os - - -def generate_launch_description(): +from launch_ros.actions import ComposableNodeContainer +from launch_ros.actions import LoadComposableNodes +from launch_ros.actions import Node +from launch_ros.descriptions import ComposableNode +from launch_ros.substitutions import FindPackageShare +import yaml - default_vehicle_characteristics_param = os.path.join( - get_package_share_directory('simple_planning_simulator'), - 'param/vehicle_characteristics.param.yaml') +def launch_setup(context, *args, **kwargs): + # vehicle information param path + vehicle_info_param_path = LaunchConfiguration("vehicle_info_param_file").perform(context) + with open(vehicle_info_param_path, "r") as f: + vehicle_info_param = yaml.safe_load(f)["/**"]["ros__parameters"] - vehicle_characteristics_param = DeclareLaunchArgument( - 'vehicle_characteristics_param_file', - default_value=default_vehicle_characteristics_param, - description='Path to config file for vehicle characteristics' - ) - - default_vehicle_info_param = os.path.join( - get_package_share_directory('vehicle_info_util'), - 'config/vehicle_info.param.yaml') + vehicle_characteristics_param_path = LaunchConfiguration("vehicle_characteristics_param_file").perform(context) + with open(vehicle_characteristics_param_path, "r") as f: + vehicle_characteristics_param = yaml.safe_load(f)["/**"]["ros__parameters"] - vehicle_info_param = DeclareLaunchArgument( - 'vehicle_info_param_file', - default_value=default_vehicle_info_param, - description='Path to config file for vehicle information' - ) + simultor_model_param_path = LaunchConfiguration("simulator_model_param_file").perform(context) + with open(simultor_model_param_path, "r") as f: + simulator_model_param = yaml.safe_load(f)["/**"]["ros__parameters"] - simple_planning_simulator_node = launch_ros.actions.Node( + simple_planning_simulator_node = Node( package='simple_planning_simulator', executable='simple_planning_simulator_exe', name='simple_planning_simulator', namespace='simulation', output='screen', parameters=[ - "{}/param/simple_planning_simulator_default.param.yaml".format( - ament_index_python.get_package_share_directory( - "simple_planning_simulator" - ) - ), - LaunchConfiguration('vehicle_characteristics_param_file'), - LaunchConfiguration('vehicle_info_param_file') + vehicle_info_param, + vehicle_characteristics_param, + simulator_model_param, ], remappings=[ ('input/ackermann_control_command', '/control/command/control_cmd'), @@ -77,17 +73,61 @@ def generate_launch_description(): ] ) - map_to_odom_tf_publisher = launch_ros.actions.Node( + map_to_odom_tf_publisher = Node( package='tf2_ros', executable='static_transform_publisher', name='static_map_to_odom_tf_publisher', output='screen', arguments=['0.0', '0.0', '0.0', '0', '0', '0', 'map', 'odom']) - ld = launch.LaunchDescription([ - vehicle_characteristics_param, - vehicle_info_param, - simple_planning_simulator_node, - map_to_odom_tf_publisher - ]) - return ld + group = GroupAction( + [ + simple_planning_simulator_node, + map_to_odom_tf_publisher + ] + ) + + return [group] + + +def generate_launch_description(): + launch_arguments = [] + + def add_launch_arg(name: str, default_value=None, description=None): + launch_arguments.append( + DeclareLaunchArgument(name, default_value=default_value, description=description) + ) + + add_launch_arg( + "vehicle_info_param_file", + [ + FindPackageShare("vehicle_info_util"), + "/config/vehicle_info.param.yaml", + ], + "path to the parameter file of vehicle information", + ) + + add_launch_arg( + "vehicle_characteristics_param_file", + [ + FindPackageShare("simple_planning_simulator"), + "/param/vehicle_characteristics.param.yaml", + ], + "path to config file for vehicle characteristics", + ) + + add_launch_arg( + "simulator_model_param_file", + [ + FindPackageShare("simple_planning_simulator"), + "/param/simple_planning_simulator_default.param.yaml", + ], + "path to config file for simulator_model", + ) + + + + return launch.LaunchDescription( + launch_arguments + + [OpaqueFunction(function=launch_setup)] + )