Skip to content

Commit

Permalink
Fix index out of bounds in VTS
Browse files Browse the repository at this point in the history
  • Loading branch information
camearle20 committed Feb 11, 2024
1 parent 1026b3e commit 4d1a258
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions trajectory_native/src/trajectory_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class VehicleTrajectoryService final
const vts::Waypoint *prev_waypoint;

for (int waypoint_idx = 0; waypoint_idx < segment.waypoints_size(); waypoint_idx++) {
const vts::Waypoint &waypoint = segment.waypoints(segment_start_offset + waypoint_idx);
const vts::Waypoint &waypoint = segment.waypoints(waypoint_idx);

if (waypoint.has_heading_constraint()) {
fmt::print("Adding pose waypoint {} ({}, {}, {})\n", segment_start_offset + waypoint_idx,
Expand Down Expand Up @@ -175,10 +175,10 @@ class VehicleTrajectoryService final
}

if (segment.straight_line()) {
double x1 = segment.waypoints(segment_start_offset).x();
double x2 = segment.waypoints(segment_start_offset + last_waypoint_idx).x();
double y1 = segment.waypoints(segment_start_offset).y();
double y2 = segment.waypoints(segment_start_offset + last_waypoint_idx).y();
double x1 = segment.waypoints(0).x();
double x2 = segment.waypoints(last_waypoint_idx).x();
double y1 = segment.waypoints(0).y();
double y2 = segment.waypoints(last_waypoint_idx).y();
double angle = atan2(y2 - y1, x2 - x1);
fmt::print("Adding straight line constraint with angle {} to segment {} (waypoints {}-{})\n", angle,
segment_idx, segment_start_offset, segment_start_offset + last_waypoint_idx);
Expand Down

0 comments on commit 4d1a258

Please sign in to comment.