Problem Description:
I am working on an autonomous navigation project for an agricultural truck that needs to move smoothly and predictably on dynamically defined virtual lanes. The navigation is guided by GPS waypoints that can vary according to the field in which the truck operates. My goal is to ensure that the planner computes paths only within these virtual lanes, avoiding areas outside of them.
Currently, I am using the SMAC planner from the Navigation2 Stack and have explored several approaches, but still face challenges:
Approaches Used: Generating Virtual Lanes:
I use a script (visualize_lanes_from_gps_and_wps.py) to generate virtual lanes (center, left, and right) with visualization markers based on GPS waypoints.
I also created a script (lane_costmap_generator.py) to generate costmaps over these lanes, assigning different cost values to each one to try and guide the planner to prefer the desired lane.
1 - Problems Encountered:
- The planner does not restrict itself to the generated virtual lanes. As shown in the attached images and videos, the planner path (red line) "escapes" from the virtual lanes and expands outside of them, using the standard (global/local) costmaps from the Navigation2 Stack.
- I tried using virtual "walls" generated by point clouds (PCD2). Still, since there are no real physical obstacles, the Nav2 layers (such as voxel and obstacle) do not generate real occupancy "felt" by the planner, causing it to ignore these "walls."
2-Attempted Solutions:
- Binary Masks Filters: I applied cost filters using binary masks, adjusting values to make certain lanes more permissive (value 0) or more restrictive (value 100). However, the planner does not prioritize one lane over another and continues expanding outside the virtual lanes regardless of the configured cost values.
What I Need to Know: What is the best way to ensure that the SMAC planner is restricted only to the virtual lanes?
How can I configure the Navigation2 Stack to ensure that the planner expands primarily within the costmaps generated for the virtual lanes and avoids or minimizes expansion into the local and global costmaps?
If using keepout zones is appropriate, is it possible to configure them dynamically to consider everything outside the virtual lanes as a keepout zone? If so, how could this be implemented?** Or just manually as tutorial image below:
Secondary Question:
Additionally, I am using a script (follow_dynamic_gps_wps_lanes.py) that dynamically changes the GPS waypoints to another lane when an obstacle is detected in the current lane. The problem is that the planner does not correctly recalculate the path for these new waypoints. It tries to follow all the waypoints shifted to another lane, including those already behind the truck, causing it to turn back instead of following only the points ahead.
What I Have Tried:
I have tried using methods such as preempt, cancelNav, clearCostmap, but the planner still tries to recalculate the route from the beginning instead of continuing only with the waypoints ahead of the truck.
Question:
How can I adjust the path calculation to consider only the shifted side-lanes waypoints ahead of the truck, avoiding unwanted returns?
A video describing the planner "violating" virtual lanes boundaries and above issues can be checked in this link Shifting to side lane and boundaries restriction fails