This is an example output of the RRT algorithm with a 5-link serial manipulator.

This is an example output of the PRM algorithm with a 5-link serial manipular.

The overall structure of all functions used in the task 1 code is outlined in figure 1 where each arrow points from a script or function in which a function was called to the function that was called.  The task1_main script is run to plan a path using RRT and PRM and create videos of each named “RRT_nlink” or “PRM_nlink.” These videos are saved as .avi files in the directory from Matlab and then manually converted to .mov files for submission.

Environment and obstacles:

RRT Inputs:

PRM Inputs:

RRT and PRM outputs:

Both the RRT and PRM functions use the point_collides function which takes input q, an n-linksx1 vector of joint angles and then converts q into the workspace to check each link for a collision with each obstacle using the isintersect_linepolygon function from homework 8. The path_collides function takes an input of two different 1xn-links vectors of joint angles and performs a 21-step linear interpolation between the two configurations calling the point_collides function at each step to check for collision. RRT also uses the helper function nearest_node to search through the nodes already added to the child array for the closest one to the randomly generated configuration and build_path to reconstruct the path once the goal is reached using the arrays of stored parent and child configurations.

For PRM, the Astar pathfinding algorithm was chosen instead of djikstra because Astar works more quickly since it does not need to check every node in the graph. The heuristic function used in Astar is the same as the function used in Homework 2 problem 2a, meaning that Astar favors nodes which have fewer steps to take to get to the goal.

The make_video function uses the path output of either RRT or PRM to create the videos in our submission of the robot following the path to reach the goal configuration while avoiding the obstacles. It plots the initial and goal points of the robot end effector in the workspace as well as the obstacles (see figure 2). It uses a 21-step linear interpolation between each step in the path to create a smooth animation of the path that the n-link manipulator follows. Make_video has an input ‘type’ which can be either ‘RRT’ or ‘PRM’ and is used to name the output video. Make_video also has inputs of q_init, q_goal, O, r, and path where each of these variables has the same description as the inputs/outputs of the PRM and RRT functions described above. The output videos are saved as .avi files in the directory from Matlab and then manually converted to .mov files for submission.