@@ -272,7 +272,7 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
272
272
}
273
273
274
274
// Collision checking on this velocity heading
275
- if (isCollisionImminent (pose, carrot_pose, curvature, linear_vel, angular_vel)) {
275
+ if (isCollisionImminent (pose, linear_vel, angular_vel)) {
276
276
throw std::runtime_error (" RegulatedPurePursuitController detected collision ahead!" );
277
277
}
278
278
@@ -335,16 +335,13 @@ geometry_msgs::msg::PoseStamped RegulatedPurePursuitController::getLookAheadPoin
335
335
336
336
bool RegulatedPurePursuitController::isCollisionImminent (
337
337
const geometry_msgs::msg::PoseStamped & robot_pose,
338
- const geometry_msgs::msg::PoseStamped & carrot_pose,
339
- const double & curvature, const double & linear_vel,
340
- const double & angular_vel)
338
+ const double & linear_vel, const double & angular_vel)
341
339
{
342
340
// Note(stevemacenski): This may be a bit unusual, but the robot_pose is in
343
341
// odom frame and the carrot_pose is in robot base frame.
344
342
345
343
// check current point is OK
346
- if (inCollision (robot_pose.pose .position .x , robot_pose.pose .position .y ))
347
- {
344
+ if (inCollision (robot_pose.pose .position .x , robot_pose.pose .position .y )) {
348
345
return true ;
349
346
}
350
347
@@ -356,29 +353,23 @@ bool RegulatedPurePursuitController::isCollisionImminent(
356
353
pose_msg.header .frame_id = arc_pts_msg.header .frame_id ;
357
354
pose_msg.header .stamp = arc_pts_msg.header .stamp ;
358
355
359
- // Using curvature (k = 1 / R) and carrot distance (chord on circle R), project the command
360
- const double chord_len = hypot (carrot_pose.pose .position .x , carrot_pose.pose .position .y );
361
-
362
- // Find the number of increments by finding the arc length of the chord on circle
363
- const double r = fabs (1.0 / curvature);
364
- const double alpha = 2.0 * asin (chord_len / (2 * r)); // central angle
365
- const double arc_len = alpha * r;
366
- const double delta_dist = costmap_->getResolution ();
367
- const unsigned int num_pts = static_cast <unsigned int >(ceil (arc_len / delta_dist));
368
356
const double projection_time = costmap_->getResolution () / linear_vel;
369
357
370
358
geometry_msgs::msg::Pose2D curr_pose;
371
359
curr_pose.x = robot_pose.pose .position .x ;
372
360
curr_pose.y = robot_pose.pose .position .y ;
373
361
curr_pose.theta = tf2::getYaw (robot_pose.pose .orientation );
374
362
375
- for (unsigned int i = 1 ; i < num_pts; i++) {
363
+ int i = 1 ;
364
+ while (true ) {
376
365
// only forward simulate within time requested
377
366
if (i * projection_time > max_allowed_time_to_collision_) {
378
367
break ;
379
368
}
369
+
370
+ i++;
380
371
381
- // apply velocity at curr_pose over distance delta_dist
372
+ // apply velocity at curr_pose over distance
382
373
curr_pose.x += projection_time * (linear_vel * cos (curr_pose.theta ));
383
374
curr_pose.y += projection_time * (linear_vel * sin (curr_pose.theta ));
384
375
curr_pose.theta += projection_time * angular_vel;
0 commit comments