Skip to content

Commit

Permalink
Enable the generation script to be run by ros2 run
Browse files Browse the repository at this point in the history
Signed-off-by: TaikiYamada4 <[email protected]>
  • Loading branch information
TaikiYamada4 committed Dec 26, 2024
1 parent 092b6d0 commit 0768432
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
5 changes: 5 additions & 0 deletions map/autoware_lanelet2_map_validator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
15 changes: 14 additions & 1 deletion map/autoware_lanelet2_map_validator/docs/how_to_contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 `<code_name>.cpp` and `<code_name.hpp>`
- `--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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 0768432

Please sign in to comment.