**Problem definition**

We will start with the following hypothesis: the locomotion environment (the map) is known; we know the initial (start) position and the final (desired, target) position of the Robot (R). In these conditions the path planning problem means to find the shortest path from the starting point to the target point which avoids the (known) obstacles (see figure 1). It is important to mention that we have used the term shortest to introduce a cost function minimum. For most situations the cost function is in fact the length from the two mentioned points, but we can imagine also other functions, like travel lime etc.

The path planning problem is solved in the following steps:

- Discretize the environment, i.e. transform the continuous environment into a discrete one. Because the environment is a two dimension map, the results of this step is the matrix . An intuitive image of this operation is the map overlapped with a grid (see figure 2).

Each mesh of the mentioned grid can be classified in two sets: the first is composed by meshes which cover obstacle free spaces; the second is composed by meshes which cover obstacles or parts from the obstacles (see figure 3).

The meshes from the first set are empty mesh, where the locomotion is possible, the set consist of filled mesh corresponds to spaces where the locomotion is not possible (see figure 4).

For each mesh an element of the matrix is defined: zero for the empty meshes and one (or NaN) for the filled meshes (see figure 5).

- The second step computes the shortest path. Many solutions are possible, in the next section we will focus on the A* algorithm. An illustration of the result of this step is presented in figure 6. It is a subset of the matrix , with neighboring elements which start from the element used for the initial position and end with the element used for marking the target position.

- The third step uses the mentioned elements and transforms them in positions on the map. Each element (figure 7) is transformed into a coordinate (x,y)

The set of position is used to obtain a smooth trajectory, which is in fact the (R) path from the start position to the goal position (see fig.8). In next section we will present the smoothing algorithm. We will observe that the smooth trajectory is also defined as a collection of points.

**Map representation**

The map is a 2D or 3D representation of the environment. The map boundaries have been modeled with a rectangle and the obstacles have been modeled by lines represented by interconnected of points. In fact, the map consists on the following elements (properties):

- Boundary dimensions:
- Obstacles:
- Set of coordinates of points in matrix form
- The incident matrix, which define the lines by interconnected points:

where is the line from point P_{i} to P_{j};

- The task matrix which contain the initial and the final position of (R)

The map representation is made by drawing the boundary rectangle, the initial and the final positions of the Robot ( R ) and, using the incident matrix, the lines. Figure 9 gives an example of environment representation.

**Map discretization**

Additionally to the parameters defined in the previous section, the map discretization needs the sampling ratio .

Our solution consists on the following steps:

- Move (translate) the origin of the reference system in the lower left corner of the map, so the obstacles’ coordinate matrix and the task matrix will change:

(1)

- Compute the environment matrix dimensions

(2)

where l_{x,y }is the environment length in x, y direction

- Discretize the points positions:

(3)

- Compute the environment matrix elements. For this reason we have used the lines defined with the discrete points. We start with a zero matrix and rewrite the elements.
- Check if the line is on Y direction
- Check if the line is on X direction

(4)

where

Figure 10 illustrate this process.

- Thicken the (lines) obstacles with k elements in both directions. This is useful in order to compute a safety path (avoiding the collisions with the obstacles). We start with a zero matrix M
_{B}and rewrite its elements.

(5)

- Flip the M
_{B}matrix in Y direction:

(6)

Using the previous algorithm, the environment presented in figure 9 has been transformed in the matrix presented in figure 13 which is the sparsity pattern of matrix **M**

**A star (A**^{*}) algorithm

^{*}) algorithm

The well knows A star algorithm is an optimal graph search algorithm. A star belong to *best first search *category algorithms and use a cost function which combine the traveling cost from the initial nod to the current node with a heuristic, which estimate the cost of traveling from the current node to the final (goal) node from the class. This combination gives the path-based evaluation function.

(7)

where:

is the traveling cost from the initial nod to the current (node);

is the heuristic function.

