Skip to content

Commit 64972e3

Browse files
satoshi-otasoblin
authored andcommitted
feat(bpp): use planning factor (#1719)
feat(bpp): output planning factor Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent bd7378e commit 64972e3

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

planning/behavior_path_planner/autoware_behavior_path_planner/src/planner_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ BehaviorModuleOutput PlannerManager::run(const std::shared_ptr<PlannerData> & da
184184
m->publishRTCStatus();
185185
m->publishSteeringFactor();
186186
m->publishVelocityFactor();
187+
m->publish_planning_factors();
187188
});
188189

189190
generateCombinedDrivableArea(result_output.valid_output, data);

planning/behavior_path_planner/autoware_behavior_path_planner_common/include/autoware/behavior_path_planner_common/interface/scene_module_interface.hpp

+46
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "autoware/behavior_path_planner_common/utils/utils.hpp"
2222

2323
#include <autoware/behavior_path_planner_common/turn_signal_decider.hpp>
24+
#include <autoware/motion_utils/factor/planning_factor_interface.hpp>
2425
#include <autoware/motion_utils/factor/steering_factor_interface.hpp>
2526
#include <autoware/motion_utils/factor/velocity_factor_interface.hpp>
2627
#include <autoware/motion_utils/marker/marker_helper.hpp>
@@ -54,6 +55,7 @@
5455

5556
namespace autoware::behavior_path_planner
5657
{
58+
using autoware::motion_utils::PlanningFactorInterface;
5759
using autoware::motion_utils::SteeringFactorInterface;
5860
using autoware::motion_utils::VelocityFactorInterface;
5961
using autoware::objects_of_interest_marker_interface::ColorName;
@@ -66,6 +68,8 @@ using autoware_adapi_v1_msgs::msg::SteeringFactor;
6668
using autoware_adapi_v1_msgs::msg::VelocityFactor;
6769
using tier4_planning_msgs::msg::AvoidanceDebugMsgArray;
6870
using tier4_planning_msgs::msg::PathWithLaneId;
71+
using tier4_planning_msgs::msg::PlanningFactor;
72+
using tier4_planning_msgs::msg::SafetyFactorArray;
6973
using tier4_rtc_msgs::msg::State;
7074
using unique_identifier_msgs::msg::UUID;
7175
using visualization_msgs::msg::MarkerArray;
@@ -82,6 +86,27 @@ enum class ModuleStatus {
8286
class SceneModuleInterface
8387
{
8488
public:
89+
SceneModuleInterface(
90+
const std::string & name, rclcpp::Node & node,
91+
std::unordered_map<std::string, std::shared_ptr<RTCInterface>> rtc_interface_ptr_map,
92+
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>>
93+
objects_of_interest_marker_interface_ptr_map,
94+
const std::shared_ptr<PlanningFactorInterface> planning_factor_interface)
95+
: name_{name},
96+
logger_{node.get_logger().get_child(name)},
97+
clock_{node.get_clock()},
98+
rtc_interface_ptr_map_(std::move(rtc_interface_ptr_map)),
99+
objects_of_interest_marker_interface_ptr_map_(
100+
std::move(objects_of_interest_marker_interface_ptr_map)),
101+
planning_factor_interface_{planning_factor_interface},
102+
time_keeper_(std::make_shared<universe_utils::TimeKeeper>())
103+
{
104+
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
105+
uuid_map_.emplace(module_name, generateUUID());
106+
}
107+
}
108+
109+
// TODO(satoshi-ota): remove this constructor after all planning factors have been migrated.
85110
SceneModuleInterface(
86111
const std::string & name, rclcpp::Node & node,
87112
std::unordered_map<std::string, std::shared_ptr<RTCInterface>> rtc_interface_ptr_map,
@@ -93,6 +118,7 @@ class SceneModuleInterface
93118
rtc_interface_ptr_map_(std::move(rtc_interface_ptr_map)),
94119
objects_of_interest_marker_interface_ptr_map_(
95120
std::move(objects_of_interest_marker_interface_ptr_map)),
121+
planning_factor_interface_{std::make_shared<PlanningFactorInterface>(&node, "tmp")},
96122
time_keeper_(std::make_shared<universe_utils::TimeKeeper>())
97123
{
98124
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
@@ -574,6 +600,24 @@ class SceneModuleInterface
574600
path.points, getEgoPose(), slow_pose_.value().pose, VelocityFactor::APPROACHING, "slow down");
575601
}
576602

603+
void set_longitudinal_planning_factor(const PathWithLaneId & path)
604+
{
605+
if (stop_pose_.has_value()) {
606+
planning_factor_interface_->add(
607+
path.points, getEgoPose(), stop_pose_.value().pose, PlanningFactor::STOP,
608+
SafetyFactorArray{});
609+
return;
610+
}
611+
612+
if (!slow_pose_.has_value()) {
613+
return;
614+
}
615+
616+
planning_factor_interface_->add(
617+
path.points, getEgoPose(), slow_pose_.value().pose, PlanningFactor::SLOW_DOWN,
618+
SafetyFactorArray{});
619+
}
620+
577621
void setDrivableLanes(const std::vector<DrivableLanes> & drivable_lanes);
578622

579623
BehaviorModuleOutput getPreviousModuleOutput() const { return previous_module_output_; }
@@ -627,6 +671,8 @@ class SceneModuleInterface
627671
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>>
628672
objects_of_interest_marker_interface_ptr_map_;
629673

674+
mutable std::shared_ptr<PlanningFactorInterface> planning_factor_interface_;
675+
630676
mutable SteeringFactorInterface steering_factor_interface_;
631677

632678
mutable VelocityFactorInterface velocity_factor_interface_;

planning/behavior_path_planner/autoware_behavior_path_planner_common/include/autoware/behavior_path_planner_common/interface/scene_module_manager_interface.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class SceneModuleManagerInterface
146146
pub_velocity_factors_->publish(velocity_factor_array);
147147
}
148148

149+
void publish_planning_factors() { planning_factor_interface_->publish(); }
150+
149151
void publishVirtualWall() const
150152
{
151153
using autoware::universe_utils::appendMarkerArray;
@@ -318,6 +320,8 @@ class SceneModuleManagerInterface
318320

319321
std::unique_ptr<SceneModuleInterface> idle_module_ptr_;
320322

323+
std::shared_ptr<PlanningFactorInterface> planning_factor_interface_;
324+
321325
std::unordered_map<std::string, std::shared_ptr<RTCInterface>> rtc_interface_ptr_map_;
322326

323327
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>>

planning/behavior_path_planner/autoware_behavior_path_planner_common/src/interface/scene_module_manager_interface.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ void SceneModuleManagerInterface::initInterface(
6767
node->create_publisher<VelocityFactorArray>("/planning/velocity_factors/" + name_, 1);
6868
}
6969

70+
// planning factor
71+
{
72+
planning_factor_interface_ = std::make_shared<PlanningFactorInterface>(node, name_);
73+
}
74+
7075
// misc
7176
{
7277
node_ = node;

0 commit comments

Comments
 (0)