56871861 final report

58
Letter of Transmittal Dear Sir/Madam, Attached is the submission of the Autonomous Watercraft Final Report due Friday 3rd of June. The purpose of the report is to decide upon a design solution for the autonomous watercraft as requested by the consortium including the Queensland Government Department of Maritime Safety, the Australian National Parks and Wildlife Service and the Defence Materials Organisation. Yours Sincerely, Rachel McDonnell, Michael Stewart, Harrison Hope, Tom Jewell, Wenbin Wu, Chris Mangion Team Yellow

Upload: rachel-mcdonnell

Post on 04-Jul-2015

131 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 56871861 Final Report

Letter of TransmittalDear Sir/Madam,

Attached is the submission of the Autonomous Watercraft Final Report due Friday 3rd of June.

The purpose of the report is to decide upon a design solution for the autonomous watercraft as requested by the consortium including the Queensland Government Department of Maritime Safety, the Australian National Parks and Wildlife Service and the Defence Materials Organisation.

Yours Sincerely,

Rachel McDonnell, Michael Stewart, Harrison Hope, Tom Jewell, Wenbin Wu, Chris MangionTeam Yellow

Page 2: 56871861 Final Report

Executive SummaryEnvironmental disasters, whether man made or natural, have devastating effects on social, economic and environmental facets of the community. In the event of a disaster, it is essential to implement efficient and effective disaster management procedures to restore normality and quality of life within a community. In the event of a water related disaster, whether it is a flood, oil spill or shipping disaster, a quick clean up is even more critical to reduce the risk of spreading disease through water and disturbing the delicate ecosystems. Recognising this need, a consortium including the Queensland Government Department of Maritime Safety, the Australian Parks and Wildlife Service and the Defence Materials Organisation have issued a call for tenders for the design and development of an automated watercraft to enter areas hazardous to humans in a disaster (UQ 2011). The prototype of this craft will be designed to collect ping pong balls from a tub with a 2m diameter and will have sufficient power to last 10 minutes. The boat features a catamaran hull design with two 6V motors powering propellers through gearboxes. The craft implements a spiral search pattern algorithm using infrared distance and tactile bump sensors.

Page 3: 56871861 Final Report

Table of ContentsExecutive Summary...............................................................................................................................1

1.0 Introduction.....................................................................................................................................2

1.1 Background..................................................................................................................................2

1.2 Project Scope...............................................................................................................................2

1.2.1 Design Objectives..................................................................................................................3

1.2.2 Assumptions.........................................................................................................................4

1.2.3 Limitations and Constraints..................................................................................................4

2.2 Mechanical Systems.....................................................................................................................5

2.3 Propulsion Systems..................................................................................................................5

2.4 Electrical Systems.........................................................................................................................7

2.5 Software Program........................................................................................................................7

4.0 Design Justification..........................................................................................................................9

5.0 Final Design...................................................................................................................................11

5.1 Design Overview........................................................................................................................11

5.2 Hull Design.................................................................................................................................12

5.3 Collection System.......................................................................................................................13

5.4 Artificial Intelligence..................................................................................................................13

5.4.1 Spiral Algorithm..................................................................................................................13

5.4.2 Bump Sensor Input Handling..............................................................................................14

5.4.3 Issue Detection by Analysis of Historical Sensor Data.........................................................14

5.4.4 Hardware............................................................................................................................15

5.4.5 Sensor Electronics...............................................................................................................15

5.5 Power Supply.............................................................................................................................16

5.6 Propulsion System.....................................................................................................................16

6.0 Design Drawings............................................................................................................................18

Page 4: 56871861 Final Report

6.0 FMEA.............................................................................................................................................18

7.0 Life Cycle Assessment....................................................................................................................19

7.1 Goal Definition and Scope.........................................................................................................19

7.2 Inventory Analysis......................................................................................................................19

7.3 Impact Assessment....................................................................................................................20

7.4 Improvement Assessment/Interpretation.................................................................................20

8.0 Recommendations.........................................................................................................................21

9.0 Bibliography...................................................................................................................................21

Appendix 1...........................................................................................................................................25

FMEA Table......................................................................................................................................25

Appendix 2...........................................................................................................................................28

Pair Wise Comparison......................................................................................................................28

Appendix 3...........................................................................................................................................29

Decision Making Matrix...................................................................................................................29

Appendix 4...........................................................................................................................................30

Distance Sensor Calibration.............................................................................................................30

Appendix 5...........................................................................................................................................31

Battery Calculations.........................................................................................................................31

Appendix 6...........................................................................................................................................32

Buoyancy Calculations.....................................................................................................................32

Appendix 7...........................................................................................................................................33

Stability Calculations........................................................................................................................33

Appendix 8...........................................................................................................................................34

Drag Calculations.............................................................................................................................34

Appendix 9...........................................................................................................................................35

Software Calculations......................................................................................................................35

Appendix 10.........................................................................................................................................36

Page 5: 56871861 Final Report

Complete Arduino Code..................................................................................................................36

List of Figures and TablesTable 1. Social, Environmental, Economic Effects of Queensland Floods & Oil Spill...............................5

Table 2. Project scope............................................................................................................................6

Table 4. Propulsion options...................................................................................................................9

Table 5. Battery Properties..................................................................................................................10

Figure 3. Relative Criteria Weightings..................................................................................................12

Table 8. Design Options.......................................................................................................................13

Table 9. Summary of design features...................................................................................................14

Figure 4. Motor Speeds.......................................................................................................................17

Figure 5. Tactile Bump Switch..............................................................................................................18

Figure 6. IR Distance Sensor.................................................................................................................18

Table 10. Current Requirements (See appendix for calculations)........................................................19

Figure 7. Torque vs Current..................................................................................................................20

Page 6: 56871861 Final Report

1.0 Introduction

1.1 BackgroundWaterways are vital to our way of life. Communities depend on waterways for public transport, commercial shipping, industrial manufacturing, agriculture, fishing and recreation. As a result, there are many social, economic and environmental factors that must be considered when making responsible decisions that affect our waterways. When disaster strikes waterways can become polluted with debris, oil or even radioactive contaminants. In recent months there have been several events which have highlighted the vulnerability of waterways. The 2011 Queensland and Brisbane floods and the earthquake and tsunami in Japan are some of the more recent examples. Environmental disasters can cause significant damage. The table below outlines the social, environmental and economic effects of two recent waterway disasters.

Table 1. Social, Environmental, Economic Effects of Queensland Floods & Oil Spill

