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: add vehicle info util #22

Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e6172d5
vehicle_info_util package for ROS2 port (#58)
nnmm Nov 30, 2021
c7de365
[vehicle_info_util] Build as shared library (#112)
fred-apex-ai Nov 30, 2021
9f1db1d
[ROS2] Fix behavior velocity planner (#110)
mitsudome-r Nov 30, 2021
4fcad13
Adjust copyright notice on 532 out of 699 source files (#143)
nnmm Nov 30, 2021
4288d2c
Use quotes for includes where appropriate (#144)
nnmm Nov 30, 2021
9013bdd
Run uncrustify on the entire Pilot.Auto codebase (#151)
nnmm Nov 30, 2021
d9dee2a
ROS2 Linting: vehicle_info_util (#163)
jilaada Nov 30, 2021
edb6f0c
Sync public repo (#1228)
mitsudome-r Nov 30, 2021
fb93faf
Remove vehicle info param server (#1304)
wep21 Nov 30, 2021
7f73d7d
Refactor vehicle info util (#1305)
kenji-miyake Nov 30, 2021
3141f0f
Fix/fix utils (#1310)
kenji-miyake Nov 30, 2021
75f2852
Move autoware_global_parameter_loader to the appropriate place (#1701)
kenji-miyake Nov 30, 2021
78b7dab
suppress warnings for declare parameters (#1724)
h-ohta Nov 30, 2021
6ffce48
Fix -Wunused-parameter (#1836)
kenji-miyake Nov 30, 2021
824ac2d
Rename vehicle_info param arg to avoid conflicts (#2074)
kenji-miyake Nov 30, 2021
cf130b1
Change formatter to clang-format and black (#2332)
kenji-miyake Nov 30, 2021
e872a90
Add COLCON_IGNORE (#500)
kenji-miyake Nov 30, 2021
a97181c
remove COLCON_IGNORE (#505)
takayuki5168 Nov 30, 2021
bcb5abc
[vehicle_info_util] add readme (#560)
taikitanaka3 Nov 30, 2021
c096097
add default config file
taikitanaka3 Nov 30, 2021
58688eb
add sample launch
taikitanaka3 Dec 1, 2021
c4526fb
ci(pre-commit): autofix
pre-commit-ci[bot] Dec 1, 2021
eb5ae99
remove unused
taikitanaka3 Dec 1, 2021
828800e
Merge branch 'tier4/proposal' into filter/vehicle_info_util
taikitanaka3 Dec 2, 2021
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
31 changes: 31 additions & 0 deletions vehicle/vehicle_info_util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 3.5)
project(vehicle_info_util)

### Compile options
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
endif()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()


ament_auto_add_library(vehicle_info_util SHARED
src/vehicle_info_util.cpp
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(
INSTALL_TO_SHARE
config
launch
)
13 changes: 13 additions & 0 deletions vehicle/vehicle_info_util/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Vehicle Info Util

## Purpose

This package is to get vehicle info parameters.

### Description

![description](./media/vehicle_info.drawio.svg)

## Assumptions / Known limits

TBD.
11 changes: 11 additions & 0 deletions vehicle/vehicle_info_util/config/vehicle_info.param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**:
ros__parameters:
wheel_radius: 0.39
wheel_width: 0.42
wheel_base: 2.74 # between front wheel center and rear wheel center
wheel_tread: 1.63 # between left wheel center and right wheel center
front_overhang: 1.0 # between front wheel center and vehicle front
rear_overhang: 1.03 # between rear wheel center and vehicle rear
left_overhang: 0.1 # between left wheel center and vehicle left
right_overhang: 0.1 # between right wheel center and vehicle right
vehicle_height: 2.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright 2015-2021 Autoware Foundation
//
// 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.

#ifndef VEHICLE_INFO_UTIL__VEHICLE_INFO_HPP_
#define VEHICLE_INFO_UTIL__VEHICLE_INFO_HPP_

namespace vehicle_info_util
{
/// Data class for vehicle info
struct VehicleInfo
{
// Base parameters. These describe the vehicle's bounding box and the
// position and radius of the wheels.
double wheel_radius_m;
double wheel_width_m;
double wheel_base_m;
double wheel_tread_m;
double front_overhang_m;
double rear_overhang_m;
double left_overhang_m;
double right_overhang_m;
double vehicle_height_m;

// Derived parameters, i.e. calculated from base parameters
// The offset values are relative to the base frame origin, which is located
// on the ground below the middle of the rear axle, and can be negative.
double vehicle_length_m;
double vehicle_width_m;
double min_longitudinal_offset_m;
double max_longitudinal_offset_m;
double min_lateral_offset_m;
double max_lateral_offset_m;
double min_height_offset_m;
double max_height_offset_m;
};

/// Create vehicle info from base parameters
inline VehicleInfo createVehicleInfo(
const double wheel_radius_m, const double wheel_width_m, const double wheel_base_m,
const double wheel_tread_m, const double front_overhang_m, const double rear_overhang_m,
const double left_overhang_m, const double right_overhang_m, const double vehicle_height_m)
{
// Calculate derived parameters
const double vehicle_length_m_ = front_overhang_m + wheel_base_m + rear_overhang_m;
const double vehicle_width_m_ = wheel_tread_m + left_overhang_m + right_overhang_m;
const double min_longitudinal_offset_m_ = -rear_overhang_m;
const double max_longitudinal_offset_m_ = front_overhang_m + wheel_base_m;
const double min_lateral_offset_m_ = -(wheel_tread_m / 2.0 + right_overhang_m);
const double max_lateral_offset_m_ = wheel_tread_m / 2.0 + left_overhang_m;
const double min_height_offset_m_ = 0.0;
const double max_height_offset_m_ = vehicle_height_m;

return VehicleInfo{
// Base parameters
wheel_radius_m,
wheel_width_m,
wheel_base_m,
wheel_tread_m,
front_overhang_m,
rear_overhang_m,
left_overhang_m,
right_overhang_m,
vehicle_height_m,
// Derived parameters
vehicle_length_m_,
vehicle_width_m_,
min_longitudinal_offset_m_,
max_longitudinal_offset_m_,
min_lateral_offset_m_,
max_lateral_offset_m_,
min_height_offset_m_,
max_height_offset_m_,
};
}
} // namespace vehicle_info_util

#endif // VEHICLE_INFO_UTIL__VEHICLE_INFO_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2015-2021 Autoware Foundation
//
// 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.

#ifndef VEHICLE_INFO_UTIL__VEHICLE_INFO_UTIL_HPP_
#define VEHICLE_INFO_UTIL__VEHICLE_INFO_UTIL_HPP_

#include "vehicle_info_util/vehicle_info.hpp"

#include <rclcpp/rclcpp.hpp>

namespace vehicle_info_util
{
/// This is a convenience class for saving you from declaring all parameters
/// manually and calculating derived parameters.
/// This class supposes that necessary parameters are set when the node is launched.
class VehicleInfoUtil
{
public:
/// Constructor
explicit VehicleInfoUtil(rclcpp::Node & node);

/// Get vehicle info
VehicleInfo getVehicleInfo();

private:
/// Buffer for base parameters
VehicleInfo vehicle_info_;
};

} // namespace vehicle_info_util

#endif // VEHICLE_INFO_UTIL__VEHICLE_INFO_UTIL_HPP_
57 changes: 57 additions & 0 deletions vehicle/vehicle_info_util/launch/sample.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2021 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 os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.actions import OpaqueFunction
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import SetParameter
from launch_ros.substitutions import FindPackageShare


def launch_setup(context, *args, **kwargs):
# use_sim_time
set_use_sim_time = SetParameter(name="use_sim_time", value=LaunchConfiguration("use_sim_time"))

vehicle_info_param_path = os.path.join(
get_package_share_directory("vehicle_info_util"),
"config",
"vehicle_info.param.yaml",
)
# vehicle_info
load_vehicle_info = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[FindPackageShare("vehicle_info_util"), "/launch/vehicle_info.launch.py"]
),
launch_arguments={"vehicle_info_param_file": [vehicle_info_param_path]}.items(),
)

return [
set_use_sim_time,
load_vehicle_info,
]


def generate_launch_description():
return LaunchDescription(
[
DeclareLaunchArgument("use_sim_time", default_value="false"),
OpaqueFunction(function=launch_setup),
]
)
36 changes: 36 additions & 0 deletions vehicle/vehicle_info_util/launch/vehicle_info.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2021 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.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import OpaqueFunction
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import SetParameter
import yaml


def launch_setup(context, *args, **kwargs):
vehicle_param_file = LaunchConfiguration("vehicle_info_param_file").perform(context)
with open(vehicle_param_file, "r") as f:
vehicle_param = yaml.safe_load(f)["/**"]["ros__parameters"]
return [SetParameter(name=k, value=v) for (k, v) in vehicle_param.items()]


def generate_launch_description():
return LaunchDescription(
[
DeclareLaunchArgument("vehicle_info_param_file"),
taikitanaka3 marked this conversation as resolved.
Show resolved Hide resolved
OpaqueFunction(function=launch_setup),
]
)
Loading