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(default_ad_api): add localization api #1431

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b6ede8b
feat(default_ad_api): add localization api
isamu-takagi Aug 2, 2022
ec2b06c
docs: add readme
isamu-takagi Aug 2, 2022
8c987eb
feat: add auto initial pose
isamu-takagi Aug 3, 2022
0dcffb2
Merge branch 'main' into feature/ad-api/localization
isamu-takagi Aug 10, 2022
d74888e
feat(autoware_ad_api_msgs): define localization interface
isamu-takagi Aug 10, 2022
20dba3f
Merge branch 'feature/ad-api/localization-interface' into feature/ad-…
isamu-takagi Aug 10, 2022
6f51ee0
fix(default_ad_api): fix interface definition
isamu-takagi Aug 24, 2022
ee6b428
feat(default_ad_api): modify interface version api to use spec package
isamu-takagi Aug 24, 2022
fdde4f2
feat(default_ad_api): modify interface version api to use spec package
isamu-takagi Aug 24, 2022
905ecfb
fix: pre-commit
isamu-takagi Aug 24, 2022
6b5a07d
Merge branch 'feature/ad-api/modify-interface-version' of github.com:…
isamu-takagi Aug 24, 2022
92b5c7e
fix: pre-commit
isamu-takagi Aug 24, 2022
2a0bc7e
fix: pre-commit
isamu-takagi Aug 24, 2022
5ec7d38
Merge branch 'feature/ad-api/modify-interface-version' into feature/a…
isamu-takagi Aug 24, 2022
b423776
Merge branch 'main' into feature/ad-api/localization-interface
isamu-takagi Aug 25, 2022
566554e
Merge branch 'feature/ad-api/localization-interface' into feature/ad-…
isamu-takagi Aug 25, 2022
122701c
Merge branch 'feature/ad-api/localization' of github.com:isamu-takagi…
isamu-takagi Aug 25, 2022
e5db1a7
fix: copyright
isamu-takagi Aug 25, 2022
7f6cfda
feat: split helper package
isamu-takagi Aug 25, 2022
bc02465
fix: change topic name to local
isamu-takagi Aug 25, 2022
acdfc3f
fix: style
isamu-takagi Aug 25, 2022
f4ce862
fix: style
isamu-takagi Aug 25, 2022
cf1f540
fix: style
isamu-takagi Aug 25, 2022
b94a6d8
fix: remove needless keyword
isamu-takagi Aug 25, 2022
5431400
Merge branch 'main' into feature/ad-api/localization
isamu-takagi Aug 26, 2022
925589b
Merge branch 'main' into feature/ad-api/localization
isamu-takagi Aug 26, 2022
2af3217
feat: change api helper node namespace
isamu-takagi Aug 26, 2022
7eaefe2
Merge branch 'main' into feature/ad-api/localization
isamu-takagi Aug 26, 2022
de6a32c
fix: fix launch file path
isamu-takagi Aug 26, 2022
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
2 changes: 2 additions & 0 deletions common/autoware_ad_api_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ autoware_package()
rosidl_generate_interfaces(${PROJECT_NAME}
common/msg/ResponseStatus.msg
interface/srv/InterfaceVersion.srv
localization/msg/LocalizationInitializationState.msg
localization/srv/InitializeLocalization.srv
DEPENDENCIES
builtin_interfaces
std_msgs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
uint16 UNKNOWN = 0
uint16 UNINITIALIZED = 1
uint16 INITIALIZING = 2
uint16 INITIALIZED = 3

builtin_interfaces/Time stamp
uint16 state
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
geometry_msgs/PoseWithCovarianceStamped[<=1] pose
---
uint16 ERROR_UNSAFE = 1
uint16 ERROR_GNSS_SUPPORT = 2
uint16 ERROR_GNSS = 3
uint16 ERROR_ESTIMATION = 4
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you write brief descriptions of these error types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error Description
ERROR_UNSAFE Requested when unsafe, such as while driving.
ERROR_GNSS_SUPPORT GNSS is not supported.
ERROR_GNSS GNSS is supported but an error related to GNSS occurred.
ERROR_ESTIMATION An error occurred while pose estimation.

autoware_ad_api_msgs/ResponseStatus status
7 changes: 7 additions & 0 deletions common/autoware_ad_api_specs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_ad_api_specs)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.

#ifndef AUTOWARE_AD_API_SPECS__LOCALIZATION_HPP_
#define AUTOWARE_AD_API_SPECS__LOCALIZATION_HPP_

#include <rclcpp/qos.hpp>

#include <autoware_ad_api_msgs/msg/localization_initialization_state.hpp>
#include <autoware_ad_api_msgs/srv/initialize_localization.hpp>

