Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Motivating scenario In HW3, you simulated a mail delivery robot on your computer

ID: 3682053 • Letter: M

Question

Motivating scenario

In HW3, you simulated a mail delivery robot on your computer. You will now translate the program to 3pi robot.

Figure 1: Mail delivery paths with ten different addresses, where packages may have to be delivered.

Just as in homework 3, your program consists of three main modes: (a) track learning, (b) getting delivery addresses, and (c) delivery, described below.

Mode 1: Track learning: Assuming the robot is placed on track at the dispatch station facing away from the station) the robot traverses the entire track in the clockwise direction using the left-hand-on-wall strategy, while recording the sequence of turns at the junctions in a linked list.

Mode 2: Getting delivery addresses: At the end of the learning process, the robot will return to the dispatch station. It will then wait for the user input. The user will provide a list of addresses (between 0 and the maximum # addresses).

Mode 3: Delivery: Once the delivery addresses are obtained from the user, the robot have to travel from the dispatch to the specified addresses in the clockwise sense through the shortest route (i.e, by skipping the visit to the addresses not in the list of delivery addresses).

Since the on-board memory on the 3 robot is limited, you need to use a linked list to store the turns rather than an array of fixed number of turns. To facilitate testing and debugging your program, this homework has been divided into two parts: 1) implement and test the required functionality for the linked list of turns, and 2) implement your homework 3 solution using the 3pi robot.

1Part 1 - Implement the linked list functionality

In this part, you will implement the linked list functionality in the turnList.c file. We have provided code (testTurnList.c) for you to be able to test your code in the PC. The node structure for the linked list is defined in turnList.h and consists on a character member turn and a pointer to the next node nextPtr. The linked list and helper functions should be added in turnList.c and turnList.h. The main functions you are required to create are:

Mode 1: Since you are replacing arrays with linked lists, you should create basic functions to work with linked lists.

< >: this function should create a new node with value specified by turn and append it to the end of the list.

< >: this function frees all the memory in the list.

< >: this function computes the number of turns in the linked list.

giveAddressLocations this function returns the number of addresses (’U’ turns) and pointers of the nodes corresponding to the addresses (see figure below). After this function is called, addressLocations is an array of pointers to nodes in the list with U turns. These pointers can be used later for the simplification of the turns linked list.

< >: this function appends a linkedlist to the end of another linked list. Note that once the linked lists are concatenated, you only need to free the top linked list. If you attempt to free both, you will get a segmentation fault.

should use the function testMode1 within testTurnList.c to test the above functions on your computer before moving the code to the 3 robot.

Mode 3: You need to simplify the learned turnlist using turnlist functions from part 1. The required tasks are

You are required to create the function in the file . This function takes in a segment of a turnList between startPtr and endPtr and simplifies it by cutting out all visits to intermediate stations. For example, if you pass the entire turnList (by setting endPtr as the pointer to the last node), it will return a list with visits to all intermediate stations removed. This function can be implemented by creating a new linkedlist by sequentially appending the turns from the input list between and . The function is given and should be called after each turn is added.

You are required to create the function to create the optimized path from the original path. The main steps in this function are:

use to obtain the pointers to the nodes with the stations. See figure below.

get the delivery addresses from the user.

Using the above inputs, obtain the simplified segments and concatenate them to obtain the final list. See figure below.

See Figure below for the illustration. You should use the function testMode3 within testTurnList.cto test the above functions on your computer before moving the code to the 3 robot.

S

S

S

S

L

L

U

R

L

S

S

L

U

L

S

S

U

Your code should be written in turnList.c file in your homework/hw4 directory. You can compile these files using the attached codeblocks project testTurnList.cbp or by typing the command g++ turnList.c testTurnList.c -o test.exe

./test.exe

You are also required to include standard documentation blocks above any functions that you may use and at the top of your file.

2Part 2 - Functions for 3 robot

Mode 1: Track Learning: The following helper functions are provided in hw4-utility.c:

auto_calibrate_line_sensors calibrates the sensors. This function should be run the first time to adjust for light conditions.

