Skip to content

Commit

Permalink
Add new architecture-type awf/universe/20250130
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Jan 30, 2025
1 parent a492aa4 commit e667e86
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 9 deletions.
29 changes: 29 additions & 0 deletions external/concealer/include/concealer/available.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2015 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.

#ifndef CONCEALER__AVAILABLE_HPP_
#define CONCEALER__AVAILABLE_HPP_

#include <rclcpp/rclcpp.hpp>

namespace concealer
{
template <typename T>
constexpr auto available(const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &) -> bool
{
return true;
}
} // namespace concealer

#endif // CONCEALER__AVAILABLE_HPP_
34 changes: 34 additions & 0 deletions external/concealer/include/concealer/get_parameter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2015 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.

#ifndef CONCEALER__GET_PARAMETER_HPP_
#define CONCEALER__GET_PARAMETER_HPP_

#include <rclcpp/rclcpp.hpp>

namespace concealer
{
template <typename T>
auto getParameter(
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node,
const std::string & name, T value = {})
{
if (not node->has_parameter(name)) {
node->declare_parameter(name, rclcpp::ParameterValue(value));
}
return node->get_parameter(name).get_value<T>();
}
} // namespace concealer

#endif // CONCEALER__GET_PARAMETER_HPP_
11 changes: 11 additions & 0 deletions external/concealer/include/concealer/path_with_lane_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <tier4_planning_msgs/msg/path_with_lane_id.hpp>
#endif

#include <concealer/available.hpp>
#include <concealer/convert.hpp>

namespace concealer
Expand All @@ -44,6 +45,16 @@ using PathWithLaneId = decltype(std::tuple_cat(
static_assert(0 < std::tuple_size_v<PathWithLaneId>);
} // namespace priority

#if __has_include(<autoware_internal_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
auto available<autoware_internal_planning_msgs::msg::PathWithLaneId>(const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &) -> bool;
#endif

#if __has_include(<tier4_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
auto available<tier4_planning_msgs::msg::PathWithLaneId>(const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &) -> bool;
#endif

#if __has_include(<autoware_internal_planning_msgs/msg/path_with_lane_id.hpp>) and \
__has_include(<tier4_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
Expand Down
17 changes: 9 additions & 8 deletions external/concealer/include/concealer/subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <concealer/convert.hpp>
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include <scenario_simulator_exception/exception.hpp>

namespace concealer
{
Expand All @@ -37,23 +38,23 @@ struct Subscriber<Message>
explicit Subscriber(
const std::string & topic, const rclcpp::QoS & quality_of_service, Autoware & autoware,
const Callback & callback)
: subscription(autoware.template create_subscription<Message>(
: subscription(available<Message>(autoware.get_node_parameters_interface()) ? autoware.template create_subscription<Message>(
topic, quality_of_service,
[this, callback](const typename Message::ConstSharedPtr & message) {
if (std::atomic_store(&current_value, message); current_value) {
callback((*this)());
}
}))
}) : throw common::scenario_simulator_exception::Error("no viable message type for topic ", std::quoted(topic)))
{
}

template <typename Autoware>
explicit Subscriber(
const std::string & topic, const rclcpp::QoS & quality_of_service, Autoware & autoware)
: subscription(autoware.template create_subscription<Message>(
: subscription(available<Message>(autoware.get_node_parameters_interface()) ? autoware.template create_subscription<Message>(
topic, quality_of_service, [this](const typename Message::ConstSharedPtr & message) {
std::atomic_store(&current_value, message);
}))
}) : nullptr)
{
}
};
Expand All @@ -79,24 +80,24 @@ struct Subscriber<Message, T, Ts...> : public Subscriber<T, Ts...>
const std::string & topic, const rclcpp::QoS & quality_of_service, Autoware & autoware,
const Callback & callback)
: Subscriber<T, Ts...>(topic, quality_of_service, autoware, callback),
subscription(autoware.template create_subscription<Message>(
subscription(available<Message>(autoware.get_node_parameters_interface()) ? autoware.template create_subscription<Message>(
topic, quality_of_service,
[this, callback](const typename Message::ConstSharedPtr & message) {
if (std::atomic_store(&current_value, message); current_value) {
callback((*this)());
}
}))
}) : nullptr)
{
}

template <typename Autoware>
explicit Subscriber(
const std::string & topic, const rclcpp::QoS & quality_of_service, Autoware & autoware)
: Subscriber<T, Ts...>(topic, quality_of_service, autoware),
subscription(autoware.template create_subscription<Message>(
subscription(available<Message>(autoware.get_node_parameters_interface()) ? autoware.template create_subscription<Message>(
topic, quality_of_service, [this](const typename Message::ConstSharedPtr & message) {
std::atomic_store(&current_value, message);
}))
}) : nullptr)
{
}
};
Expand Down
29 changes: 29 additions & 0 deletions external/concealer/src/path_with_lane_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,39 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <concealer/get_parameter.hpp>
#include <concealer/path_with_lane_id.hpp>

namespace concealer
{
#if __has_include(<autoware_internal_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
auto available<autoware_internal_planning_msgs::msg::PathWithLaneId>(
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node) -> bool
{
if (const auto architecture_type = getParameter<std::string>(node, "architecture_type");
architecture_type.find("awf/universe") != std::string::npos) {
return "awf/universe/20250130" <= architecture_type;
} else {
return false;
}
}
#endif

#if __has_include(<tier4_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
auto available<tier4_planning_msgs::msg::PathWithLaneId>(
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node) -> bool
{
if (const auto architecture_type = getParameter<std::string>(node, "architecture_type");
architecture_type.find("awf/universe") != std::string::npos) {
return architecture_type < "awf/universe/20250130";
} else {
return false;
}
}
#endif

#if __has_include(<autoware_internal_planning_msgs/msg/path_with_lane_id.hpp>) and \
__has_include(<tier4_planning_msgs/msg/path_with_lane_id.hpp>)
template <>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
def architecture_types():
# awf/universe/20230906: autoware_perception_msgs/TrafficSignalArray for traffic lights
# awf/universe/20240605: autoware_perception_msgs/TrafficLightGroupArray for traffic lights
return ["awf/universe/20230906", "awf/universe/20240605"]
# awf/universe/20250130: [Pilot.Auto >= 0.41.1] autoware_internal_planning_msgs/msg/PathWithLaneId for concealer
return ["awf/universe/20230906", "awf/universe/20240605", "awf/universe/20250130"]


def default_autoware_launch_package_of(architecture_type):
Expand All @@ -46,6 +47,7 @@ def default_autoware_launch_package_of(architecture_type):
return {
"awf/universe/20230906": "autoware_launch",
"awf/universe/20240605": "autoware_launch",
"awf/universe/20250130": "autoware_launch",
}[architecture_type]


Expand All @@ -57,6 +59,7 @@ def default_autoware_launch_file_of(architecture_type):
return {
"awf/universe/20230906": "planning_simulator.launch.xml",
"awf/universe/20240605": "planning_simulator.launch.xml",
"awf/universe/20250130": "planning_simulator.launch.xml",
}[architecture_type]


Expand Down

0 comments on commit e667e86

Please sign in to comment.