Queensland Floods Gulf of Mexico Oil SpillSocial More than 75% of state affected.

This includes flooded homes, workplaces and isolation of towns. (Salvation Army 2011)

Health problems associated with disease to people along the Gulf of Mexico (Marcus E Dr 2011)

Environmental Ecosystems disrupted, riverbank erosion, soils and waterways contaminated (Wildlife Queensland 2011)

Five species of sea turtles in Gulf, ecosystems destroyed, underwater oxygen supply limited (Judd A 2010)

Economic Extent of economic cost predicted at US$10 billion as of early February (McNamara M 2011)

Has so far cost BP US$41 billion (Trotman A 2011)

To assist in future disaster management, a consortium including the Queensland Government Department of Maritime Safety, the Australian National Parks and Wildlife Service and the Defence Materials Organisation have issued a call for tenders for an autonomous watercraft to assist in the recovery of debris and clean up in areas hazardous to humans (UQ 2011).

1.2 Project ScopeThe aim of this report is to outline the design of an automated watercraft to assist in the clean up of marine disasters. The table below outlines the aspects that are considered in scope of the project and those that are considered negligible.

Page 7: 56871861 Final Report

Table 2. Project scope

In Scope Out of ScopeAnalysis of:

Drag due to water Buoyancy Stability

Analysis of: Aerodynamic drag due to air

resistance Effects of vessel's bow wave Effects of uneven water surface

Design of: Propulsion mechanism Electrical circuit connecting all

sensors, actuators, microprocessors and power supplies

Hull considering strength, size, weight, waterproofing, stability, rigidity and manoeuvrability

Debris collecting mechanism Software to control craft, motors

and actuators to collect debris Software to gather and collect

data from sensors Logic to decide where to move

the given sensor data

Avoidance of: Underwater hazards Overhead hazards (eg. Bridges)

Launching of vessel into the water

Rusting of the hull

Disposal of debris and land collection

Varying weather conditions

1.2.1 Design ObjectivesThe requirements of the craft are as follows;

The prototype must fit in a box with the dimensions; 30cmx30cmx30cm however, it is desirable for it to fit within a box of 15cmx20cmx20cm.

The watercraft must be fully autonomous and must operate without touching the bottom of the tank when fully loaded.

The craft should pick up a maximum amount of debris.

It is desirable for the craft to have a draft of less than 5cm when fully loaded and have a freeboard of at least 1cm below the bottom of the plastic container.

The watercraft must also have a power supply that enables it to last 10 minutes in total.

The craft must work reliably with minimal maintenance.

The craft must comply with a $50 budget but must also be relatively cheap at in the full scale design.

Page 8: 56871861 Final Report

1.2.2 Assumptions During the process of design, a number of assumptions will be made. These are as follows;

There will be no current in the water as the prototype will be tested in an enclosed tank

There will be no air resistance or high winds

No sensors will be designed or assembled; they will be purchased as standalone parts.

Software will be written for an Arduino UNO microcontroller board.

No microprocessors will be designed or fabricated.

Motors and gearboxes for the propulsion system will be supplied.

The density of water will be taken at 1000kg/m^3.

The force acting upon the craft due to surface tension will be taken as 0.

As the craft will be travelling at low speeds, the drag acting upon the craft will be assumed to be negligible.

The craft will be deployed in the water.

1.2.3 Limitations and Constraints The watercraft must run on a portable power supply, that is, it cannot be attached to a

power pack or usb

Materials must be light enough for the watercraft to float

Page 9: 56871861 Final Report

2.2 Mechanical SystemsThere are a wide variety of hull designs that could be used for the construction of an automated watercraft. A flat bottomed hull has straight or rounded edges. Its features are outlined below:

Large surface area results in shallow draught

Simple to construct

Excellent stability at low speeds

Low design complexity

Low manoeuvrability

A pontoon has two separate hulls that are connected via the deck. Its features are outlined below:

Provides exceptional grip in tight turns

Much more stable than other hull designs

Deck remains relatively dry due to distance raised above the water

Easy to manoeuvre with an outboard motor

Easier to construct than v or round bottom hulls

Can be used effectively with a flat deck

Space between hulls allows for storage and collection

Simplicity of design and construction results in lower construction costs

Lower surface area in contact with water than for other hulls results in greater draught

Less compact as it is wider than boats with different hulls

The pontoon hull is more suitable for the automated watercraft due to the available storage space and greater manoeuvrability than a flat bottomed hull.

2.3 Propulsion SystemsThere are many propulsion mechanisms used in maritime systems. These include:

Fans Propeller Impellers Paddlewheels

The pros, cons and suitability of different propulsion systems are outlined in table 4.

Figure 1. Flat Bottomed Hull

Figure 2. Pontoon Hull

Page 10: 56871861 Final Report

Table 4. Propulsion optionsPropulsion System

Description Pros Cons Suitability