In our case each element of the matrix **M** becomes a node, the element which matches the start point is the initial node and the element which matches the goal point is the goal node.

I order to compute the cost function a stepping procedure must be defined. This procedure defines the links from the current node to the next nodes: the locomotion possibilities.

Several rules can be imagined. An attractive (simple) rule is inspired from the chess rook locomotion model. The next node can be reached in the same line from the current column to the neighboring column; or in the same column from the current line to the neighboring lines. Moving from one node to the next node will increase the function with 1. The function computes the distance by adding the number of columns and rows which separate the current nod and the goal node. The heuristics is eluding the possible obstacles. Figure 14 gives an illustration of the mentioned concept.

Other rules can be imagined. If we continue to use the chess play allegory the new model can be the King locomotion rules. Figure 15 illustrate the new rules.

The A star algorithm compute the shortest path from the start node to the goal node. Before we start to present the algorithm it is important to mention that two results are to be expected: finding the path or denying its existence. The algorithm can be finished with the following statements:

- STOP
_{failure}this means there are no solutions; - RESOLVED, this means that the path has been computed;
- STOP
_{succes }an intermediary result which means that the search is ended (the target node have been funded) and the path can be computed.

A star includes the following steps:

- Create two empty lists of nodes: the Open list and the Close list,
- Perform one step (using one of the previous stepping procedures) and generate new nodes (the set of new nodes):
(10)

- Compute the cost functions for the new nodes
(13)

- Check if the nodes (from the set of new nodes) are already in the open list. If yes, there are duplicate nodes. If the cost function of the duplicate node, which belongs in the new nodes set, is bigger than the cost function of the same node, from the open list, eliminate it from the set; at contrary, eliminate the node from the open list.
(14)

- Check if the nodes (from the set of new nodes) are already in the open list. If yes, there are duplicate nodes. If the cost function of the duplicate node, which belongs in the new nodes set, is bigger than the cost function of the same node, from the open list, eliminate it from the set; at contrary, eliminate the node from the open list.
- Add the new nodes to the open list
(15)

- Check if the open list is empty, if yes stop the algorithm with failure
(16)

- Check if the open list is empty, if yes stop the algorithm with failure
- From the open list choose the node with the minimum of the cost function
(17)

- Add the selected node to the close list and remove it from the open list
(18)

- Check if the selected nod is the target node, if yes stop search with success
(19)

- if not, go to 2 and step the selected node

- Add the selected node to the close list and remove it from the open list
- If the search algorithm has been closed with success, the path can be constructed from the close list. Create an empty Path list:
- Add the target node to the Path list
(20)

- Step the last added nod from the Path list and find the duplicate node from the close list which has the minimum cost function
(21)

- Check if the last added nod is the start nod, if yes, flip the path list and end the algorithm with result
(22)

- If not, go to 6.2

- Add the target node to the Path list

## Compute the desired trajectory

Using the Path list (computed in the previous section) two additional steps are needed.

Firstly, the nodes must be transformed in corresponding point on map (reverse of the discretization)

(23)

Secondly, the trajectory defined by points must be smoothed. This is an optimization problem to move the points in a new location in which they minimize two hypothetical distances: between neighboring points in the new position, and the original position of the points and the current position of points. Figure 15 illustrate this concept.

A hypothetical attraction between the neighboring points is use to move the points closer. This movement of thiese points is compensated by reducing in parallel the distance between the initial position of points and the current position of points. The second interaction tends to preserve the original positions of the points.

Using this idea, an iterative (gradient descendent) loop can be constructed for each point contained in the Path list, less the start and target point. The loop is stopped after a maximum number of iteration (initially imposed) or, if the points displacement will decrees under an (initialy imposed) limit:

(24)

where: is the point i at k iteration, and are the gradient descend coefficients.

The final result of path planning is a trajectory defined like a list (set) of points. The trajectory links the start point with the target point, it is the shortest path between these point, it is avoiding the obstacles and it is a smooth curve.