@@ -499,7 +499,6 @@ void NodeLattice::getNeighbors(
499
499
NodeVector & neighbors)
500
500
{
501
501
uint64_t index = 0 ;
502
- float angle;
503
502
bool backwards = false ;
504
503
NodePtr neighbor = nullptr ;
505
504
Coordinates initial_node_coords, motion_projection;
@@ -515,6 +514,24 @@ void NodeLattice::getNeighbors(
515
514
motion_projection.y = this ->pose .y + (end_pose._y / grid_resolution);
516
515
motion_projection.theta = motion_primitives[i]->end_angle /* this is the ending angular bin*/ ;
517
516
517
+ // if i >= idx, then we're in a reversing primitive. In that situation,
518
+ // the orientation of the robot is mirrored from what it would otherwise
519
+ // appear to be from the motion primitives file. We want to take this into
520
+ // account in case the robot base footprint is asymmetric.
521
+ backwards = false ;
522
+ if (i >= direction_change_index) {
523
+ backwards = true ;
524
+ float opposite_heading_theta =
525
+ motion_projection.theta - (motion_table.num_angle_quantization / 2 );
526
+ if (opposite_heading_theta < 0 ) {
527
+ opposite_heading_theta += motion_table.num_angle_quantization ;
528
+ }
529
+ if (opposite_heading_theta > motion_table.num_angle_quantization ) {
530
+ opposite_heading_theta -= motion_table.num_angle_quantization ;
531
+ }
532
+ motion_projection.theta = opposite_heading_theta;
533
+ }
534
+
518
535
index = NodeLattice::getIndex (
519
536
static_cast <unsigned int >(motion_projection.x ),
520
537
static_cast <unsigned int >(motion_projection.y ),
@@ -524,28 +541,12 @@ void NodeLattice::getNeighbors(
524
541
// Cache the initial pose in case it was visited but valid
525
542
// don't want to disrupt continuous coordinate expansion
526
543
initial_node_coords = neighbor->pose ;
527
- // if i >= idx, then we're in a reversing primitive. In that situation,
528
- // the orientation of the robot is mirrored from what it would otherwise
529
- // appear to be from the motion primitives file. We want to take this into
530
- // account in case the robot base footprint is asymmetric.
531
- backwards = false ;
532
- angle = motion_projection.theta ;
533
- if (i >= direction_change_index) {
534
- backwards = true ;
535
- angle = motion_projection.theta - (motion_table.num_angle_quantization / 2 );
536
- if (angle < 0 ) {
537
- angle += motion_table.num_angle_quantization ;
538
- }
539
- if (angle > motion_table.num_angle_quantization ) {
540
- angle -= motion_table.num_angle_quantization ;
541
- }
542
- }
543
544
544
545
neighbor->setPose (
545
546
Coordinates (
546
547
motion_projection.x ,
547
548
motion_projection.y ,
548
- angle ));
549
+ motion_projection. theta ));
549
550
550
551
// Using a special isNodeValid API here, giving the motion primitive to use to
551
552
// validity check the transition of the current node to the new node over
0 commit comments