Propeller (Above water

Propellers are fans that convert axial rotation into thrust.

+Can be placed above water (No interference with draft or net)

-Higher RPM required / Larger fan size for equal thrust.

The fact that above water propellers can be placed, above the water, and thus have little to no effect on the net or draft, makes them an attractive option.

However, larger diameter required makes this design unsuitable due to the dimensional restraints of the craft.

Propeller (Under water)

+Water is a more dense fluid, thus smaller propellers can be used.

-Have to sit in water and may increase draft of craft.

-Propellers may interfere with fan.

Although underwater propellers interfere may possibly interfere with the draft of the craft as well as the net used, they are highly suitable for the design as they produce an equal amount of thrust for a much smaller propeller diameter. Through proper integration into the design, the problems associated with underwater propellers could also be reduced or eliminated.

Paddlewheel Waterwheel incorporating scoops around the wheel to push through water

+Motors can be placed on the top of deck.

+Gearbox can be directly connected to paddlewheel

-Much less efficient than propeller. (Force has upward and downwards component)

-Very draft sensitive

-Not as readily available as propellers

Despite the advantages relating to the placement and attachment of paddlewheels, the unavailability of such paddlewheels in combination with the inefficiency of the paddlewheel design makes it an unattractive option.

This, in combination with the fact that paddlewheels are very sensitive to shallow drafts, makes this design highly unsuitable. One of the vital design specifications of the craft is a small draft. Thus, a trade-off occurring between speed and draft is undesirable.

Page 11: 56871861 Final Report

2.4 Electrical SystemsThere are two main types of battery that can be used in powering the watercraft. Primary batteries can produce current immediately whilst secondary batteries must be charged before use (Thomas and David 2010). Primary batteries cost less per battery and have a higher capacity and initial voltage that secondary batteries (Castelvecchi 2009) however, secondary batteries can be reused and are therefore more environmentally friendly and may work out more cost efficient if the batteries are needed for an extended period of time (Armand and Tarascon 2008). Primary batteries will be used in the watercraft design because of the higher initial voltage and capacity. Size, weight and power capacity of each battery will need to be considered in the design. The table below compares voltage, weight, size and service characteristics of different types of Energizer batteries (one brand was used for standardisation and simplicity).

Table 5. Battery Properties

Battery Model Voltage (V)

Average Weight (g)

Size (length x diameter) (mm)

Service Hours (mAh) at 70mA

AA E91 1.5 23.0 50.50 x 14.50 25

C E93 1.5 66.2 50.0 x 26.20 80

D E95 1.5 148.0 61.50 x 34.20 150

528 6.0 885.0 112.00 x 68.20 (width) 170

522 9.0 45.6 48.50 x 26.50 (width) 7

A23 12.0 8.0 28.50 x 10.30 <1

2.5 Software ProgramThe most widespread automated cleaning device is the iRobot Corporation’s Roomba vacuum. The most basic Roomba model sells for AU$599 in Australia (iRobot, 2011). The device has two drive wheels with basic suspension. An optical sensor detects if the wheels are turning at the correct speed so more power can be given to a wheel if it becomes stuck. The robot turns by driving one wheel faster than the other. The device uses four sets of infrared detectors and emitters to sense when the device is on the edge of a “cliff” such as a staircase. During normal operation the IR emitters send out light and the IR detectors receive reflected light back yet when the emitter / detector pair is over a void the detector no longer senses reflected light and the wheels are stopped (Cravotta, 2006). The robot uses a spatial reasoning algorithm called Monte Carlo Localization (MCL). This algorithm allows the

Page 12: 56871861 Final Report

Roomba to determine its location in the room given sensor data and known dimensions of the room. In this method a number of hypothetical possible locations are scattered randomly across the room. The probability of the robot being at each location given the sensor data it is receiving is calculated using Bayes’ Theorem (Thrun et al, 2001). Each time the sensor data is updated the probabilities are recalculated. When the probability of a hypothetical location is very low that location is replaced with a new randomly generated one.

The LawnBott from Paradise robotics is an autonomous consumer robot that can mow a lawn. In Collin’s (2007) review of the device he noted that the device requires a boundary wire to be placed around the yard’s perimeter. However, when this wire is in place the robot can mow the lawn then autonomously dock and recharge until its next use. The LawnBott starts at the center of the lawn then moves outward in a circle until the whole lawn bas been mown. This circular pattern is an effective way to ensure that an entire surface has been covered and is therefore a possible search pattern algorithm for the autonomous watercraft.

Page 13: 56871861 Final Report

4.0 Design JustificationThe following criteria where established as a benchmark upon which to judge possible design options:

Performance: How much debris does the boat collect in a given time period. Cost: The price of the materials and manufacturing at a large scale. Size: It is desirable for the boat to fit in a box measuring 150 x 200 x 200mm Battery Life: The watercraft must feature a power supply that enables it to last a total

of 10 minutes. Buoyancy: The craft must float with a draft of less than 5cm. Sustainability: The craft must be able to scale to a full size version in a manner that

can be sustained by the environment over a long term. Reliability: The craft must work reliably with minimal maintenance.

A pair wise comparison as seen in appendix 2 was completed to establish the following criteria weightings, which have been slightly adjusted as seen in figure 3.

Figure 3. Relative Criteria Weightings

The design options as summarized in table 8 where then scored on a scale from 1 - 5 in a decision matrix. This decision matrix and an explanation of the scoring scale can be seen in appendix 3 . The best options as decided by the decision matrix are shown in bold with all scores from the decision matrix shown below.

Table 8. Design Options

Propulsion System Fan: The main issue Paddle Wheel: The Propellers: Two

Page 14: 56871861 Final Report

Options is that a propeller above the water doesn’t provide as much power as below.

disadvantage of paddle wheels was due to the size requirement, as they would be mounted on the side of the craft.

underwater propellers to drive the craft were found to be the most effective.

Score 2.3 2.91 3.3

Hull Material Options

Pine: A pine hull was found to be not buoyant enough for the 5cm draft requirement.

Polystyrene: A polystyrene hull was not as sustainable as balsa wood.

Balsa Wood: The balsa wood hull was found to score the best on the decision matrix criteria.

Score 3.4 3.2 3.5

Sensor Options (Note: These options are all in addition to bump sensors which are very simple and inexpensive.)

Sonar: Sonar satisfied range requirements greater than the size of the tank, which is unnecessary, and more expensive

IR: An infrared distance sensor with a range of 10 -80cm was found to be the best due to its low cost.

IR and Compass: The IR and Compass option would result in the best performance but it would go far beyond the $50 budget.

Score 2.6 3.1 3.07

Battery Options Single 9V: A single 9V battery may result in errors due to motor feedback.

Single 7.2V: A Single 7.2V batter may result in errors due to motor feedback, the battery also costs much more than AAAs and 9Vs.

9V and 6V: The combination of a 9V and 6V battery was determined by the matrix to be the most effective due to low cost and long life.

Score 2.8 2.9 3.3

Control Algorithm Options

Spiral: A spiral algorithm to cover the whole surface

Random: A random algorithm was predicted to have

Page 15: 56871861 Final Report

area was determined to deliver the best performance.

lower performance as there is no guarantee that the whole area would be covered.

Score 3.1 2.7

Having assessed each design option it was decided that a balsa wood boat powered by a 9V and 6V battery with two propellers would use infrared and bump sensors to implement a spiral search pattern algorithm.

5.0 Final Design

5.1 Design OverviewThe boat features a catamaran hull design with two 6V motors powering propellers through gearboxes. The craft implements a spiral search pattern algorithm using infrared distance and tactile bump sensors. The design features are summarized in the table below:

Table 9. Summary of design features

Design Element Design Feature

Buoyancy Two L-shaped hulls made of balsa wood displace 6.8 x 10-4 m3 of water.

Propulsion Two 6V motors connected through gearboxes with a 12.7:1 gear ratio turn propellers of diameter 40mm.

Debris Collection and Storage

Debris is funneled through the front of the craft and collected in a floating rope net made from bubble wrap.

Artificial Intelligence

The craft uses a spiral algorithm to cover the entire tank, and turn when stuck.

Sensors The craft has a Sharp GP2D12 Analog Distance Sensor and two tactile bump Sensors

Microprocessor The craft uses an Arduino Uno with a 16Mhz microprocessor to read sensors and control actuators.

Battery Solution A 9V 300mAh battery is used to power the Arduino and four 1.5V 1000mAh batteries are used to power the motors.

Motors Each motor delivers 13200 rpm with a torque of 0.72mN, which

Page 16: 56871861 Final Report

is converted by the gearboxes to 1039 rpm with 9.2mN of torque.

5.2 Hull DesignThe craft uses a catamaran style hull. This design features two wide L-shaped hulls, connected via a flat deck on top.

The bottom section of each hull is 70mm wide at the widest point. However, the hull tapers down to 50mm in width at the front of the craft. This was done in order to work in conjunction with the funnel at the front of the craft. A 5mm gap in the inner corner of each hull was included to house the casing for the propellers. This was done to prevent any unwanted movement in the propeller shafts.

Wide hulls were chosen in order to increase stability as well as to ensure a relatively shallow draft. These hulls were spaced 60mm apart in order to allow ping-pong balls (diameter of 40mm) to travel through freely.

The craft’s weight force is 6.63N. The dimensions of the hull result in a draft of 25mm, which means the hull displaces 6.8 x 10-4 m3 of water, see calculations in appendix 6 . The centre of buoyancy, which is the point that the upward buoyant force acts through was determined to be 12.5mm above the bottom of the craft. While the centre of gravity is 69 mm above the bottom of the craft, see appendix 7 for stability calculations.

The upright component of each L-shaped hull is 40mm high, and 20mm wide. This means that the overall height of the hulls is 75mm, allowing a space of 50mm between the deck and the surface of the water. This spacing was included in order to allow ping pong balls to pass through freely and ensure all electronics remain dry.

These hulls were made out of balsa wood for optimal buoyancy and durability. To prevent these hulls from swelling due to contact with water, each hull was coated in Emerclad, a plastic paint. For further waterproofing, as well as to prevent splintering and breakage, the hulls were also covered in a layer cloth tape.

The deck, connecting these two hulls was made from a high density polyethylene. This material was chosen as it was waterproof, cheap, and strong even at a relatively small thickness. The deck is 2mm thick by 200mm wide by 200mm long. At the front of the craft, on either side, a cutout measuring 45mm in length and 25mm in width was made to house the gearboxes.

To fabricate the hull, a hacksaw was first used to cut the balsa wood to length. These pieces of balsa were then assembled using hot glue. To cut the deck material to size, a set of heavy duty scissors were used. Each pontoon was then positioned on the outer edge of the deck and connected using hot glue.

Page 17: 56871861 Final Report

5.3 Collection SystemThe collection system consists of a funnel and floating rope net. The funnel, situated at the front of the craft is composed of steel mesh (flyscreen). This material was chosen as it is cheap, malleable and holds its shape. Mesh was used in order to reduce drag in the water. This mesh is in two pieces, bent at an angle, connected to the underside of the deck with hot glue. The spacing between each piece spans 160mm at the front and 40mm at the back. This was designed to create a one way flow, it is easy for ping-pong balls to pass through, into the craft, but difficult for them to float back out. This means that if the craft has to stop or reverse, the collected balls will not be lost.

The floating rope net at the back is comprised of bubble wrap 460mm in length. Bubble wrap was chosen as it is cheap and buoyant. This buoyancy is desirable as it reduces the likelihood that the net will interfere with the propellers. The net is attached to the craft with cloth tape to allow for removal in case of damage.

The collection system involves balls being funnelled through the front of the craft, out to the rear of the craft. The balls are then contained by the floating rope to allow for collection after deployment. The use of the floating rope net theoretically provides a storage area of approximately 67388mm2 or 42 ping-pong balls.

5.4 Artificial Intelligence

5.4.1 Spiral AlgorithmThe watercraft uses a spiral search pattern in order to cover the entire surface area of the tank. This search pattern is achieved by controlling the motors such that the distance sensor’s reading approaches a certain variable, see software flowchart figure 4. This variable is then gradually increased. The complete code running the watercraft can be viewed in appendix 10.

The code used to determine the speed of the motors is as follows:

Lmotor = int(((float(-x)/maxcm)*(minmotor-maxmotor))+maxmotor);

Rmotor = int(((float(x)/maxcm)*(minmotor-maxmotor))+maxmotor);

Where:x is the difference between the distance sensor reading and the desired distance,maxmotor is the maximum motor speed which is 255,minmotor is the minimum motor speed,maxcm defines the x value in cm when the motor should first reach minimum speed.

Figure 4 graphically demonstrates these motor speeds and how they vary based on the distance sensor reading.

Page 18: 56871861 Final Report

Figure 4. Motor Speeds

The values of maxcm and minmotors were tested experimentally to find a value that limited oversteering which was the main problem with the algorithm while still allowing the craft to get back on track. The values of minmotor = 95 and maxcm = 20 where determined to be the most effective, these are the values used to generate the chart above.

5.4.2 Bump Sensor Input HandlingBump sensor input is handled by reversing with the left motor at 100% and the right motor at 50% for 8 seconds. It was found experimentally that 8 seconds is the time taken to turn 90 degrees, which is the desired turn when the boat is facing the wall.

5.4.3 Issue Detection by Analysis of Historical Sensor DataEarly testing indicated that it was possible for the craft to become stuck driving into a wall even if its bump sensors were operational. The causes of this include uneven surfaces, debris trapped between the craft and the wall and insufficient force to depress the bump sensors.

In order to avoid this, the last 20 distance sensor values are stored in an array which is updated every half second. If the last 20 values are all more than 20cm from the desired distance sensor reading the boat realizes that it is stuck. The boat then turns and continues to turn until the difference of successive distance sensor readings becomes positive. This means it will turn until it is just past parallel with the closest wall. It then resumes its spiral algorithm. See the If (runningStuck) { } code section in the full code listing in appendix 10 for the code used to perform this maneuver.

5.4.4 HardwareThe algorithm runs on an Arduino Uno, which is a microcontroller board. A microcontroller is a standalone integrated circuit including a simple CPU, clock, Input/Output ports and

Page 19: 56871861 Final Report

memory. The arduino Uno features a 16MHz microprocessor, 14 Digital I/O pins, 6 analog inputs, a USB connection and a power jack.

5.4.5 Sensor ElectronicsThe main sensor used by the watercraft is a Sharp GP2D12 Analog Distance Sensor. The sensor measures distances from 10 - 80cm. Since the sensor is analogue, its output voltage has to be converted into a distance by the software running on the Arduino board. In order to do this an expression for distance based on voltage must be found. A regression analysis of experimentally collected data points as seen in appendix 4 was used to find the following expression:

d = 26.58v-1.08

Where d is distance in cm and

v is voltage in volts.

The Sharp GP2D12 is comprised of an infrared emitter and sensor. The emitter sends a pulse of IR light, which bounces off the nearest object as seen in figure. The light then returns to the sensor where a lens focuses the light onto an array of CCDs (Charge-coupled devices), which are photoelectric devices used for sensing light. The angle of incidence is then determined based on which CCD detects the most light. The triangulation method then uses the angle of incidence to calculate the distance to the object. This method is effective as both object colour and ambient light have very little effect on the sensor’s performance. An electrical schematic including the sensor’s connection can be seen in figure 6.

The watercraft also uses two tactile bump sensors mounted on the front of the craft. These sensors are just switches, one pin is connected to the arduino 3V output and the other pin is wired to a digital input see figure 5. When the sensor is pressed this digital pin is raised to 3V, which the software registers as a high signal. The digitalRead(bumpPin) function is used to detect if the bump sensor is depressed.

Figure 5. Tactile Bump Switch

Figure 6. IR Distance Sensor

Page 20: 56871861 Final Report

5.5 Power SupplyThe watercraft is powered by two separate batteries as recommended by D Robotics (2011). A standard 9V 300mAh battery is connected to the Arduino UNO board. This battery delivers power to the Arduino, the sensors and the motor shield electronics but not the motors. A separate 6V battery pack consisting of four 1.5V 1000mAh AA cells was connected to the motor shield in order to power the motors. Table 10 outlines current requirements for different components of the craft.

Table 10. Current Requirements (See appendix 5 for calculations)

Predicted Actual Theoretical Operation Time

Actual Operating Time

Arudino and Sensors

100mA 80mA 3.75h > 2h

Motors 800mA 260mA 3.8h > 2h (Tested in 4x30 min sections)

As seen in the table above, the 9V battery will theoretically last for 3.7h and the 6V battery will last for 3.8h, see appendix 5 for calculations. The L298P motor shield is rated for a maximum of 35V, 2A and 35W (Little Bird Electronics, 2011). At 6V the motors consume 1.56W and 260mA, which easily fall within the shield’s requirements. The main battery has a charge capacity of 1000mAh. However, this is not the energy capacity of the battery, the energy capacity is 6Wh. This is found by multiplying the voltage by the charge capacity.

The reason for the separation of the motor battery and Arduino battery is because of the electrical noise that is characteristic of DC motors. This electrical noise results in an uneven voltage supply to the Arduino board, which could result in failure (D Robotics, 2011). Although the noise could be filtered using a capacitor, a different battery guarantees that the microcontroller receives a consistent 9V supply.

5.6 Propulsion SystemThe mechanical drive system is comprised of two motors connected to propellers via a gearbox and shaft. Each motor is connected directly into the gearbox, which has a gear ratio of 12.7:1. The output shaft of the gearbox is then connected with a small piece of rubber directly to the propeller shaft which runs through the casing down to the propeller, see figure . The output of each motor is 13200 rpm with a torque of 0.72mN. The gearbox then converts this rpm into torque by a factor of 12.7. The rpm becomes 1039rpm with 9.2mN of torque. Theoretically speaking the propellers should run at these speeds although friction

Page 21: 56871861 Final Report

somewhat reduce the speed in practice. The relationship between torque and current can be loosely modeled by:

= k I1.5

Where is torque in N,

k is a constant dependant on the motor, and

I is current in Amps.

(Johns, 2003)

For our given motor, k = 5.4 x 10-3. Figure 7 shows this relationship between torque and current.

Figure 7. Torque vs Current

Page 22: 56871861 Final Report

6.0 Design Drawings

6.1 Hull Design

Page 23: 56871861 Final Report

6.2 Propulsion System

Page 24: 56871861 Final Report

6.3 Electrical Schematic

Page 25: 56871861 Final Report

6.4 Software Flow Chart

Page 26: 56871861 Final Report

6.0 FMEASee Appendix 1 for full FMEA analysis.

The biggest risks for this project are related to the electrical system of the craft. The failure mode with the greatest risk is contact between the electrical components and water, due to inadequate waterproofing. This could result in sparks, causing either burns or fire, shock, and of course, the craft no longer functioning correctly. To reduce the risk of these occurring, adequate waterproofing it required. In particular, the arduino and batteries should be placed in a watertight container. The wiring from this container leading to the sensors and motors should also be waterproofed, namely by running the wiring through waterproof tubing. It is also recommended that this waterproofing be thoroughly checked and also tested before use, to further ensure that water is kept out. This waterproofing should be regularly checked for any damage.

Automated Watercraft

Propulsion

Software

Navigation

Light Sensor

Bump Sensor

Hull Electrical System

Motors Propellers

Page 27: 56871861 Final Report

7.0 Life Cycle Assessment

7.1 Goal Definition and Scope

In the design process, the overall environmental impact of the design must be taken into account. This analysis will focus on energy requirements for the materials.

7.2 Inventory Analysis

Cut to specified dimensions

Balsa wood is grown in South America and treated

Deployment

Disposal

Transported to Australia

HDPE is manufactured at plant, locally

Fashioned into sheets

Cut to specified dimensions

Craft Construction

Arduino Board is manufactured in Italy

Transported to Australia

Sharp GP2D12 Light Sensor manufactured in China

Transported to Australia

Storage

All other mechanical parts made in China

Transported to Australia

Recycling of parts

Page 28: 56871861 Final Report

Volume of balsa used = 1242000 = 1.242x

0.2kg of balsa usedEmbodied Energy Balsa = 2MJ/kg Embodied Energy in Balsa used = 4MJ

Volume of HDPE used

Embodied Energy HDPE

Embodied Energy in HDPE used

31.32kJ in the batteries on small scaleTherefore in batteries on large scale

Approximately 50 times as much embodied energy in an alkaline battery as it contains. Embodied energy in batteries = 31.32MJ

7.3 Impact AssessmentBalsa wood is quite environmentally friendly as it a natural resource that can be recycled easily, meaning it will have a low impact on the environment. However, it is coated in a layer of Emer-Clad paint which is not as friendly, as it is a plastic paint that can be hazardous to aquatic life, with long lasting effects. It also significantly reduces the recyclability of the material.

Being a plastic, High-Density Polyethylene has a significant environmental impact. Large amounts of chemical pollutants are emitted during the creation of plastic, as well as large amounts of fossil fuels.

Batteries have the potential to be the most environmentally damaging aspect of the craft. Disposable Alkaline batteries have a greater impact than rechargeables. Most of the environmental impact of disposable batteries is brought about by the initial manufacture and transport of the batteries.

7.4 Improvement Assessment/InterpretationThe craft has plenty of room for improvement in terms of environmental impact. Although the majority of the craft is comprised of environmentally friendly balsa wood, this is coated in Emer-Clad paint. To improve environmental impact, this method of waterproofing could be replaced with a more sustainable method. The deck made of HDPE is also an environmental hazard. It could easily be replaced a thicker sheet of balsa wood, which would also save weight.

Page 29: 56871861 Final Report

8.0 RecommendationsIn order to implement the automated watercraft design a number of improvements must be made. Firstly, the sustainability must be improved to ensure maximum life and minimum environmental impact of the design. Secondly, the design needs to be scaled in order to suit the real life problem of collecting debris rather than ping pong balls.

9.0 BibliographyCarey, D, 2006, ‘Roomba sweeps low-cost parts’, Electronic Engineering Times, vol.14, pp. 54.

Collins, C, 2007, ‘LawnBott’, Christian Science Monitor, vol. 99, no. 184, pp. 12.

Cravotta, R, 2007, ‘Rummage through a Roomba’, EDN, vol. 52, pp. 32.

Franklin F, Muir P, Scott T, Wilcocks L, Yates P 2010, Introduction to Biological Physics for the Health and Life Sciences, John Wiley Sons and Limited Publications, New Zealand

Kakazu Y, Sato T, Wada M 1998, Intelligent Autonomous Systems: IAS-5, IOS Press

Murray, C, 2006, ‘Mowing on Autopilot’, Design News, vol. 61, no. 9, pp. 37.

Thrun, S, Fox, D, Burgard, W, & Dellaert, F, 2001, ‘Robust Monte Carlo Localization for Mobile

Robots’, Artificial Intelligence, vol. 5, pp. 10.

Tribelhorn, B, 2007, ‘Evaluating the Roomba: A low-cost, ubiquitous platform for robotics

research and education’, Robotics and Automation, vol. 1, pp. 139.

Ulanoff, L, 2006, ‘Scooba Mops and Almost Shines’, PC Magazine, vol. 25, pp. 48.

University of Queensland (UQ) 2011, ENGG1000 Introduction to Professional Engineering, 2011, Project Design Brief: Automated Water Craft, The University of Queensland

White, M 1999, Properties of Materials, Oxford University Press, New York.

AFP, 2010, ‘BP oil spill bill tops $8 billion’, ABC News, 3 July, accessed 16 March 2011, <http://www.abc.net.au/news/stories/2010/09/03/3002265.htm>.

Arduino 2011, ArduinoBoardUno, accessed 20/3/11 http://arduino.cc/en/Main/ArduinoBoardUno

Author Unknown 2009, Types of Hulls, accessed 15/3/2011, <http://www.boatingbasicsonline.com/content/general/3_5.php>.

Page 30: 56871861 Final Report

Author Unknown 2009, OIL SPILL RECOVERY VESSELS, HARBOUR CLEAN AND WATER WEED CLEARANCE VESSELS, accessed 17/3/2011, <http://pacificworkboats.com/oilspillrecoveryvessels.html>.

Author Unknown 2009, Water Witch, accessed 12/3/2011, <http://waterwitch.com/waterwitch>.

Author Unknown 2010, Matbase, accessed 17/3/11, <http://www.matbase.com/material/wood/class2-15-25-years/european-oak/properties>.

Benedict S, Bennett M, Cardoza MA, Hughes C, Mayoral A, Tucker D 2005, Autonomous Surface Watercraft, FreePatentsOnline, accessed 18/3/11 <http://www.freepatentsonline.com/6854406.pdf>

Bergin, T, 2010, ‘BP oil spill costs hit $US8bn’, Business Spectator, 3 July 2011, accessed

18/3/11, <http://www.businessspectator.com.au/bs.nsf/Article/UPDATE-2-BP-oil-spill-costs-

hit-8-bln-as-ends-rig>.

Cardarelli, M 2008, Materials Handbook A Concise Desktop Reference, Second Edition edn, Springer-Verlag London Limited, London.

CARROLL, Bradley W. 2004. Archimede's Principles. [online]. [Accessed 27 March 2011]. Available from World Wide Web: < HYPERLINK "http://physics.weber.edu/carroll/archimedes/principle.htm" http://physics.weber.edu/carroll/archimedes/principle.htm >

Croswaite, P 2011, Project 2 Design Brief: Automated Water Craft, Brisbane

Deniz, M 2006, MINI CAT DEBRIS & TRASH & GARBAGE RECOVERY VESSEL, accessed 12/3/2011, <http://www.mavideniz.com.tr/product/Debris_Recovery_Vessel/Mini_Cat/Mini_Cat.html>.

Disk Type Oil Skimmers, 2010, Zebra Skimmers Corp, accessed 20 March 2011,

<http://www.zebraskimmers.com/oil_skimmer_products/disk_tramp_oil_skimmers.html>.

Energizer 2010, Energizer E91 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/E91.pdf>

Energizer 2010, Energizer A23 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/a23.pdf>

Energizer 2010, Energizer E93 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/e93.pdf>

Energizer 2010, Energizer E95 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/e95.pdf>

Page 31: 56871861 Final Report

Energizer 2010, Energizer 528 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/528.pdf>

Energizer 2010, Energizer 522 Datasheet, accessed 22/3/11 <http://data.energizer.com/PDFs/522.pdf>

Eveready Battery Co., Energizer 522 Engineering Datasheet, accessed 22/3/11 <http://www.batterystore.com/Eveready/EvereadyPDF/522.pdf>

Fitzgerald, M, Phelps, D & Robinson, K 2002, 'Hydrodynamics and boat hull design', Tech Directions, vol. 61, no. 9, p. 23.

Godfrey, M, 2011, ‘Minehunter begins clearing flood debris in Brisbane River’, News.com.au,

18 January 2011, accessed 15 March 2011,

<http://www.news.com.au/breaking-news/minehunter-begins-clearing-flood-debris-in-

brisbane-river/story-e6frfku0-1225990232843>.

Hoff, L 2010, Basic Hull Shapes Offer Distinct Advantages And Disadvantages, accessed 15/3/2011, <http://madmariner.com/tip/050608>

iRobot, 2011,The Vacuum Cleaning & Floor Washing Robots, iRobot, accessed 20 March

2011, <http://www.roomba.com.au/>.

Judd A 2010, Oil Spill Gulf of Mexico 2010, NowPublic, accessed 20/3/11 <http://www.nowpublic.com/environment/oil-spill-gulf-mexico-2010-wildlife-and-fish-risk-2612183.html>

Kasten, M 2010, Strength of Aluminum vs Strength of Steel, accessed 15/3/2011, <http://www.kastenmarine.com/alumVSsteel.htm>.

Little Bird Electronics 2011a, Arduino Uno, accessed 19/3/11 <http://littlebirdelectronics.com/products/arduino-uno>

Little Bird Electronics 2011b, Brushed DC Motor: 130-Size, 6V, 11.5kRPM, 800mA Stall, accessed 19/3/11 <http://littlebirdelectronics.com/products/brushed-dc-motor-130-size-6v-115krpm-800ma-stall>

Little Bird Electronics 2011c, L298 Motor Shield (Arduino-compatible), accessed 19/3/11 <http://littlebirdelectronics.com/products/l298-motor-shield-arduinocompatible>

Little Bird Electronics 2011d, Snap-Action Switch with 15.6mm Bump Lever: 3-Pin, SPDT, 5A, accessed 19/3/11 <http://littlebirdelectronics.com/products/snap-action-switch-with-156mm-bump-lever-3-pin-spdt-5a>

Little Bird Electronics 2011e, Tamiya 70167 Single Gearbox (4-Speed) Kit, accessed 19/3/11 <http://littlebirdelectronics.com/products/tamiya-70167-single-gearbox-4-speed-kit>

Page 32: 56871861 Final Report

Marcus E Dr 2011, One Year Later: The Health Effects of the BP Oil Spill, New American Media, accessed 20/3/11 <http://newamericamedia.org/2011/03/one-year-later-the-health-effects-of-the-bp-oil-spill.php>

McNamara M 2011, Queensland Floods and Cyclone Yasi Could Cost Australia USD $10 Billion, White Digital Media Group, accessed 20/3/11 <http://www.businessreviewaustralia.com/tags/australian-economy/queensland-floods-and-cyclone-yasi-could-cost-australia-usd10-billion>

Naval-Technology, 2009, Huon Class Minehunter, Naval-Technology, accessed 20 March

2011, <www.naval-technology.com/projects/huon/>.

Salvation Army 2011, Overview of Salvation Army Support- Queensland Flood Crisis, accessed 20/3/11 <http://salvos.org.au/about-us/news-and-resources/documents/WEBOVERVIEWASAT14.1.11-LONGVERSION_000.pdf>

Skimmers, 2011, Encyclopedia of Earth, accessed 23/3/11,

<http://www.eoearth.org/article/Skimmers?topic=50359>.

Trollip, R 2010, Boat Hull, accessed 12/3/2011, <http://www.psychosnail.com/InfoBoatHull.aspx>.

Trotman A 2011, BP Chief Bob Dudley Apologises for Gulf of Mexico Oil Spill, Telegraph Media Group Ltd, accessed 20/3/11 <http://www.telegraph.co.uk/finance/newsbysector/energy/oilandgas/8370358/BP-chief-Bob-Dudley-apologises-for-Gulf-of-Mexico-oil-spill.html>

United Marine International, 2009, TrashCat, accessed

20/3/11,<http://www.trashskimmer.com/>.

Wildlife Queensland 2011, Environmental Impact of Floods, accessed 20/3/11

Wesch, K 2011, The Pros and Cons of Catamarans, accessed 15/3/2011, <http://worldwisetravelresources.blogcashbiz.com/11277/the-pros-and-cons-of-catamarans/>.

Zidock, A 2011, Boat Hull DESIGN, accessed 17/3/2011, <http://www.fish.state.pa.us/anglerboater/1999/julaug99/boathull.htm>.

Zidock, A 2011, Hull Shapes, accessed 17/3/2011,<http://www.fish.state.pa.us/anglerboater/1999/julaug99/boathull.htm>.

Page 33: 56871861 Final Report

Appendix 1

FMEA Table

Page 34: 56871861 Final Report
Page 35: 56871861 Final Report
Page 36: 56871861 Final Report

Appendix 2

Pair Wise Comparison

Page 37: 56871861 Final Report

Appendix 3

Decision Making Matrix

Page 38: 56871861 Final Report

Appendix 4

Distance Sensor Calibration

Page 39: 56871861 Final Report

Appendix 5

Battery CalculationsBattery Calculations

Solve for the power from the Voltage and Current.

P = VI

P = 6 * .26

P = 1.56W

Solve for the energy capacity from the charge Capacity

Energy Capacity = V * charge Capacity

Energy Capacity = 6V * 1Ah

Energy Capacity = 6Wh

Solve for the theoretical battery life

Battery Life = Charge Capacity / Current

Battery Life = Ah / A

In the 9V battery:

Battery Life = .3 / .08

Battery Life = 3.75h

In the 6V battery:

Battery Life = 1 / .26

Battery Life = 3.846h

Battery Life 3.8h

Page 40: 56871861 Final Report

Appendix 6

Buoyancy CalculationsTotal weight of water craft = 676N

Density of craft ≈ 170kg/m3

(CARROLL, Bradley W, 2004)

According Archimede’s Principle and the previous calculation, the volume of displaced fluid is equal

to the submerged volume of the object which means of the craft which will be

submerged. Assuming the craft is constructed to the above dimensions, the water will sit at 14.5mm above the bottom of each hull.

Page 41: 56871861 Final Report

Appendix 7

Stability CalculationsDetermining the height of centre of gravity.

Density of balsa x Height of centre of gravity x volume of hull = (35/2)*(20*180*35*Density of balsa) + 35/2*(30*200*35*Density of balsa)) + 70/2*(75*20*200*Density of balsa) – (15/2+20)*(5*15*200*Density of balsa)

