Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Introduction Product Purpose: this product is being developed as a generalized robotic guidance platform. This product will take guidance input from the console and

1. Introduction Product Purpose: this product is being developed as a generalized robotic guidance platform. This product will take guidance input from the console and translate those values into positional data for a robotic platform. 2. Standards Hardware: this product should be capable of running on a Linux platform with the gcc compiler and a means of text I/O. Language: this project will be implemented using the C++ programming language. 3. System Description System Context: this will be a self-contained piece of software that will not rely on external platforms for its basic operation. User Characteristics: users will be trained robot operators who are proficient with computer operation. This project will not be responsible for user training. 4. Functional Requirements 4.1 Startup when the software starts, it should ask the user for a number of robots to track. It should also ask the user for a unique identifier for each robot. You can assume that the user is entering unique names for each robot, you do not need to check.

4.2 Menu the user should be shown the menu of possible commands and should be able to select one command from the menu. Your program should print an error message if the user enters a letter that is not in the menu. The following commands are available in MRG: M- move one robot D- print the distance each robot has moved Q- quit the program 4.3 Move The user should be prompted to enter the unique identifier of one robot and a direction. The program should print an error if the user enters an invalid direction or if they enter an invalid robot identifier. The following directions are allowed: U- up or positive y D- down or negative y R- right or positive x L- left or negative x Your program should update the position of the correct robot by an amount equal to the robots speed (defined in Section 5.1) and then print the new position. Every robot starts at position 0,0 and can move infinitely in any direction. The position should always be printed as X,Y. 4.4 Distance (updated): This menu option should print the unique identifier of each robot and the distance that it has moved in neatly formatted columns, sorted with the robot that has moved the farthest at the top. 4.5 Quit: Your program should print a short parting message when the user selects Q. 4.6 Errors: Your program should print an appropriate error message and return to the top level menu (described in 4.2) as soon as it receives unrecognized input. 5. Non-functional Requirements Your program should store all information about Robots in a dynamically allocated array of Robot* pointers (described below). The size of this array is given by the user at startup (described in Section 4.1). Your array should not be any larger than necessary. Your program should delete all dynamically allocated memory. Comments are welcome for understanding Parameters Returns Side Effects 5.1 Robot struct The program should store the robots name, speed, and positional data in a struct with the following members: X- the current X value of the robots position Y- the current Y value of the robots position lastCommand- the last direction that the robot moved currentSpeed- the speed that the robot is traveling distance- the total distance that the robot has traveled name- the name of the robot The initial values of the X and Y members should be set to 0. This could be done with a constructor if thats familiar or in the main function. A robot speeds up the longer it moves in one direction. A robots first move in a direction will move one unit in that direction, the second move in the same direction increases the robots speed to two, the third move in the same direction to three, and then to four. Four is the maximum speed for these robots. Changing direction resets the robots speed to 1. The distance value should store the total number of squares that the robot has moved, not its euclidean distance from the starting position. For example, a robot that moves four spaces up and then three spaces right should have a distance of seven even though the straight line distance back to (0,0) is only five. 5.2 findRobot function This function should find the index of one Robot in the array of Robots using its unique identifier.

The parameters of this function are: Robot* roboList[]: an array of robots pointers string identifier: the target unique identifier SIZE: the number of robots in roboList Return the index of the robot with a matching identifier as an int, or -1 if the identifier is not in the list.

5.3 moveRobot function The position of the robot struct should be updated using a void function called moveRobot. The parameters of this function are: Robot r: a Robot pointer char d: a character value representing one direction The robots position should be updated as described in Section 4.3 (so if d == U, then increase r.y by r.currentSpeed, etc.) This function also needs to update the current speed and the distance traveled for the robot. The robots speed increases by one unit every time it moves in the same direction up to a maximum speed of four. See Section 5.1 for more information about speed and distance. Only this function should be used to change the robots position after the initial position has been set. 5.4 makeRoboList function The list of robots should be created in this function. The list should be of whatever length the user specifies (described in Section 4.1)

The parameters of this function are: numRobos: the size of the list. This function should dynamically allocate a new array of the given size and return a pointer to this array of Robot pointers (the return type will be Robot**). Notice that there are two steps to the process of making the robot list: 1.Dynamically allocate the array of Robot pointers. 2.Dynamically allocate a Robot for each element of the array. 5.5 Interface: the display should be neatly formatted and easily readable by the user. You may choose the exact formatting of the output, but it must be consistent on a terminal with an 80 character width. Your program should let users enter characters as upper OR lower case.

6. Guidance The robot should speed up every time it moves in the same direction. You need to be able to compare characters regardless of whether they are upper or lower case. The ctype.h library might help. The program should keep running until the user selects Q. There should be a loop in your main function that breaks when a user types Q. The iomanip library might help you with your formatting, but it is not required. Just make sure everything looks good. You will need a search algorithm to find one Robot in the list of Robots. Think about which one is best for this project. The new keyword is used to dynamically allocate memory. Remember to free that memory using the delete keyword.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago