Skip to content

Commit 004823e

Browse files
authored
Precompute yaw trigonometric values in smac planner (#5109)
Signed-off-by: mini-1235 <[email protected]>
1 parent bb6cf9d commit 004823e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nav2_smac_planner/include/nav2_smac_planner/utils.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ inline std::vector<geometry_msgs::msg::Point> transformFootprintToEdges(
159159
const double & x = pose.position.x;
160160
const double & y = pose.position.y;
161161
const double & yaw = tf2::getYaw(pose.orientation);
162+
const double sin_yaw = sin(yaw);
163+
const double cos_yaw = cos(yaw);
162164

163165
std::vector<geometry_msgs::msg::Point> out_footprint;
164166
out_footprint.resize(2 * footprint.size());
165167
for (unsigned int i = 0; i < footprint.size(); i++) {
166-
out_footprint[2 * i].x = x + cos(yaw) * footprint[i].x - sin(yaw) * footprint[i].y;
167-
out_footprint[2 * i].y = y + sin(yaw) * footprint[i].x + cos(yaw) * footprint[i].y;
168+
out_footprint[2 * i].x = x + cos_yaw * footprint[i].x - sin_yaw * footprint[i].y;
169+
out_footprint[2 * i].y = y + sin_yaw * footprint[i].x + cos_yaw * footprint[i].y;
168170
if (i == 0) {
169171
out_footprint.back().x = out_footprint[i].x;
170172
out_footprint.back().y = out_footprint[i].y;

0 commit comments

Comments
 (0)