Density of balsa x Height of centre of gravity x 621000 = (2205000 + 3675000 + 10500000 – 412500) x density of balsa

Height of centre of gravity x 621000 = 15967500

Height of centre of gravity = 25.71mm = 25mm

Weight of components above deck = 396g

Height of centre of gravity x 676g = 2 x [(35/2)*(20*180*35*Density of balsa) + (35/2)*(30*200*35*Density of balsa)) + (75/2)*(75*20*200*Density of balsa) – (15/2+20)*(5*15*200*Density of balsa)] + (76)*(2*200*200*Density of HDPE) + 396g*90

= 2*16717500*Density of Balsa + 6080000*Density of HDPE + 41040

= 5356 + 6080 + 35640

=47076g*mm

Therefore height of centre of gravity = 69mm

Density of balsa = 1.6x10^-4 g / (mm^3)

Density of HDPE = 1x10^-3g/mm^3

Assume that the height centre of gravity for the components above the deck is 90mm from the base of the craft. (13mm above the top of the deck)

Centre of buoyancy

Height of centre of buoyancy = Half of draft = 25/2 = 12.5mm

Page 42: 56871861 Final Report

Appendix 8

Drag CalculationsDrag=.5*S*v^2*p*Cd

v = 0.12m/s

p = 1000kg/m^3