< >: returns the sensor value flags indicating if the robot has a line to the left, right, ahead, or if it is back at the dispatch station (solid black).

< >, turnLeft, uTurn, stopRobot & moveStraight function to move the robot.

follow_segment moves the robot forward, while ensuring that it stays on the track.

You need to complete the function learnAddresses in hw4.c. The robot will repeat the following steps in a loop:

It will move forward using .

It will read the sensors using .

If it is at the end (back at dispatch), it should make a U turn, record the U turn in the linked list, and stop.

Else if it is at an intersection (straight turn is not available or there is a track available on right or left), it should follow the left hand on the wall strategy to decide. The turns taken by the robot has to be recorded in the linked list.

Mode 2: Getting delivery addresses: You need to obtain the delivery addresses between 0 and maximum number of addresses from the user and have them sorted. You may use the int readUserInput in hw4-utility.c to replace the scanw of the delivery address and the same logic you developed in HW3.

Mode 3: Delivery: You need to complete the function goToAddresses in hw4.c. The robot will repeat the following steps in a loop

It will move forward using .

It will read the sensors using .

If it is at the end (back at dispatch), it should make a U turn and stop.

Else if it is at an intersection (straight turn is not available or there is a track available on right or left) it has to play the next turn the optimized linked list.

In your top documentation block, please also include high-level pseudocode for your program. Your program should be written so that it will work with any track. Two tracks are available in the CIE lab. Since the first maze is smaller, it may be easier to work with during the development of your program.

Your submission will be tested using a different track.

using c++ program

Motivating scenario

In HW3, you simulated a mail delivery robot on your computer. You will now translate the program to 3pi robot.

Figure 1: Mail delivery paths with ten different addresses, where packages may have to be delivered.

Just as in homework 3, your program consists of three main modes: (a) track learning, (b) getting delivery addresses, and (c) delivery, described below.

Mode 1: Track learning: Assuming the robot is placed on track at the dispatch station facing away from the station) the robot traverses the entire track in the clockwise direction using the left-hand-on-wall strategy, while recording the sequence of turns at the junctions in a linked list.

Mode 2: Getting delivery addresses: At the end of the learning process, the robot will return to the dispatch station. It will then wait for the user input. The user will provide a list of addresses (between 0 and the maximum # addresses).

Mode 3: Delivery: Once the delivery addresses are obtained from the user, the robot have to travel from the dispatch to the specified addresses in the clockwise sense through the shortest route (i.e, by skipping the visit to the addresses not in the list of delivery addresses).

Since the on-board memory on the 3 robot is limited, you need to use a linked list to store the turns rather than an array of fixed number of turns. To facilitate testing and debugging your program, this homework has been divided into two parts: 1) implement and test the required functionality for the linked list of turns, and 2) implement your homework 3 solution using the 3pi robot.

1Part 1 - Implement the linked list functionality

In this part, you will implement the linked list functionality in the turnList.c file. We have provided code (testTurnList.c) for you to be able to test your code in the PC. The node structure for the linked list is defined in turnList.h and consists on a character member turn and a pointer to the next node nextPtr. The linked list and helper functions should be added in turnList.c and turnList.h. The main functions you are required to create are:

Mode 1: Since you are replacing arrays with linked lists, you should create basic functions to work with linked lists.

< >: this function should create a new node with value specified by turn and append it to the end of the list.

< >: this function frees all the memory in the list.

< >: this function computes the number of turns in the linked list.

giveAddressLocations this function returns the number of addresses (’U’ turns) and pointers of the nodes corresponding to the addresses (see figure below). After this function is called, addressLocations is an array of pointers to nodes in the list with U turns. These pointers can be used later for the simplification of the turns linked list.

< >: this function appends a linkedlist to the end of another linked list. Note that once the linked lists are concatenated, you only need to free the top linked list. If you attempt to free both, you will get a segmentation fault.

should use the function testMode1 within testTurnList.c to test the above functions on your computer before moving the code to the 3 robot.

Mode 3: You need to simplify the learned turnlist using turnlist functions from part 1. The required tasks are

