Write My Paper Button

WhatsApp Widget

Implementing a Path Planning Algorithm | My Assignment Tutor

Advanced Programming TechniquesCOSC1076 | Semester 1 2021Assignment 1 | Implementing a Path Planning Algorithm Assessment TypeIndividual Assessment. Clarifications/updates may be made via announcements/relevant discussion forums.Due Date11.59pm, Sunday 11 April 2021 (Before Week 6)Silence PolicyFrom 5.00pm, Friday 09 April 2021 (Week 5)Weight30% of the final course markSubmissionOnline via Canvas. Submission instructions are provided on Canvas. 1 … Continue reading “Implementing a Path Planning Algorithm | My Assignment Tutor”

Advanced Programming TechniquesCOSC1076 | Semester 1 2021Assignment 1 | Implementing a Path Planning Algorithm Assessment TypeIndividual Assessment. Clarifications/updates may be made via announcements/relevant discussion forums.Due Date11.59pm, Sunday 11 April 2021 (Before Week 6)Silence PolicyFrom 5.00pm, Friday 09 April 2021 (Week 5)Weight30% of the final course markSubmissionOnline via Canvas. Submission instructions are provided on Canvas. 1 OverviewIn this assignment you will implement a simplified algorithm for Path Planning, and use it with a simplesimulated 2D robot moving around a room. Figure 1: An example robot• Style & Code Description: Producing well formatted, and welldocumented code. In this assignment you will:• Practice the programming skills such as:– Pointers– Dynamic Memory Management– Arrays• Implement a medium size C++ program using predefined classes• Use a prescribed set of C++11/14 language featuresThis assignment is marked on three criteria, as given on the Marking Rubricon Canvas:• Milestone 1: Writing Tests.• Milestone 2-4: Implementation of the Path Planner.1.1 Relevant Lecture/Lab MaterialTo complete this assignment, you will require skills and knowledge from workshop and lab material for Weeks2 to 4 (inclusive). You may find that you will be unable to complete some of the activities until you havecompleted the relevant lab work. However, you will be able to commence work on some sections. Thus, do thework you can initially, and continue to build in new features as you learn the relevant skills.1.2 Learning OutcomesThis assessment relates to all of the learning outcomes of the course which are:1• Analyse and Solve computing problems; Design and Develop suitable algorithmic solutions using softwareconcepts and skills both (a) introduced in this course, and (b) taught in pre-requisite courses; Implementand Code the algorithmic solutions in the C++ programming language.• Discuss and Analyse software design and development strategies; Make and Justify choices in softwaredesign and development; Explore underpinning concepts as related to both theoretical and practicalapplications of software design and development using advanced programming techniques.• Discuss, Analyse, and Use appropriate strategies to develop error-free software including static code analysis, modern debugging skills and practices, and C++ debugging tools.• Implement small to medium software programs of varying complexity; Demonstrate and Adhere to goodprogramming style, and modern standards and practices; Appropriately Use typical features of the C++language include basic language constructs, abstract data types, encapsulation and polymorphism, dynamic memory management, dynamic data structures, file management, and managing large projectscontaining multiple source files; Adhere to the C++14 ISO language features.• Demonstrate and Adhere to the standards and practice of Professionalism and Ethics, such as describedin the ACS Core Body of Knowledge (CBOK) for ICT Professionals.2 IntroductionOne challenge in robotics is called path planning. This is the process of the robot figuring out how to navigatebetween two points within some environment. In this assignment you will implement a simplified path planningalgorithm for a robot moving about a simple 2D environment – a rectangular room with obstacles.We will represent a simple 2D environment as a grid of ASCII characters. For example:===========S…….=========.==……=.===.=.=…==..=..=.===.===.=..==..==G==.====.================Aspects of the environment are represented by different symbols: SymbolMeaning= (equal)Wall or Obstacle within the environment. The robot cannot pass obstacles. (dot)Empty/Open Space.SThe start position of the robotGThe goal point that the robot is trying to reach. Each location in the environment is indexed by a (col,row) co-ordinate. The top-left corner of the environmentis always the co-ordinate (0,0), the col-coordinate increases right-wards, and the row-coordinate increasesdown-wards. For the above environment, the four corners have the following co-ordinates:(0,0) . . (9,0). .. .(0,8) . . (9,8)Two dimensional environments can be designed in different ways. For this assignment we will use environmentswhere:1. There is one goal (ending) point denoted by character “G”.2. The environment is always surrounded by walls.3. The environment can contains junctions, corridors “open” space, loops or islands.For the purposes of this assignment we will make several important assumptions:2• The robot knows the map of the whole environment it is in at the start.• Robot can only be located at cells marked as empty/open spaces.• It may not be possible for the robot to reach every empty space.• The robot can move to any one of 4 cells, that are to the left, right, up, or down from the robotsoriginating cell. Robot cannot move diagonally.• For this assignment the direction the robot is “facing” is ignored.In this assignment, the path planning problem is divided into two parts:1. forward search: Conduct a forward search algorithm starting from the “start”, until the goal is reached.The pseudo-code for the algorithm you need to implement is provided to you in Section 3.2.1.2. backtracking: Move backwards from the “goal” using, the results of forward search, to identify the shortestpath from the start to goal. You will have to develop the pseudo-code for this part. A description of thealgorithm you need to implement is provided to you in Section 3.3.1.While there are many ways to navigate a 2D environment, you must implement the algorithms providedin this document. If you don’t, you will receive a NN grade.3 Assessment DetailsThe task for this assignment is to write a full C++ program that:1. Reads in a 20×20 environment from standard-input (std::cin).2. Finds the robot’s starting position within the environment.3. Executes the forward search algorithm (Section 3.2.1) until the robot reaches the goal.4. Executes the backtracking algorithm (Section 3.3.1) to find the shortest path.5. Prints out the environment and the path to be followed by robot to standard output (std::cout).You may assume that the environment is a fixed size of 20×20, except for Milestone 4.This assignment has four Milestones. To receive a PA/CR grade, you only need to complete Milestones 1 & 2.To receive higher grades, you will need to complete Milestones 3 & 4. Take careful note of the Marking Rubricon Canvas. Milestones should be completed in sequence.3.1 Milestone 1: Writing TestsBefore starting out on implementation, it is good practice to write some tests. We are going to use I/O-blackboxtesting. That is, we will give our program a environment to solve (as Input), and then test that our program’sOutput is what we expect it to be.A test consists of two text-files:1. .env – The input environment for the program to solve2. .out – The expected output which is the solution to the environment.A test passes if the output of your program matches the expected output. Section 4.4 explains how to run yourtests using the diff tool.You should aim to write a minimum of four tests. We will mark your tests based on how suitable they are fortesting that your program is 100% correct. Just having four tests is not enough for full marks.The starter code contains a folder with one sample test case. This should give you an idea of how your testsshould be formatted.3.2 Milestone 2: Forward SearchIn this milestone, you will implement a forward search algorithm that starts from the “start” position and explorethe environment is a systematic way until it reaches the “goal” position. The pseudo-code for the algorithm youneed to implement is provided below:3.2.1 Forward Search AlgorithmIn this algorithm, a position in the environment that the robot can reach is denoted by a node and each nodewill contain the (col,row) co-ordinate and distance_travelled (the distance that the algorithm took to reachthat position from the robot’s starting position).3Pseudocode for the forward Search algorithm1 Input: E – the environment2 Input: S – start location of the robot in the environment3 Input: G – goal location for the robot to get reach4 Let P be a list of positions the robot can reach, with distances (initially contains S). This is alsocalled the open-list.5 Let C be a list of positions the that has already being explored, with distances (initially empty).This is also called the closed-list.6 repeat 7Select the node p from the open-list P that has the smallest estimated distance (see Section 3.2.2)to goal and, is not in the closed-list C.for Each position q in E that the robot can reach from p do8 9 Set the distance_travelled of q to be one more that that of p10 Add q to open-list P only if it is not already in it.11 end12 Add p to closed-list C.13 until The robot reaches the goal, that is, p == G, or no such position p can be found3.2.2 Estimated distanceFor the above algorithm we need to estimate the distance from a given node to the goal node. It is not possibleto know the exact distance from a given node to the goal before solving the path planning problem. Howeverwe can come up with an approximation. In this implementation we use the following approximation as theestimated distance from a given node, p, to the goal node G.Estimated distance = distance_travelled of node p + Manhattan distance from p to GThe Manhattan distance from node p with coordinates (colp; rowp) to node G with coordinates (colG; rowG) iscomputed as:Manhattan_distance = jcolp – colGj + jrowp – rowGjhere jxj is the absolute value of x. The Manhattan distance represent the shortest distance from a node to goalif there are no obstacles.3.2.3 Implementation detailsIt is important to have a good design for our programs and use suitable data structures and classes. InAssignment 1, you will implement our design1. You will implement 3 classes:• Node class – to represent a position (col, row, distance_travelled) of the robot.• NodeList class – provides a method for storing a list of node objects as used in pseudo-code above.• PathSolver class – that executes the forward search and backtracking algorithms.• The main file that uses these classes, and does any reading/writing to standard input/output.You are given these classes in the starter code. You may add any of your own code, but you must not modifythe definitions of the provided class methods and fields.3.2.4 Node ClassThe Node class represents a position of the robot. It is a tuple (col,row,distance_travelled), which is thex-y location of the robot, and the distance that the algorithm took to reach that position from the robot’sstarting position. It contains getters for this information and setter for distance_travelled.1This won’t be the case for Assignment 2, where you will have to make these decisions for yourself.4// Constructor/DesctructorNode(int row, int col, int dist_traveled);~Node();// get row-coodinate of the nodeint getRow();// get column-coodinate of the nodeint getCol();//getter and setter for distance traveledint getDistanceTraveled();void setDistanceTraveled(int dist_traveled);//getter for estimated dist to goal – need to return -> Manhatten distance + distance traveledint getEstimatedDist2Goal(Node* goal);3.2.5 NodeList ClassThe NodeList class provides a method for storing a list of Node objects. It stores an array of Node objects.Since it’s an array we also need to track the number of position objects in the NodeList.You must implement the NodeList class using an array.// NodeList: list of node objects// You may assume a fixed size for M1, M2, M3Node* nodes[NODE_LIST_ARRAY_MAX_SIZE];// Number of nodes currently in the NodeListint length;The constant NODE_LIST_ARRAY_MAX_SIZE is the maximum number of objects that can be in a NodeList. Thisconstant is given in the Types.h header file.#define ENV_DIM 20#define NODE_LIST_ARRAY_MAX_SIZE 4*(ENV_DIM * ENV_DIM)The NodeLsit class has the following methods:// Constructor/DesctructorNodeList();~NodeList();// Copy Constructor// Produces a DEEP COPY of the NodeListNodeList(NodeList& other);// Number of elements in the NodeListint getLength();// Add a COPY node element to the BACK of the nodelist.void addElement(Node* newNode);// Get a pointer to the ith node in the node listNode* getNode(int i);These methods let you add positions to the NodeList, and get a pointer to an existing position. Be aware, thatthe NodeList class has full control over all position objects that are stored in the array. Thus, if position objectsare removed from the array you must remember to “delete” the objects.53.2.6 PathSolver ClassThe PathSolver class executes the two parts (forward search, backtracking) of the path planning algorithm byusing the NodeList and Node classes. It has three main components:1. forwardSearch: Execute the forward search algorithm.2. getNodesExplored: returns a DEEP COPY of the explored NodeList in forward search.3. getPath: Execute backtracking and Get a DEEP COPY of the path the robot should travel. To beimplemented for milestone 3.// Constructor/DestructorPathSolver();~PathSolver();// Execute forward search algorithm// To be implemented for Milestone 2void forwardSearch(Env env);// Get a DEEP COPY of the explored NodeList in forward search// To be implemented for Milestone 2NodeList* getNodesExplored();// Execute backtracking and Get a DEEP COPY of the path the// robot should travel// To be implemented for Milestone 3NodeList* getPath(Env env);This uses a custom data type Env, which is given in the Types.h. It is a 2D array of characters that representsa environment using the format in Section 2. It is a fixed size, because we assume the size of the environmentis known.// A 2D array to represent the environment or observations// REMEMBER: in a environment, the location (x,y) is found by env[y][x]!typedef char Env[ENV_DIM][ENV_DIM];It is very important to understand the Env type. It is defined as a 2D array. If you recall from lectures/labs, a2D array is indexed by rows then columns. So if you want to look-up a position (col,row) in the environment,you find this by env[row][col], that is, first you look-up the row value, then you look-up the col value.The forwardSearch method is given an environment, and conducts the forward search in Section 3.2.1. Remember, that the initial position of the robot is recorded in the environment. Importantly, the forwardSearchmethod must not modify the environment it is given. The forwardSearch method will generate a list of nodesthe robot explored (“closedList” C in pseudo-code) and will store this list of positions in the private field:// list of positions from the forward search algorithmNodeList* nodesExplored;The getNodesExplored method returns a deep copy of the nodesExplored field. Be aware that this is a deepcopy, so you need to return a new NodeList object.The implementation of getPath method is part of milestone 3 and will be discussed in detail in Section 3.3.3.2.7 main fileThe main file:1. Reads in an environment from standard input.2. Executes the forward search algorithm.3. Gets the nodes explored in the forward search.4. Gets the full navigation path (to be implemented in Milestone 3).5. Outputs the environment (with the path) to standard output (to be implemented in Milestone 3).The starter code gives you the outline of this program. It has two functions for you to implement that read inthe environment and print out the solution.6// Read a environment from standard input.void readEnvStdin(Env env);// Print out a Environment to standard output with path.// To be implemented for Milestone 3void printEnvStdout(Env env, NodeList* path);Some hints for this section are:• You can read one character from standard input by:char c;std::cin >> c;• Remember that is ignores all white space including newlines!3.3 Milestone 3: Finding the pathFor Milestone 3, you will implement the getPath method of class PathSolver and printEnvStdout method inmain.cpp.3.3.1 Implementing getPath methodThis method finds a path from the robot’s starting position to the specified goal position using the NodeListstored in field nodesExplored (generated in your Milestone 2) – The backtracking algorithm. Then the pathfound should be returned as a deep copy. The path should contain an ordered sequence of Node objects includingthe starting position and the given goal position. You may assume that the goal co-ordinate can be reachedfrom the starting position.The backtracking algorithm is not given to you as a pseudo code. However, the following hint is given to helpyou formulate a pseudo-code.Hint: “Start from the goal node in the list nodesExplored. This would be your final element of the path.Then search for the the four neighbours of the goal node in nodesExplored. If there is a neighbour that hasdistance_traveled one less than the goal node. Then that should be the node in the path before the goal node.Repeat this backtracking process for each node you add to the path until you reach the start node.”Think carefully the path that you return must be from start to finish, not finish to start.Be aware that the returned path is a deep copy of the path, so you need to return a new NodeList object.3.3.2 Printing the pathThe next step is showing the path the robot should take in navigating from where it started until it reached thegoal. You should implement this in printEnvStdout method in main.cpp. For example, using the environmentfrom the Introduction section, the robot’s path is below:===========Sv=========v==…v

Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?