For the hull:

S = 0.0048m^2

Cd = 1.28 (Benson, 2010)

For the net:

S = 0.0015m^2

Cd = 0.96 (Benson, 2010)

Total Drag = .5*.0048*v^2*1000*1.28+.5*.0015*v^2*1000*.96

= 500v^2(.0048*1.28+.0015*.96)

= 500v^2(.006144+.00144)

= 500*.12^2(.007584)

= 54.6 mN

Page 43: 56871861 Final Report

Appendix 9

Software Calculations

Table 10: Data Sample RatesSensor or Variable Max

Sample Rate (Hz)

Required Sample Rate (Hz)

Data Type Storage Space Used per sample

Storage Space Used per second

(Bytes/sec)

Snap-Action Switch with 15.6mm Bump Lever: 3-Pin, SPDT, 5

- 16 Boolean 1 Bit 2

Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150c

- 1 Unsigned Int

2 Bytes 2

Left Motor Speed Percentage

- 1 Byte 1 Byte 1

Right Motor Speed Percentage

- 1 Byte 1 Byte 1

Total 6

(Max Sample Rate from Littlebird Electronics, 2011)

Program size is 4kB Arduino UNO Microcontroller Board includes:

o 1kB EEPROMo 32kB Program Flash

1kB = 1000B (Not 1024B)

