From 07684326011e1c24951da8ff0a756375a91f34ad Mon Sep 17 00:00:00 2001 From: TaikiYamada4 Date: Thu, 26 Dec 2024 15:37:34 +0900 Subject: [PATCH] Enable the generation script to be run by `ros2 run` Signed-off-by: TaikiYamada4 --- .../CMakeLists.txt | 5 +++++ .../docs/how_to_contribute.md | 15 ++++++++++++++- .../template/create_new_validator.py | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/CMakeLists.txt b/map/autoware_lanelet2_map_validator/CMakeLists.txt index 36776605..3d5e1789 100644 --- a/map/autoware_lanelet2_map_validator/CMakeLists.txt +++ b/map/autoware_lanelet2_map_validator/CMakeLists.txt @@ -31,6 +31,11 @@ target_link_libraries(autoware_lanelet2_map_validator autoware_lanelet2_map_validator_lib ) +install(PROGRAMS + template/create_new_validator.py + DESTINATION lib/${PROJECT_NAME} +) + if(BUILD_TESTING) file(GLOB_RECURSE test_src "test/src/test_*.cpp") ament_auto_add_library(autoware_lanelet2_map_validator_test_lib ${test_src}) diff --git a/map/autoware_lanelet2_map_validator/docs/how_to_contribute.md b/map/autoware_lanelet2_map_validator/docs/how_to_contribute.md index 19ce474d..6689b2ee 100644 --- a/map/autoware_lanelet2_map_validator/docs/how_to_contribute.md +++ b/map/autoware_lanelet2_map_validator/docs/how_to_contribute.md @@ -50,7 +50,19 @@ You can use the script [`create_new_validator.py`](https://github.com/autowarefo You can use this by the command like this example: ```shell -python3 create_new_validator.py \ +create_new_validator.py \ +--base_directory ./ \ +--category_name traffic_light \ +--code_name traffic_light_facing \ +--class_name TrafficLightFacingValidator \ +--validator_name mapping.traffic_light.correct_facing \ +--check_function_name check_traffic_light_facing +``` + +OR + +```shell +ros2 run autoware_lanelet2_map_validator create_new_validator.py \ --base_directory ./ \ --category_name traffic_light \ --code_name traffic_light_facing \ @@ -63,6 +75,7 @@ All arguments are required. - `--base_directory`: The directory to the `autoware_lanelet2_map_validator` package. - `--category_name`: The category (like lanelet, traffic_light...) where your validator belongs to. Look [Design Concept](#design-concept) to see the list of categories. +- `--code_name`: The name for the files. The source code names will be like `.cpp` and `` - `--class_name`: The base class name of your validator which will be defined in your new header file. - `--validator_name`: The name of the validator which will be displayed when `autoware_lanelet2_map_validator` is executed with a `--print` option. The naming rules are explained in [Restrictions for validator class implementation](#restrictions-for-validator-class-implementation). - `--check_function_name`: The main function name of your validator which will be defined in your header file, and its implementation will be written in the cpp source file. diff --git a/map/autoware_lanelet2_map_validator/template/create_new_validator.py b/map/autoware_lanelet2_map_validator/template/create_new_validator.py index b704843d..da64764e 100755 --- a/map/autoware_lanelet2_map_validator/template/create_new_validator.py +++ b/map/autoware_lanelet2_map_validator/template/create_new_validator.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python3 + +# Copyright 2024 TIER IV, Inc. All rights reserved. +# +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import argparse import os import shutil @@ -13,7 +29,7 @@ def create_files( base_directory, "src/include/lanelet2_map_validator/validators", category_name ) docs_directory = os.path.join(base_directory, "docs", category_name) - test_directory = os.path.join(base_directory, "test/src") + test_directory = os.path.join(base_directory, "test/src", category_name) # Define source and destination file paths cpp_template = os.path.join(template_directory, "validator_template.cpp")