namespace autoware_ad_api::localization
{

struct Initialize
{
using Service = autoware_ad_api_msgs::srv::InitializeLocalization;
static constexpr char name[] = "/api/localization/initialize";
};

struct InitializationState
{
using Message = autoware_ad_api_msgs::msg::LocalizationInitializationState;
static constexpr char name[] = "/api/localization/initialization_state";
static constexpr size_t depth = 3;
static constexpr auto reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
static constexpr auto durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL;
};

} // namespace autoware_ad_api::localization

#endif // AUTOWARE_AD_API_SPECS__LOCALIZATION_HPP_
20 changes: 20 additions & 0 deletions common/autoware_ad_api_specs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autoware_ad_api_specs</name>
<version>0.0.0</version>
<description>The autoware_ad_api_specs package</description>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<build_depend>autoware_cmake</build_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
7 changes: 7 additions & 0 deletions common/component_interface_specs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.14)
project(component_interface_specs)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.

#ifndef COMPONENT_INTERFACE_SPECS__LOCALIZATION_HPP_
#define COMPONENT_INTERFACE_SPECS__LOCALIZATION_HPP_

#include <rclcpp/qos.hpp>

#include <autoware_ad_api_msgs/msg/localization_initialization_state.hpp>
#include <autoware_ad_api_msgs/srv/initialize_localization.hpp>

namespace localization_interface
{

struct Initialize
{
using Service = autoware_ad_api_msgs::srv::InitializeLocalization;
static constexpr char name[] = "/localization/initialize";
};

struct InitializationState
{
using Message = autoware_ad_api_msgs::msg::LocalizationInitializationState;
static constexpr char name[] = "/localization/initialization_state";
Copy link
Contributor

@kenji-miyake kenji-miyake Aug 10, 2022

Choose a reason for hiding this comment

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

@yukkysaito @mitsudome-r Do you have any opinions on the namings of Initialize and InitializationState?

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose these are okay.

static constexpr size_t depth = 3;
static constexpr auto reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
static constexpr auto durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL;
};

} // namespace localization_interface

#endif // COMPONENT_INTERFACE_SPECS__LOCALIZATION_HPP_
20 changes: 20 additions & 0 deletions common/component_interface_specs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>component_interface_specs</name>
<version>0.0.0</version>
<description>The component_interface_specs package</description>
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<build_depend>autoware_cmake</build_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
7 changes: 2 additions & 5 deletions launch/tier4_autoware_api_launch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ Please see `<exec_depend>` in `package.xml`.

## Usage

You can include as follows in `*.launch.xml` to use `control.launch.py`.
You can include as follows in `*.launch.xml` to use `autoware_api.launch.xml`.

```xml
<include file="$(find-pkg-share tier4_autoware_api_launch)/launch/autoware_api.launch.xml">
<arg name="init_simulator_pose" value="true"/>
<arg name="init_localization_pose" value="false"/>
</include>
<include file="$(find-pkg-share tier4_autoware_api_launch)/launch/autoware_api.launch.xml"/>
```

## Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<arg name="launch_calibration_status_api" default="false"/>
<arg name="launch_start_api" default="true"/>

<!-- AD API -->
<group>
<include file="$(find-pkg-share default_ad_api)/launch/default_ad_api.launch.py"/>
</group>

kenji-miyake marked this conversation as resolved.
Show resolved Hide resolved
<!-- awapi (deprecated) -->
<group>
<include file="$(find-pkg-share awapi_awiv_adapter)/launch/awapi_awiv_adapter.launch.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import launch
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode

Expand All @@ -29,12 +28,7 @@ def _create_api_node(node_name, class_name, **kwargs):