Total Available Storage Space = S = 1kB + 32kB – 4kB = 29kB

Rate = R = Σ (Bump Sensor + Distance Sensor + Left Motor + Right Motor)= Σ (2 + 2 + 1 + 1)= 6 B/s

Run Time = S/R= 29000B/6B/s= 4833s= 80.55 mins

Page 44: 56871861 Final Report

Appendix 10

Complete Arduino Codeint E1 = 6;int M1 = 7;int E2 = 5;int M2 = 4; int IRpin = 1; // Distance Sensor Pinint inPinL = 2; // Left bump Pinint inPinR = 3; // Right bump pinint Lmotor; // Variable for Left motor speedint Rmotor; // Variable for right motor speedint boatWidth = 10; // Distance from sensor to side of boatint L; // Desired distance from the side of the poolint x;int maxcm = 25;int minmotor = 120;int maxmotor = 255;unsigned long lastRecTime = 0;int distRecords[20];int lastChange;unsigned long lastStickTime = 0;boolean runningStuck = LOW;

void setup() { pinMode(M1, OUTPUT); pinMode(M2, OUTPUT); pinMode(inPinL, INPUT); digitalWrite(inPinL, HIGH); pinMode(inPinR, INPUT); digitalWrite(inPinR, HIGH); Serial.begin(9600); }

