User:Gknapp2779/Project2

Project Preference

 * 1) Power Wheel
 * 2) Maker Bot PLA Characteristics
 * 3) Wind Turbine

Problem Statement
''In one or two sentences, describe the project that your group will be working on. Identify which one or two CDIO documents your group will create in this project cycle.''

Project Plan
Briefly describe your group's plan for the next 4 weeks, including the specific activities that will take place each week.

Week 1 Narrative
For the first week working on the Mobile Robot project, it was my job to look up how the compass sensor works, and how we could apply this to our design for the Mobile Robot.

The LEGO MINDSTORMS NXT Compass Sensor works by detecting the magnetic direction that it is facing. This magnetic direction would be in a normal 360 degree measurement with 0 degrees being North, 90 degrees being East, 180 degrees being South, 270 degrees being West,and finally 359 degrees, which is 1 degree counter clockwise of North.

However, in Matlab, the compass sensor is coded as an int8 value. This means the coding does not use Base 10 numbering(the number format we use in our everyday life). The coding uses Base 8 numbering. So instead of 0, 90, 180, and 270 degrees being North, East, South, and West respectively, the coding would use 0 as North, 132 as East, 264 as South, and 416 as West. (Bases Calculator used).

We could use this in our design by detecting what degrees of direction the hallways have. With that information we could make sure the Robot never veers off the given path by more than the coded range we decide. When we get to the point where we want the car to turn a corner in the hallway, we can have the code change the range to be within the range of the new hallways direction.

In this video, it shows how the Robot can be programmed to turn to a specific compass heading by using the compass sensor.

Week 2 Narrative
Design 1 This week, it was my job to design and put together our first prototype of the Mobile NXT Robot. The way we decided to do it was to have an Ultrasonic sensor on the front of the robot and an Ultrasonic sensor on the left side of the robot. The purpose of this was to have the robot sense the distance of objects in front and to the left of the robot. The left sensor was to help the robot follow the inner wall around the hallway, so if the robot is to close to the wall it will go right, and if the robot is to far away from the wall, it will go left. The front sensor's purpose is to make sure the robot does not run into any obstructions like pillars or people.



Hallway Schematic The second part of what I had to do this week was to create a basic layout of the hallways with precise measurements. Since a tape measure was not nearly long enough to measure the entire length of a hallway, I decided to measure the space from one pillar to next. Since each pillar has the same distance between each of them, I multiplied the distance between pillars by the amount of pillars minus one (since I am counting the spaces in between) and then added and subtracted the extra spaces that the pillars did not cover. Once I collected the measurements of the entire hallway, I made a CAD 2-D design so we could easily refer back to the path and distance that the robot must venture. The schematic I made is just a simple design where the width of the hallway is the very smallest point of each hallway.

Robot Coding With my group, we got together and tried to work with the coding of the project. At first, we had trouble with the robot doing anything besides going in circles, but after some fiddling we got to the point where the robot would always slightly turn left if the left sensor and the front sensor does not detect something within its coded range. If the left sensor detects something and the the front sensor does not within the coded range, the robot will slightly turn right. If the front sensor detects something and the left sensor does not, it will sharply turn right. If the front sensor detects something and the left sensor does as well, it will still turn right sharply. With this code the Mobile Robot was able to go down a full length of hall, turn onto another hallway, and go half the length of the next hallway before it got stuck on a pillar.

Week 3 Narrative
This week I had to think up some ideas for how I might solve the problems I had and make it so the NXT Robot will travel all the way around the hallway without running into obstacles and without assistance.

Problems

The main problems that were keeping the robot from making it all the way around the hallway:


 * 1) The Robot gets stuck in such corners that its sharp turning feature can not save the Robot from running into the obstruction.
 * 2) The Left Ultrasonic Sensor is protruding so far out of the robot that it sometimes gets caught on an obstruction.

Possible Solutions to Stop the Robot From Getting Stuck in Corners


 * 1) Increase the range of the Ultrasonic Sensor so it will not get in the situation that it might get stuck in a corner.
 * 2) Add another Ultrasonic Sensor in between the first two sensors and point it diagonally so it eliminates the blind spot.
 * 3) Add code to program so it backs up out of the corner.

