Skip to content

Commit

Permalink
perf(map_based_prediction): early return in crosswalk iteration
Browse files Browse the repository at this point in the history
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Jun 27, 2022
1 parent 0e6bdcd commit c42d6f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <lanelet2_extension/utility/utilities.hpp>
#include <rclcpp/rclcpp.hpp>
#include <tier4_autoware_utils/ros/transform_listener.hpp>
#include <tier4_autoware_utils/tier4_autoware_utils.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
#include <autoware_auto_perception_msgs/msg/predicted_objects.hpp>
Expand Down Expand Up @@ -87,6 +88,7 @@ using autoware_auto_perception_msgs::msg::PredictedPath;
using autoware_auto_perception_msgs::msg::TrackedObject;
using autoware_auto_perception_msgs::msg::TrackedObjectKinematics;
using autoware_auto_perception_msgs::msg::TrackedObjects;
using tier4_autoware_utils::StopWatch;

class MapBasedPredictionNode : public rclcpp::Node
{
Expand Down Expand Up @@ -136,6 +138,9 @@ class MapBasedPredictionNode : public rclcpp::Node
double reference_path_resolution_;
double min_crosswalk_user_velocity_;

// Stop watch
StopWatch<std::chrono::milliseconds> stop_watch_;

// Member Functions
void mapCallback(const HADMapBin::ConstSharedPtr msg);
void objectsCallback(const TrackedObjects::ConstSharedPtr in_objects);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
for (const auto & crosswalk : crosswalks_) {
const auto entry_point = getCrosswalkEntryPoint(crosswalk);

const auto reachable_first = hasPotentialToReach(
object, entry_point.first, prediction_time_horizon_, min_crosswalk_user_velocity_);
const auto reachable_second = hasPotentialToReach(
object, entry_point.second, prediction_time_horizon_, min_crosswalk_user_velocity_);

if (!reachable_first && !reachable_second) {
continue;
}

const auto reachable_crosswalk = isReachableEntryPoint(
object, entry_point, lanelet_map_ptr_, prediction_time_horizon_,
min_crosswalk_user_velocity_);
Expand Down

0 comments on commit c42d6f5

Please sign in to comment.