void loop() { if (millis() < 120000) { L = round(millis()*70/120000); } else if ((millis() > 120000) && (millis() < 240000)) { L = round(70-((millis()-120000)*70/120000)); } else if (millis() > 240000) { L = 2; } float dist = distance(); dist = dist - boatWidth; x = dist-L;

Page 45: 56871861 Final Report

record(x); if (runningStuck) { if ((distRecords[(lastChange+21) % 20] < distRecords[lastChange]) && (distRecords[(lastChange+22) % 20] < distRecords[(lastChange+21) % 20])) { runningStuck = LOW; fullSpeed(); } if ((millis()-lastStickTime) > 12000) { runningStuck = LOW; fullSpeed(); } } else { bump(); spiralSpeeds(x); }}

void spiralSpeeds(int x) { if (x < (-1*maxcm)) { x = -maxcm; } if (x > maxcm) { x = maxcm; } Lmotor = int(((float(-1*x)/maxcm)*(minmotor-maxmotor))+maxmotor); Rmotor = int(((float(x)/maxcm)*(minmotor-maxmotor))+maxmotor); if (Lmotor > 255) { Lmotor = 255; } if (Rmotor > 255) { Rmotor = 255; } digitalWrite(M1,LOW); digitalWrite(M2,HIGH); analogWrite(E1, Rmotor); // set motors to this value analogWrite(E2, Lmotor); // set motors to this value }

Page 46: 56871861 Final Report

float distance() { float volts = analogRead(IRpin)*0.0048828125; // change to volts float distance = 26.58*pow(volts, -1.08); // get distance in cm from volts return distance;}

void bump() { if ((digitalRead(inPinL) == LOW) || (digitalRead(inPinR)) == LOW) { if ((digitalRead(inPinL) == LOW) || (digitalRead(inPinR)) == LOW) { bumpReverse(); } } }

void record(int x) { if ((millis()-lastRecTime) > 500) { lastChange = (lastChange+1) % 20; distRecords[lastChange] = x; //Serial.println(x); lastRecTime = millis(); stuck(); } }

void stuck() { boolean stuck = HIGH; for(int i = 0;i < 20; i++) { int temp = distRecords[(lastChange+i) % 20]; if ((temp < maxcm) && (temp > -maxcm)) { stuck = LOW; } } if ((stuck) && ((millis()-lastStickTime) > 30000)) { lastStickTime = millis(); stuckReverse(); }}

void bumpReverse () { digitalWrite(M2, LOW); // reverse motor 1 analogWrite(E1, 150); // slow down motor 1 analogWrite(E2, 255); // slow down motor 2 delay(8000); // certain time seconds fullSpeed();}

Page 47: 56871861 Final Report

void stuckReverse () { runningStuck = HIGH; digitalWrite(M2, LOW); // reverse motor 1 analogWrite(E1, 150); // slow down motor 1 analogWrite(E2, 255); // slow down motor 2 delay(4000); // certain time seconds }

void fullSpeed () { digitalWrite(M1, LOW); // forward digitalWrite(M2, HIGH); // forward analogWrite(E1, 255); // back to full speed ahead analogWrite(E2, 255); // back to full speed ahead}

QuickTime™ and a decompressor

are needed to see this picture.