Reasoning For or Against the Possible Solutions


 * 1) Increasing the range of the Ultrasonic Sensors could possibly make it so the Robot does not get stuck in a corner. However, since the Robot moves in a very back and forth kind of way, the Front Ultrasonic Sensor might see the opposite wall and get turned around to move in the opposite direction that we want it to move in.
 * 2) Adding Another Ultrasonic Sensor diagonally in between the other two sensors would eliminate the blind spot and might keep the Robot from going into the corner to begin with. However, adding another Ultrasonic Sensor would add another variable to the code and I would have to change the entire code to incorporate it. I also checked all of the parts boxes in the Engineering Workshop, and I did not see any parts that would even allow the Ultrasonic sensor to look diagonally.
 * 3) Adding a back up feature to the Robot's code would make it so that if it got to close to an obstruction, it would back away from the obstruction. When the car got out of the given range, the robot would sharply turn around the obstacle. This would be simple enough to code because all I would have to do is add a couple lines of code and slightly change one other part of the code.

Possible Solutions to Keep the Left Ultrasonic Sensor From Getting Stuck


 * 1) Add another Ultrasonic Sensor in between the first two sensors and point it diagonally so it eliminates the blind spot.
 * 2) Move the left Ultrasonic Sensor to the right side of the robot so it is not jutting out on the left side.

Reasoning For or Against the Possible Solutions


 * 1) Adding Another Ultrasonic Sensor diagonally in between the other two sensors would eliminate the blind spot and might keep the Robot from hitting the Left Ultrasonic sensor on an obstruction. However, for the same reason that it would cause problems with the other problem, it would complicate the code and I do not have the materials to make it point diagonally. Also, this is also jutting out of the Robot and also has a chance to get caught on an obstruction, just like the Left Sensor.
 * 2) Moving the Left Ultrasonic Sensor to the right side would get the sensor out of the way so it will not catch on an obstruction on the left side.

Decisions Through the reasoning I have given above, it has been decided to move the Left Ultrasonic Sensor to the right side and to add code to the program that will make the Robot back up if it gets to close to the Front Sensor.

Coding and Testing Process In coding the Robot to back, an if statement had to be added so that if an object is less than 10 cm, the robot would back up and allow the turn sharply if statement to kick in. Along with added the if statement, the turn sharply statements had to be changed to less than 80 cm and greater than 10 cm. We did this and tested it, but the Robot did not have enough space to turn sharply around the obstacle. So the 10 cm was eventually changed to 30 cm, which worked and made it around the obstacle.

Flaw

I sent it on a test run around the hallway and it successfully made it all the way around the hallway without running into any obstacles. Unfortunately, I did not have a video Camera to record the success. When a team member came to help, we did another test run with him video taping, but the Robot did not make it around because it got stuck with the Front Ultrasonic Sensor's eyes on the corner of a bench's leg. We attempted other codes like making it back up to the left (did not have a noticeable change) and increasing the range, but we could not trouble shoot a solution.

Next Time

We might possible add a timer to the backing up feature so that if it sees an object to close to the front sensor, it will back up for a second and continue. We are also going to ask the class for any ideas on how to fix this problem. If they give us some good ideas then we might implement them to our design.

Week 4 Narrative
For this week, I mostly worked with my group on polishing the functions of the Robot and writing up the CDIO Report.

Natacha wrote a backing up program while she was on her own and she wanted me to test it and maybe make some changes to the code if I saw necessary.

Testing Part 1 I uploaded the code onto the robot and took it out into the hallway to test it out. I activated the robot and the new program, and all the robot did was back up. The backing up and timer function that was being added to the code was overriding all of the other functions of the code. I recalled what Professor Edelen said about the way we were using the timer in the code, and apparently the way we had it made it so when the backing up function was activated, a global variable would increase but it never returned back to the starting value. This starting value is what lets all of the other functions work. So, I went through the code and added an A = 0 to all of the if statements that did not apply to backing up (A is the global variable and 0 is the initial value that does not make the robot back up).

Testing Part 3 With this test, the Robot worked fine and made it all the way around the hallway. If the Robot was going to get stuck in a tight corner, it would back up and turn out of the bad spot. Every now and again it just barely detects the wall to close and backs up pointlessly, but for the most part, the Robot works just how we want it.