0

When I was developing the path planning problem of a CAR-like mobile robot, I encountered the following problems:

  1. It is required that the robot must pass through the set path points, for example, 50 points must pass.
  2. The planned path is required to have the least number of u-turns.

The preliminary design adopts A* or PRM algorithm.

enter image description here

How to introduce the above two constraints into the algorithm? Is such a design feasible?

zhang237
  • 1
  • 1

1 Answers1

0

Your answer depends on how do you define a U-turn. If you define it as merely 2 "left" or "right" turns in succession, then yes, you can solve this fairly easily. Take your nodes, and form a directed graph G0. Leave off the edges momentarily- we'll add them in a bit, for now we just need the vertices themselves. Now, let's repeatedly duplicate this graph, creating an instance of each vertex for every possible "state" we care about. For the sake of detecting a U-turn, we need three pieces of state information:

  • what direction were we previously turning (left/right/straight)
  • how many consecutive turns have we made in that direction (0/1/2)
  • what direction are we facing now (north/south/east/west)

This boils down to 3*3*4 = 36 states, per vertex, however we can actually do a lot better. We'll never be turning left or right with 0 consecutive turns in that direction, and we don't actually care about how long we've been going straight, so we can fix that to 0. So now we have (2 + 2 + 1) * 4 = 20 states.

Still not ideal, but there's one more simplification we may be able to do. Again, this depends on your definition of U-turn, but if we take a closed 1x1 loop to be a single U-turn (or, if revisiting nodes is forbidden), we can treat the 2-left and 2-right states as equivalent "U-turn" states, resetting the turn count upon exiting that vertex regardless of direction. This results in (1 + 1 + 1 + 1) * 4 = 16 states to consider.

Now, as I mentioned, we'll create an instance of each vertex for each possible state it may be in, and for organizational purposes, we'll lump these vertices into subgraphs where each subgraph contains vertices of the same state. In notation, we can say subgraph G1LN contains nodes that have just turned left once and are now "facing" north on their current node.

Now we need to add directed edges between theses vertices within each subgraph and between subgraphs. Note that the only subgraph with edges between its own vertices should be G0SN/G0SS/G0SE/G0SW graphs. All edges should be weighted as follows:

  • incoming edges to a vertex in G2L* or G2R* have weight 1
  • all other edges have weight 0

We're almost done. Our graph now fully encodes the state of our current U-turn status, and the weight of our path is equal to the number of U-turns we've made. We just need to insert a dummy source and sink node, and connect them to our graph to start a start. For the source, connect an outward edge to each vertex in the G0S* subgraphs. For the sink, connect an incoming edge from every vertex in every subgraph.

Now, just start a search from the source to the sink, minimizing the path weight, but still requiring a visit to at least one vertex for each path point. The first path will be the one with fewest U-turns.

Aside: This can be represented with a multigraph, containing multiple edges per node, as long as you explicitly store the direction/turns state in your search. I've presented it in a simplified form here for ease of understanding.

If you have a different definition for a U-turn, then you'll need to encode your state differently, but likely the result will be similar- you create multiple "variants" of each vertex to represent this state, and then add non-zero weights to the edges that complete a U-turn.

Dillon Davis
  • 6,679
  • 2
  • 15
  • 37