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

perf(behavior_path_planner_common): remove unnecessary angle calculation in OccupancyGridMapBasedDetector #7103

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ void OccupancyGridBasedCollisionDetector::setMap(const nav_msgs::msg::OccupancyG
}
}

static IndexXY position2index(
const nav_msgs::msg::OccupancyGrid & costmap, const geometry_msgs::msg::Point & position_local)
{
const int index_x = position_local.x / costmap.info.resolution;
const int index_y = position_local.y / costmap.info.resolution;
return {index_x, index_y};
}

void OccupancyGridBasedCollisionDetector::computeCollisionIndexes(
int theta_index, std::vector<IndexXY> & indexes_2d)
{
Expand All @@ -131,12 +139,11 @@ void OccupancyGridBasedCollisionDetector::computeCollisionIndexes(
const double offset_x = std::cos(base_theta) * x - std::sin(base_theta) * y;
const double offset_y = std::sin(base_theta) * x + std::cos(base_theta) * y;

geometry_msgs::msg::Pose pose_local;
pose_local.position.x = base_pose.position.x + offset_x;
pose_local.position.y = base_pose.position.y + offset_y;
geometry_msgs::msg::Point position_local;
position_local.x = base_pose.position.x + offset_x;
position_local.y = base_pose.position.y + offset_y;

const auto index = pose2index(costmap_, pose_local, param_.theta_size);
const auto index_2d = IndexXY{index.x, index.y};
const auto index_2d = position2index(costmap_, position_local);
indexes_2d.push_back(index_2d);
};

Expand Down
Loading