**3.2. Programming the palletizer robot**

As mentioned before, the NXT brick can be programmed in LabVIEW code to perform the robotic arm movements:

**1.** Move up and down the arm.

where *F(x)* = cost of the shortest path to the goal, *G(x)* = cost of the movement from A node to an intermediate node and *H(x)* = cost of the possible movement to go from an intermediate

Every node on the open list is evaluated using this equation, and the node with the lowest *F(x)* value is chosen. The value *G(x)* represents the costs involved in reaching the neighbor nodes. Horizontal or vertical nodes are weighted as 10 (because there is one node to get there). Then, diagonal moves are weighted as 14 because this is the closest without choosing a diagonal. *H(x)* value is estimated using the Manhattan distance, but many other distances can be used as well. Such distance considers only vertical or horizontal moves to get to the final goal from any intermediate node, ignoring diagonal moves and obstacles on the way. This does not imply that all the environment must be free of moving or static obstacles; it is just the real physical distance between two nodes, after a second weighted value excludes possible paths with occupied intermediate nodes. The punctuation after computing Eq. (7) in our example is shown in **Figure 9(a)**. As the method does not consider obstacles, the shortest distance from B to right node of A is *H = 30* because this node is reachable in three nodes. Similarly, the upper right

**Figure 9.** A-star algorithm. (a) First iteration of the algorithm and (b) the lowest cost node.

node to the goal.

**Figure 8.** Environment to go from A to B.

178 Advanced Path Planning for Mobile Entities


Moreover, to perform a safe and coherent navigation, the path planning algorithm is programmed on the sb-RIO reprogrammable card of the robot, that is, following the abovementioned A-star technique. In this chapter, we explain robotic arm motion and pathfinder algorithm.

The LabVIEW Robotics software provides a module of the A-star algorithm which computes an optimal path to get to goal position [18]. The path includes horizontal and vertical trajectories of the robot, left or right rotations and diagonal displacements. However, our mobile robot can only

**Figure 10.** (a) Nodes computed by the A-star algorithm at each iteration and (b) path to get from node A to node B.

perform horizontal and vertical trajectories and left or right rotations. Diagonal movements cannot be performed, because the robot size is not considered for the final path computation, and, consequently, it is more important to avoid possible robot collisions than to get an optimal traversing path. For this reason, the virtual instrument (VI module) provided on the software is modified to exclude all diagonal nodes that could be included in the path. The modified class is called "*GetNeighbours*" of the library "*OccupancyGridWorldMap,"* and only we establish a fixed threshold value for the cost function of the diagonal nodes, such that it will always be higher than other possible nodes. **Figure 11(a)** illustrates simulation results of the A-star algorithm, and **Figure 11(b)** the modified version for the same environment before programming the mobile robot DaNI. Note that there are diagonal displacements on the path, yet they are not too close to the obstacles, so the risk of collision is minimal. Real tests of the final palletizer robot are presented in the next section.