def generate_launch_description():
param_initial_pose = {
"init_simulator_pose": LaunchConfiguration("init_simulator_pose"),
"init_localization_pose": LaunchConfiguration("init_localization_pose"),
}
components = [
_create_api_node("initial_pose", "InitialPose", parameters=[param_initial_pose]),
_create_api_node("iv_msgs", "IVMsgs"),
_create_api_node("operator", "Operator"),
_create_api_node("route", "Route"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
name="crosswalk_states"
args="/api/autoware/set/crosswalk_states /planning/scenario_planning/lane_driving/behavior_planning/behavior_velocity_planner/input/external_crosswalk_states"
/>

<!-- TODO(Takagi, Isamu): workaround for topic check -->
<node pkg="topic_tools" exec="relay" name="initial_pose_2d" args="/initialpose /initialpose2d"/>
</group>
</launch>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- pose_initializer -->
<group>
<include file="$(find-pkg-share pose_initializer)/launch/pose_initializer.launch.xml"/>
<include file="$(find-pkg-share default_ad_api_helpers)/launch/auto_pose_init.launch.xml"/>
</group>
<!-- util -->
<group>
Expand Down
6 changes: 5 additions & 1 deletion system/default_ad_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ autoware_package()

ament_auto_add_library(${PROJECT_NAME} SHARED
src/interface.cpp
src/localization.cpp
)

rclcpp_components_register_nodes(${PROJECT_NAME} "default_ad_api::InterfaceNode")
rclcpp_components_register_nodes(${PROJECT_NAME}
"default_ad_api::InterfaceNode"
"default_ad_api::LocalizationNode"
)

if(BUILD_TESTING)
add_launch_test(test/main.test.py)
Expand Down
1 change: 1 addition & 0 deletions system/default_ad_api/launch/default_ad_api.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _create_api_node(node_name, class_name, **kwargs):
def generate_launch_description():
components = [
_create_api_node("interface", "InterfaceNode"),
_create_api_node("localization", "LocalizationNode"),
]
container = ComposableNodeContainer(
namespace="default_ad_api",
Expand Down
2 changes: 2 additions & 0 deletions system/default_ad_api/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<build_depend>autoware_cmake</build_depend>

<depend>autoware_ad_api_msgs</depend>
<depend>autoware_ad_api_specs</depend>
<depend>component_interface_specs</depend>
<depend>component_interface_utils</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
Expand Down
32 changes: 32 additions & 0 deletions system/default_ad_api/src/localization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.

#include "localization.hpp"

namespace default_ad_api
{

LocalizationNode::LocalizationNode(const rclcpp::NodeOptions & options)
: Node("localization", options)
{
const auto node = component_interface_utils::NodeAdaptor(this);
kenji-miyake marked this conversation as resolved.
Show resolved Hide resolved
group_srv_ = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
node.relay_message(pub_state_, sub_state_);
node.relay_service(cli_initialize_, srv_initialize_, group_srv_);
}

} // namespace default_ad_api

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(default_ad_api::LocalizationNode)
46 changes: 46 additions & 0 deletions system/default_ad_api/src/localization.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.

#ifndef LOCALIZATION_HPP_
#define LOCALIZATION_HPP_

#include <autoware_ad_api_specs/localization.hpp>
#include <component_interface_specs/localization.hpp>
#include <component_interface_utils/rclcpp.hpp>
#include <rclcpp/rclcpp.hpp>

using Initialize1 = autoware_ad_api::localization::Initialize;
using Initialize2 = localization_interface::Initialize;
using State1 = autoware_ad_api::localization::InitializationState;
using State2 = localization_interface::InitializationState;

namespace default_ad_api
{
kenji-miyake marked this conversation as resolved.
Show resolved Hide resolved

class LocalizationNode : public rclcpp::Node
{
public:
explicit LocalizationNode(const rclcpp::NodeOptions & options);

private:
rclcpp::CallbackGroup::SharedPtr group_srv_;
component_interface_utils::Service<Initialize1>::SharedPtr srv_initialize_;
component_interface_utils::Client<Initialize2>::SharedPtr cli_initialize_;
component_interface_utils::Publisher<State1>::SharedPtr pub_state_;
component_interface_utils::Subscription<State2>::SharedPtr sub_state_;
};

} // namespace default_ad_api

#endif // LOCALIZATION_HPP_
15 changes: 15 additions & 0 deletions system/default_ad_api_helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.14)
project(default_ad_api_helpers)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_executable(automatic_pose_initializer
src/automatic_pose_initializer.cpp
)

ament_auto_add_executable(initial_pose_adaptor
src/initial_pose_adaptor.cpp
)

ament_auto_package(INSTALL_TO_SHARE config launch)
23 changes: 23 additions & 0 deletions system/default_ad_api_helpers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# default_ad_api_helpers

## initial_pose_adaptor
kenji-miyake marked this conversation as resolved.
Show resolved Hide resolved

This node makes it easy to use the localization AD API from RViz.
When a initial pose topic is received, call the localization initialize API.
This node depends on fitting to map height service.

| Interface | Local Name | Global Name | Description |
| ------------ | -------------- | --------------------------------- | ----------------------------------------- |
| Subscription | initialpose | /initialpose | The pose for localization initialization. |
kenji-miyake marked this conversation as resolved.
Show resolved Hide resolved
| Client | fit_map_height | /localization/util/fit_map_height | To fix initial pose to map height |
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you tell me where this service is implemented, please?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've found it in #1500.

| Client | - | /api/localization/initialize | The localization initialize API. |

## automatic_pose_initializer

This node calls localization initialize API when the localization initialization state is uninitialized.
Since the API uses GNSS pose when no pose is specified, initialization using GNSS can be performed automatically.

| Interface | Local Name | Global Name | Description |
| ------------ | ---------- | -------------------------------------- | ------------------------------------------ |
| Subscription | - | /api/localization/initialization_state | The localization initialization state API. |
| Client | - | /api/localization/initialize | The localization initialize API. |
Loading