Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vehicle_info_util): add script to calculate turning radius #1855

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vehicle/vehicle_info_util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ ament_auto_package(
config
launch
)

install(PROGRAMS
scripts/min_turning_radius_calculator.py
TakaHoribe marked this conversation as resolved.
Show resolved Hide resolved
DESTINATION lib/${PROJECT_NAME}
)
16 changes: 16 additions & 0 deletions vehicle/vehicle_info_util/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ This package is to get vehicle info parameters.

In [here](https://autowarefoundation.github.io/autoware-documentation/main/design/autoware-interfaces/components/vehicle-dimensions/), you can check the vehicle dimensions with more detail.

### Scripts

#### Minimum turning radius

```sh
$ ros2 run vehicle_info_util min_turning_radius_calculator.py
yaml path is /home/autoware/pilot-auto/install/vehicle_info_util/share/vehicle_info_util/config/vehicle_info.param.yaml
Minimum turning radius is 4.253220695862465 [m]
```

You can designate yaml file with `-y` option as follows.

```sh
ros2 run vehicle_info_util min_turning_radius_calculator.py -y <path-to-yaml>
```

## Assumptions / Known limits

TBD.
48 changes: 48 additions & 0 deletions vehicle/vehicle_info_util/scripts/min_turning_radius_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3

# Copyright 2022 Tier IV, Inc.
#
# 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 math

from ament_index_python.packages import get_package_share_directory
import yaml


def main(yaml_path):
with open(yaml_path) as f:
config = yaml.safe_load(f)

wheel_base = config["/**"]["ros__parameters"]["wheel_base"]
max_steer_angle = config["/**"]["ros__parameters"]["max_steer_angle"]

print("yaml path is {}".format(yaml_path))
print("Minimum turning radius is {} [m]".format(wheel_base / math.sin(max_steer_angle)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to show the definition of the radius since the formula depends on how you define the radius. If it is for the rear wheel, the equation should be

radius = wheel_base / tan(steer)

If it is for front steer, it will be

radius = wheel_base / sin(steer)

Maybe it is nice to print both, like

Minimum turning radius is 4.40 [m] for rear, 4.45[m] for front

Copy link
Contributor Author

@takayuki5168 takayuki5168 Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the better idea.

50746d6
DONE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!



if __name__ == "__main__":
default_yaml_path = (
get_package_share_directory("vehicle_info_util") + "/config/vehicle_info.param.yaml"
)

parser = argparse.ArgumentParser()
parser.add_argument(
"-y", "--yaml", default=default_yaml_path, help="vehicle_info.param.yaml path"
)

args = parser.parse_args()
yaml_path = args.yaml

main(yaml_path)