You are required to create the function in the file . This function takes in a segment of a turnList between startPtr and endPtr and simplifies it by cutting out all visits to intermediate stations. For example, if you pass the entire turnList (by setting endPtr as the pointer to the last node), it will return a list with visits to all intermediate stations removed. This function can be implemented by creating a new linkedlist by sequentially appending the turns from the input list between and . The function is given and should be called after each turn is added.

You are required to create the function to create the optimized path from the original path. The main steps in this function are:

use to obtain the pointers to the nodes with the stations. See figure below.

get the delivery addresses from the user.

Using the above inputs, obtain the simplified segments and concatenate them to obtain the final list. See figure below.

See Figure below for the illustration. You should use the function testMode3 within testTurnList.cto test the above functions on your computer before moving the code to the 3 robot.

S

S

S

S

L

L

U

R

L

S

S

L

U

L

S

S

U

Your code should be written in turnList.c file in your homework/hw4 directory. You can compile these files using the attached codeblocks project testTurnList.cbp or by typing the command g++ turnList.c testTurnList.c -o test.exe

./test.exe

You are also required to include standard documentation blocks above any functions that you may use and at the top of your file.

2Part 2 - Functions for 3 robot

Mode 1: Track Learning: The following helper functions are provided in hw4-utility.c:

auto_calibrate_line_sensors calibrates the sensors. This function should be run the first time to adjust for light conditions.

< >: returns the sensor value flags indicating if the robot has a line to the left, right, ahead, or if it is back at the dispatch station (solid black).

< >, turnLeft, uTurn, stopRobot & moveStraight function to move the robot.

follow_segment moves the robot forward, while ensuring that it stays on the track.

You need to complete the function learnAddresses in hw4.c. The robot will repeat the following steps in a loop:

It will move forward using .

It will read the sensors using .

If it is at the end (back at dispatch), it should make a U turn, record the U turn in the linked list, and stop.

Else if it is at an intersection (straight turn is not available or there is a track available on right or left), it should follow the left hand on the wall strategy to decide. The turns taken by the robot has to be recorded in the linked list.

Mode 2: Getting delivery addresses: You need to obtain the delivery addresses between 0 and maximum number of addresses from the user and have them sorted. You may use the int readUserInput in hw4-utility.c to replace the scanw of the delivery address and the same logic you developed in HW3.

Mode 3: Delivery: You need to complete the function goToAddresses in hw4.c. The robot will repeat the following steps in a loop

It will move forward using .

It will read the sensors using .

If it is at the end (back at dispatch), it should make a U turn and stop.

Else if it is at an intersection (straight turn is not available or there is a track available on right or left) it has to play the next turn the optimized linked list.

In your top documentation block, please also include high-level pseudocode for your program. Your program should be written so that it will work with any track. Two tracks are available in the CIE lab. Since the first maze is smaller, it may be easier to work with during the development of your program.

Your submission will be tested using a different track.

S

S

S

S

L

L

U

R

L

S

S

L

U

L

S

S

U

Explanation / Answer

public class SendEmail { public static void main(String[] args) throws Exception { String smtpServer = "smtp.gmail.com"; int port = 587; final String userid = "youraddress";//change accordingly final String password = "*****";//change accordingly String contentType = "text/html"; String subject = "test: bounce an email to a different address " + "from the sender"; String from = "youraddress@gmail.com"; String to = "bouncer@fauxmail.com";//some invalid address String bounceAddr = "toaddress@gmail.com";//change accordingly String body = "Test: get message to bounce to a separate email address"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.port", "587"); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.from", bounceAddr); Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(userid, password); } }); MimeMessage message = new MimeMessage(mailSession); message.addFrom(InternetAddress.parse(from)); message.setRecipients(Message.RecipientType.TO, to); message.setSubject(subject); message.setContent(body, contentType); Transport transport = mailSession.getTransport(); try { System.out.println("Sending ...."); transport.connect(smtpServer, port, userid, password); transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO)); System.out.println("Sending done ..."); } catch (Exception e) { System.err.println("Error Sending: "); e.printStackTrace(); } transport.close(); }// end function main() }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote