Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 committed Apr 3, 2023
1 parent 3659416 commit 4691ced
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ class SceneModuleInterface
{
std::unordered_map<std::string, std::shared_ptr<RTCInterface>> rtc_interface_ptr_map;
for (const auto & rtc_type : rtc_types) {
const auto rtc_interface_name = rtc_type == "" ? name : name + "_" + rtc_type;
const auto snake_case_name = util::convertToSnakeCase(name);
const auto rtc_interface_name =
rtc_type == "" ? snake_case_name : snake_case_name + "_" + rtc_type;
rtc_interface_ptr_map.emplace(
rtc_type, std::make_shared<RTCInterface>(&node, rtc_interface_name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class SceneModuleManagerInterface
enable_simultaneous_execution_(config.enable_simultaneous_execution)
{
for (const auto & rtc_type : rtc_types) {
const auto rtc_interface_name = rtc_type == "" ? name : name + "_" + rtc_type;
const auto snake_case_name = util::convertToSnakeCase(name);
const auto rtc_interface_name =
rtc_type == "" ? snake_case_name : snake_case_name + "_" + rtc_type;
rtc_interface_ptr_map_.emplace(
rtc_type, std::make_shared<RTCInterface>(node, rtc_interface_name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ double calcLaneChangeBuffer(

lanelet::ConstLanelets getLaneletsFromPath(
const PathWithLaneId & path, const std::shared_ptr<route_handler::RouteHandler> & route_handler);

std::string convertToSnakeCase(const std::string & input_str);
} // namespace behavior_path_planner::util

#endif // BEHAVIOR_PATH_PLANNER__UTILITIES_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,15 @@
namespace behavior_path_planner
{
#ifdef USE_OLD_ARCHITECTURE
std::string getTopicName(const ExternalRequestLaneChangeModule::Direction & direction)
{
const std::string direction_name =
direction == ExternalRequestLaneChangeModule::Direction::RIGHT ? "right" : "left";
return "ext_request_lane_change_" + direction_name;
}

ExternalRequestLaneChangeModule::ExternalRequestLaneChangeModule(
const std::string & name, rclcpp::Node & node, std::shared_ptr<LaneChangeParameters> parameters,
const Direction & direction)
: SceneModuleInterface{name, node, createRTCInterfaceMap(node, name, {getTopicName(direction)})},
: SceneModuleInterface{name, node, createRTCInterfaceMap(node, name, {""})},
parameters_{std::move(parameters)},
direction_{direction}
{
steering_factor_interface_ptr_ =
std::make_unique<SteeringFactorInterface>(&node, getTopicName(direction));
std::make_unique<SteeringFactorInterface>(&node, util::convertToSnakeCase(name));
}

void ExternalRequestLaneChangeModule::onEntry()
Expand Down
14 changes: 14 additions & 0 deletions planning/behavior_path_planner/src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2691,4 +2691,18 @@ lanelet::ConstLanelets getLaneletsFromPath(

return lanelets;
}

std::string convertToSnakeCase(const std::string & input_str)
{
std::string output_str = std::string{std::tolower(input_str.at(0))};
for (size_t i = 1; i < input_str.length(); ++i) {
const auto input_chr = input_str.at(i);
if (std::isupper(input_chr)) {
output_str += "_" + std::string{std::tolower(input_chr)};
} else {
output_str += input_chr;
}
}
return output_str;
}
} // namespace behavior_path_planner::util

0 comments on commit 4691ced

Please sign in to comment.