cu sail navigation team spring 2016 semester report...comprises of a global positioning system...

29
CU SAIL Navigation Team Spring 2016 Semester Report Professor Andy Ruina’s Biorobotics and Locomotion Lab Cornell University Stephanie Hogan, Alex Pomerenk, Alec Dean, Arjan Singh May 13, 2016

Upload: others

Post on 19-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

CU SAIL

Navigation Team

Spring 2016 Semester Report

Professor Andy Ruina’s Biorobotics and Locomotion LabCornell University

Stephanie Hogan, Alex Pomerenk, Alec Dean, Arjan Singh

May 13, 2016

Page 2: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Abstract

The team’s goal for this semester was to develop a navigation sys-tem that would allow our boat to autonomously sail from one pair ofco-ordinates to another. A combination of an electrical array of sensorsand a short term navigation algorithm determine appropriate sailing ma-neuvers for our sailboat to reach its desired destination. The sensor arraycomprises of a Global Positioning System sensor, an Inertial MeasurementUnit and a magnetic Rotary Sensor, which allow the navigation algorithmto access wind direction, current position and boat orientation. The sail-ing maneuvers thus determined by the navigation algorithm are executedby a control system consisting of servo motors, that rotate the sail andtail to appropriate angles. Feedback is provided by a short-distance radiocommunication system as well as visible LED lights. A microcontrollerallows for communication between the sensor array, the navigation al-gorithm, the control system and the feedback system. In addition, themicrocontroller also handles scheduling tasks. The navigation system ispowered by a rechargeable 6V, 330 amp hr, NiMH battery pack. Powerfrom the battery is directly supplied to the control system and the micro-controller. The microcontroller in turn, supplies power to the sensor arrayand the feedback system. The Navigation algorithm operates by first, de-termining the waypoint to sail to and then finding the optimal headingto sail in, in order to reach that waypoint. Then, by taking into accountdata given by the sensor array, the algorithm determines appropriate sail-ing maneuvers (like tacking and jibing) and, outputs sail and tail anglesthat would execute those maneuvers. The navigation system was testedusing a MATLAB simulation and on the Engineering Quad with success;our system obtained accurate data from the environment and set correctsail and tail angles to execute the optimal maneuver for various scenarios.With that said, without further testing on water, the functionality of thepresent navigation system is still to be fully verified.

Page 3: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Contents

1 Overview 4

2 Microcontroller and Sensors 42.1 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Magnetic Rotary Sensor . . . . . . . . . . . . . . . . . . . . . . . 62.3 Inertial Measurement Unit . . . . . . . . . . . . . . . . . . . . . . 72.4 GPS Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.5 Servo Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 Communication System 8

4 Manual Remote Control 8

5 Power System 9

6 Electrical Organization of Navigation System 10

7 Navigation Algorithm 127.1 Selecting a waypoint and getting from latitude-longitude to dis-

tance (in meters) coordinate system . . . . . . . . . . . . . . . . 127.2 Finding a heading . . . . . . . . . . . . . . . . . . . . . . . . . . 137.3 Choosing a Maneuver . . . . . . . . . . . . . . . . . . . . . . . . 157.4 Output sail and tail angles . . . . . . . . . . . . . . . . . . . . . . 187.5 Jibing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197.6 Optimal Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 207.7 Buoy Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

8 Testing 258.1 Testing through simulations . . . . . . . . . . . . . . . . . . . . . 258.2 Testing on land . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258.3 Testing on water . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

9 Future Work 26

10 Appendix 2710.1 Appendix A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2710.2 Appendix B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Page 4: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

1 Overview

Our sailboat must be able to sail to a designated set of coordinates by takinginto account its present latitude and longitude, perceived wind direction, theboat heading, and the boat direction. The boat heading refers to the directionthe nose of the boat points to, with respect to true North, while the boat head-ing refers to the direction the boat is moving, also with respect to true North.A sailboat generally does not move in the direction that its nose points, whichmakes this distinction between heading and direction important. We approachthe task in three parts; 1) Acquisition of data relevant for navigation; 2) Usingthe acquired data to determine appropriate sailing maneuvers; and 3) Executingthe sailing maneuvers.

The first part of the process is achieved by a set of sensors that gather data(wind direction, coordinates, boat heading and boat direction). The second partis done via an algorithm which uses sensor data to determine the next directionof the boat, and the relevant sailing maneuver to sail, in that direction. The finalpart is accomplished by a set of servo motors (see section 2.5). A microcontroller(see section 2.1) acts as a bridge between the three parts and allows the flow ofdata from the sensors, to the algorithm and finally to the servo motors (servos).

2 Microcontroller and Sensors

2.1 Microcontroller

The microcontroller handles scheduling tasks, determining how often the sensorsmust activate and collect data, a new heading must be calculated, a new maneu-ver needs to be executed to stay on course and communication must be made.We are currently using the Arduino Due as the sailboat’s micro-controller. Theprocessor core of the Due is made by Atmel (Atmel SAM3X8E), and runs at84 MHz. This microcontroller has enough ports and pins to accommodate ourcurrent sensor array, and even additions we might make in the future. The highclock speed of the processor also allows us to stay clear of potential bottlenecksin terms of the frequency at which we might want to run the navigation al-gorithm. The processor communicates with the sensor array through variouscommunication protocols that vary between devices. The following protocolsare used by our navigation system:

1. Serial Communication. Communication between two devices is considered“serial” when data is transferred one bit at a time. This serial communi-cation can be aided by a clock signal (a constant sequence of alternating1’s and 0’s) generated by the processor. In such a case, data will onlybe transferred when the clock signal changes from 0 to 1 (rising edge)or when the clock signal changes from 1 to 0 (falling edge). This serialprotocol is considered synchronous. In the case where the clock is notused, the serial protocol is considered asynchronous. A commonly used

4

Page 5: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

asynchronous serial communication protocol (which the Arduino Due alsouses), is known simply as “Serial Communication.” This communicationprotocol uses two channels for communication between devices: one toreceive data (RX) and one to transfer data (TX). The connection betweentwo devices is made as shown in Figure 1. The RX port of one deviceconnects to the TX port of the other device. The Arduino Due has fourserial ports labeled Serial 0, Serial 1, Serial 2 and Serial 3. By default, theArduino uses Serial 0 to communicate with the user’s personal computer(PC). Serial 0 is used to print statements on the screen and also to uploadprogram(s) to the microcontroller.

Figure 1: Connection of devices through the Serial communication channel(source: sparkfun.com)

2. Serial Peripheral Interface or SPI, is an example of Synchronous SerialCommunication. Bits (1 or 0) are transferred one at a time through des-ignated Transfer and Receive channels. Because this communication issynchronous, the transfer of bits is synchronized with the clock signal pro-duced by the Arduino. This requires one more channel of communicationbetween the devices- The clock signal. Furthermore, in SPI protocol, it ispossible for multiple devices to use the same clock, transfer, and receivechannels. The restriction, however, is that in the case of our processor,only one device can use the channels at any given moment. This gives riseto a fourth channel, called the chip select or slave select. The device withan active chip select signal from the Arduino will be allowed to use theSPI protocol of the microcontroller. Once that chip select signal becomesinactive, the device can no longer use the SPI protocol. The transferand receive channels are referred to as MOSI (Master Out Slave In) andMISO (Master In Slave Out). In our case, the Master is the Arduino Due,and the Slave is the sensor communicating with the Arduino Due. Theclock channel is the CLK or SCK channel, and the chip select channel isabbreviated to CSn or SS.

3. Pulse Width Modulation or PWM, is a timed digital signal. A digital signalis one that is either low (0) or high (1). A PWM signal is one where theduration for which a digital signal is high (or low) is measured to producea duty cycle. The percentage of time a signal is high in a period of timecompared to the period is called the signal’s duty cycle. For example,if the signal is high for half the period of time, the duty cycle is 50%(see Figure 2). At a high enough frequency ( 100 Hz), changing the dutycycle of a signal can result in analog values (values across a range; not

5

Page 6: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

just ”high” or ”low”) obtained from the digital signal. PWM is used tocontrol the position of the Servo motors 2.5.

Figure 2: Different duty cycle examples (source: sparkfun.com)

2.2 Magnetic Rotary Sensor

A rotary sensor is a device that allows the measurement of the angular positionof a shaft. Our magnetic sensor does this task by measuring the orientationof the magnetic field of a permanent magnet which is mounted underneath theshaft, whose angular position is to be determined. Figure 3 below demonstratesthe position of the sensor relative to the magnet. We need this sensor to obtainthe wind direction with respect to the boat direction. A magnet is attachedto the bottom of the shaft of a wind vane, below which sits the rotary sensor.As the wind vane rotates due to the wind, the magnet underneath moves. Theassociated change in magnetic field is detected by the rotary sensor, whichoutputs an angular position. The Magnetic Rotary Sensor uses the SPI protocolfor communication, which requires a 4-channel connection to the microcontrollerin addition to power, as described in section 2.1.

Figure 3: Structure of a magnetic rotary sensor unit after installation, dis-playing the sensor(bottom), the shaft and a cylindrical magnet. (source: ma-chinedesign.com)

6

Page 7: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

2.3 Inertial Measurement Unit

The inertial measurement unit, or IMU, allows measurement of the orientationof the boat, in terms of the roll, pitch and yaw see figure 4. It does this using acombination of 3 sensors: a gyroscope, a magnetometer and an accelerometer.A gyroscope measures the rate of change of the three angles. A magnetometermeasures the direction of the earth’s magnetic field relative to the boat. Thisallows for two things: determining the boat heading with respect to North,and determining wind direction with respect to North. In the previous sectionabout the Magnetic Rotary Sensor, I mentioned that the sensor determines winddirection with respect to the boat direction. Knowing the boat direction withrespect to North allows us to obtain wind direction with respect to true North.Lastly, the accelerometer measures the acceleration due to the forces on it. Inthe case of our boat, this means detecting the direction of Earth’s gravitationalforce relative to the boat. In other words, it detects which way is “down”,with respect to the boat, measuring the tip of the boat. With a combinationof these three outputs from the 3 sensors, and an on-board processor, an IMUdetermines the roll, pitch and yaw i.e. the orientation, of the boat. The IMUalso uses the SPI protocol. It can thus, share the MOSI, MISO and CLK (seesection 2.1) with the Rotary Sensor, but requires a different chip select channelfor successful communication with the Arduino Due.

Figure 4: The roll, pitch and yaw angles (source: boatsafe.com)

2.4 GPS Sensor

A global positioning system sensor, or GPS Sensor, is a sensor that, throughconnection with GPS satellites provides latitude, longitude, time, heading andspeed. The GPS uses Serial communication to communicate with the microcon-troller. The RX port of the GPS connects to the TX port of the Serial channelon the microcontroller, and the TX port of the GPS connects to the RX portof the same Serial channel on the microcontroller (see section 2.1).

7

Page 8: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

2.5 Servo Motors

A servo motor or a servo, is a device that is a combination of a motor andan angular position sensor (the magnetic rotary sensor is an example of sucha sensor). The motor allows a shaft to rotate as required, while the positionsensor keeps track of the position of the shaft. Such sensing allows us to movethe shaft to designated angles. Two servos are used on the boat - one for thesail and the other for the tail. Each of the servos have signal channels to PWMpins 2.1 on the microcontroller.

The three sensors above (magnetic rotary sensor, IMU, GPS) allow the mi-crocontroller to obtain the necessary data required to successfully implementour navigation algorithm, which then assigns the sail and tail to be set to therequired angles. The servo motors then use that output from the algorithm toset the sail and tail accordingly.

3 Communication System

Our sailboat achieves short distance communication through small radio mod-ules manufactured by Digi Internationa. These Xbee-Pro S3B modules allow forwireless communication between the microcontroller and a personal computer(PC). An Xbee module can transmit, in a Serial manner (see section 2.1), datato a linked Xbee module. One of these modules is connected to a Serial channelof the Arduino Due (Serial1), while the other is connected via USB (which alsouses a form of serial protocol), to a PC. The Xbee modules thus channel datafrom the Arduino Due to the user’s computer. These modules can communicatewith each other up to a range of 28km (using a dipole antenna) according totheir specifications. Even though real world scenarios will not result in sucha range, the range of up to 10km is satisfactory for our current purposes ofshort-course, short-term navigation.

4 Manual Remote Control

A remote control (RC) system system helped us understand the sailboat’sdirectionally-stable sailing capabilities. Understanding the sailboats behaviouron the water before allowing the navigation algorithm to take over, was impor-tant due to the fact that the algorithm was developed purely on the basis ofcomputer simulations and land testing (see section 8); the sailboat’s real worldsailing capabilities had to be determined. The remote control system was alsodeveloped as a fail safe to bring the boat back to shore in case the navigationalgorithm makes the boat malfunction.

The circuit for the RC involves the use of a multiplexer. A multiplexeris a device that has multiple inputs and one output. The device selects oneof the inputs to pass through and become the output depending on the state

8

Page 9: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

of a digital ”select” signal. In our case, the multiplexer has two inputs; oneinput is the remote control, while the other is the microcontroller. The digital”select” signal is controlled by a switch on the transmitter. The overview of thesystem can be seen in figure 5. On receiving power, the multiplexer defaults tooutputting the signal from the remote control, which means that unless the RCfunctions, the boat will not run. This acts as an effective safeguard that ensuresthe boat is never completely out of our control.

Figure 5: Schematic of current RC system of the sailboat

5 Power System

The different components of the navigation system have different optimal inputvoltage requirements. The Arduino Due requires an input voltage in the rangeof 6-16 V. This input voltage is then regulated down to the operating voltageof the processor, 3.3 V, by the microcontroller circuit board. The three sensorswere chosen such that they do not operate at a voltage higher than the oper-ating voltage of the microcontroller. The IMU, GPS Sensor and the RotarySensor require 3.3V for their operation. This 3.3V can be provided directly bythe microcontroller through one of its power-output pins. The servo motorsrequire an input voltage of 4.8-6 V. Strictly looking at these voltage limits, theservo motors can be powered by the microcontroller, however, in certain loadconditions it is possible for the servos to require higher current ( 800 mA),than the microcontroller pins can provide ( 700mA). With these requirementsin mind, the following system has been put in place: An external 6V batterypowers the microcontroller and the servo motors, while the microcontroller inturn provides the required 3.3V for the IMU, GPS and Rotary Sensor. Refer toFigure 6 for a schematic of the power system. It is important to remember thatbecause the servos receive their respective signals from the microcontroller, butare powered by an external battery, the reference ground voltages (GND) of themicrocontroller and the battery must be connected.

9

Page 10: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Figure 6: Schematic of the power system for the sailboat

6 Electrical Organization of Navigation System

The sensor array (IMU, Rotary Sensor, and GPS Sensor), the microcontroller,the servo motors, and the power to all the components are arranged on a custom-made printed circuit board. A printed circuit board, or PCB, electrically con-nects electronic components using copper etchings that are essentially “printedwires” on a non-conducting plate or “board”. It acts as the hub of the electronicsystem, to which the microcontroller, sensors, and servo motors attach. Com-ponents such as resistors and capacitors are soldered on the board itself. Thismakes the setup modular and easy to set up. Once attached, these componentsare electrically connected through the previously mentioned conductive tracksmade by the copper etchings on the board, removing the need for loose wires.The PCB was designed on a computer-aided design (CAD) software called ”Ea-gleCAD”. After the board is printed, the different pins and parts are manuallysoldered onto the board. Refer to figure 7 and table 1 for the description of theconnections on the PCB.

10

Page 11: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Figure 7: PCB ports and connections

Table 1: Description of ports on the Sailboat’s PCB

Number Port/Part Port/Part Description1 Arduino Due The microcontroller slots into place at the posi-

tion indicated. The design is such that we haveaccess to the USB ports required for uploadingprograms to the microcontroller, without remov-ing the device from the PCB.

2 GPS Port The GPS Sensor connects to the Arduino Duethrough this 4 pin port.

3 3.3V Output This pin terminal is connected to the 3.3V outputand ground of the Arduino Due.

4 IMU Port The IMU connects to the Arduino Due throughthis 6 pin port

5 Magnetic Rotary Sensor Port The rotary sensor connects to the Arduino Duethrough this 6 pin port.

6 Unused Serial Ports These pins connect to the currently unused Serialcommunication channels (Serial 0 and Serial 2) ofthe Arduino Due.

7 Xbee Unit The Xbee unit slots into place at the positionindicated.

8 Unused Analog Pins These pins connect to the currently unused analogcommunication channels of the Arduino Due

9 Unused Digital Pins These pins connect to the currently unused analogcommunication channels of the Arduino Due

10 LEDs These LEDs provide immediately visible feed-back, and help during debugging

11 Power Input The 6V battery (see section 5) connects to theboard through this terminal

12 5V Output Power from the input is run through a voltageregulator. The 5V output from the regulator isaccessible through this terminal

11

Page 12: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

7 Navigation Algorithm

As described in Section 2, our boat knows its lattitude-longitude coordinates,its orientation with respect to true North, and wind direction with respect totrue North. In addition, in order to sail on a course, the boat has a series ofwaypoints that it is trying to reach. It is important to note that the only waythat we can steer the sailboat is through changing the sail and tail angles. Toensure that the boat is sailing such that changing conditions (changing wind,changing orientation and changing position) can be accounted for, we follow aprocedure that sets our boat on the best maneuver to get to a waypoint with re-spect to its current state, and checks if that maneuver is being followed at everyinstance until the waypoint is reached. We call this the Short Course Algorithm.

The short course algorithm is executed as follows:

1. Determine waypoint to sail to

2. Find the optimal heading to that waypoint

3. Looking at boat orientation and desired optimal heading, determine whichmaneuver to execute in order to get to that waypoint

4. Output sail and tail angles to execute maneuver

7.1 Selecting a waypoint and getting from latitude-longitudeto distance (in meters) coordinate system

The Navigation Algorithm accesses an array (an ordered list) of all the way-points that are on our path, in latitude longitude coordinates. A variable keepstrack of the waypoint number, which is the index (number referencing an ele-ment of the array) in the array of the next waypoint that the boat is trying toreach. At the beginning of each iteration of the navigation algorithm, we checkto see if that waypoint has been reached yet. To check if we have reached awaypoint, we calculate how far the sailboat is from the target. If that distanceis within a set error (optimized through testing), then we are close enough tosay that the waypoint has been reached. We then begin sailing toward the nextwaypoint in the path. We get the next waypoint from the array and incrementthe variable storing the waypoint number (or array index).

Before our navigation algorithm is executed for the sailboat, it is necessaryto take into account the fact that two pairs of latitude and longitude coordinatesdo not form a perfect square. Thus, distances between a pair of co-ordinatesis unequal at different locations on the Earth. A function that accurately findsthe distance and angle between two coordinates is, therefore, required. We firstcreate a vector that starts at the boat’s location and ends at the waypoint. We

12

Page 13: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

then find the angle between the wind and the vector from our location to thewaypoint. Following this, we use the Haversine Formula to calculate the distanceto the waypoint. The formula provides the great-circle distance(distances on thesurface of a sphere, along the circumference of a circle which shares its diameterwith one of the diameters of the sphere), between a pair of co-ordinates.

7.2 Finding a heading

In order to find the next heading, we have to take into account wind direction,boat position, next waypoint position, and our boat polar. A boat polar is agraph plotting boat velocity in different wind conditions with respect to differentangles of attack to the wind. We define velocity-made-good as the componentof boat velocity in the direction of the wind. Our sailboat’s boat polar is shownin Figure 8.

Figure 8: Our sailboat’s polar diagram plotting boat speed with respect to angleof attack

The above diagram shows boat velocity for a certain angle of attack. Thecenter represents where the boat is located, with the wind coming from 0 de-grees, directly above. The angle of attack of an object refers to the angle theobject’s heading makes with the direction of the wind. For example, if the boat’sangle of attack were 90 degrees with respect to wind going at 5m/s, the boat’svelocity would be .75m/s. For a location that is directly upwind (0 degrees withrespect to the wind), the boat polar shows that if we set our heading directlyto that location, the boat velocity would be 0m/s. So instead of always headingdirectly to a location, instead it is more optimal to head at a higher angle ofattack to the wind for some time, then change direction, and head back to thelocation. This is called heading at a tack. As seen above, to get to a locationupwind with with the wind at 5m/s, the optimal way to sail is to head an angle50 degrees from the wind because it has the maximum velocity-made-good, andthen to tack or jibe back across and head at the opposite 50 degree upwind

13

Page 14: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

angle. Most boats can sail directly downwind, but our boat is different due tothe airfoil shape of the sail. However, in the same way as heading upwind, thereis an angle in which the velocity-made-good downwind is maximized. Here, itis 150 degrees from the wind direction in either direction. For all wind speeds,the optimal angle is similar, however in the future we will slightly change theoptimal angle upwind and downwind if we decide to gather wind speed data.

We are always trying to find the fastest and most efficient way to sail to ourwaypoint. Because our boat cannot go directly upwind or downwind, if the angleto the waypoint with respect to the wind is too close to the wind or 180 degreesfrom the wind, it is not a good idea to sail directly to the waypoint. Instead,it is better to sail at the angle where the velocity-made-good is maximized. Onthe other hand, if the angle to the waypoint with respect to the wind is farenough away from the wind, we can sail directly to the waypoint because thevelocity-made-good to the waypoint is maximized at the angle directly to thewaypoint. Because of this, our process of finding a next heading is broken upinto six sections. Figure 9 shows the six sections, if the wind is coming fromdirectly in front and the boat is at the center.

Figure 9: Boat at center, wind coming from above, vector to waypoint falls ina section

For a vector to the waypoint, whichever section it falls in, we set our headingto be the heading given by that section shown below:

1. +optimal angle upwind

2. directly to target

3. 180 - optimal angle downwind

4. 180 + optimal angle downwind

5. directly to target

6. -optimal angle upwind.

14

Page 15: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

This heading is the heading that we would want to be going on in the nextiteration of the algorithm. However, our boat cannot turn instantaneously, andso if the boat orientation is not directly in line with the desired heading, wemust execute a maneuver.

7.3 Choosing a Maneuver

We have determined 8 maneuvers that our boat must be able to execute:

1. Head directly to a waypoint

2. Turn slightly to get back on desired heading

3. Head left of the wind upwind

4. Head right of the wind upwind

5. Head left of the wind downwind

6. Head right of the wind downwind

7. Jibe (turn) left

8. Jibe (turn) right

We currently do not have the maneuver to tack. It is much less stable thana jibe, and while tacking is much more efficient, it is a more complex maneuver.Because of this, we focused on jibing and making sure that our algorithm is ableto execute a complete course, before implementing tacking.

An example of a basic maneuver is head upwind to the right, jibe to theright, turn slightly to get back on the desired heading, then head directly to thewaypoint. This path is shown in Figure 10.

Figure 10: An example maneuver

15

Page 16: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

This example in figure 10 shows an intuitive path, knowing that we cannotsail directly to the waypoint from the start, and so we must head upwind andthen turn right to get back on the heading directly to the waypoint. Jibing willbe discussed more in depth in section 7.5, but for now, it is essential to knowthat we lose a known distance whenever we execute a jibe, so we must headfurther upwind than originally anticipated, so that when we execute a jibe weknow that we are going to be able to head to the next waypoint. To make thisa robust solution, we must check at each stage to see what the next maneuveris, and when to transition from state to state. Figure 11 is a diagram thatillustrates when we transition from one maneuver to another. States transitionwhen a relevant incident occurs, such as when a jibe is completed or when aheading is reached.

Figure 11: State diagram of boat maneuvers

In essence, we start the boat at maneuver 1, which is the code that turns theboat from whatever orientation it is in to get us back on our desired heading. Ifthe angle to the waypoint is too close to the wind or 180 degrees from the wind,we head upwind or downwind to the right or the left according to the optimalangles discussed in the section above about finding a heading. If going upwind,keep going until we have covered the known distance that we lose to a jibe, andthen start jibing. When jibing, keep turning until the boat orientation is on thecorrect side of the wind, facing the waypoint. Once it faces the waypoint, headto the waypoint, turning if needed.At each of these stages, we assume that the wind will be the same at the nextiteration of the code. However, if the wind changes, our maneuver must change.Sometimes, a change in wind is fine, but a large change in wind can throw off a

16

Page 17: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

maneuver.

This is a flaw of this method. The wind direction with respect to the way-point is taken into consideration only in certain states. For example, while theboat is performing a jibe, the wind direction with respect to the angle to thetarget is not recalculated. This poses a problem if the wind changes throughouta jibe maneuver, and the end result would be that the boat would sail off intothe distance, as pictured in figure 12.

Figure 12: This figure portrays what occurs if the wind direction were to changein the middle of a jibe maneuver. Path A represents the path under the initialwind, path C represents the expected route that the boat would take if the winddidn’t change, and path B represents the path sailed after the wind change,which occurs at point 1.

A sensible solution to this problem is to simply reset the state variable whena drastic change in wind direction is detected, thus cutting the jibe off andrecalculating a course to take. However, another problem was that the windis averaged in the main code, and that the value of the wind direction passedinto the short course algorithm was an averaged value. This is an issue becauseif the wind changes drastically the short course algorithm would only registera small change in wind direction. Therefore, it’s insensible to reset the statevariable based on the wind direction.

The solution is to detect if the boat is sailing in the wrong direction for anextended amount of time, and if it is, reset the state variable. This algorithmappears below in figure 13.

17

Page 18: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Figure 13: This figure demonstrates the current algorithm for accounting fora change in wind direction. Point 2 is where the algorithm takes control andcorrects the boat. Path C (in blue) is the corrected path.

It may not be the most efficient solution, however there is a relatively smallchance of the wind changing specifically during a jibe.

7.4 Output sail and tail angles

In order to execute jibing upwind and downwind maneuvers properly, we haveto set sail and tail angles accordingly. Our sail has 360 degrees of freedom, andthe tail can move 30 degrees clockwise or counterclockwise with respect to thesail. Our sail and tail also have an optimal angle of attack to the wind of 15degrees, where the coefficient of lift is maximized. At this angle, the lift forcewill be greatest. Most of the time, we want to be moving where the front ofthe boat is facing, so we set the sail at the angle of the wind, turned 15 degreesclockwise or counterclockwise depending on the orientation of the boat. This di-rection will be referred to as “forward” in this section. This is shown in figure 14.

Figure 14

18

Page 19: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

To move forward, if the front of the boat is to the right of the wind, likein the figure above, we set the sail at the angle of the wind plus the 15 degreeangle of attack. If the boat is to the left of the wind, we set the sail at the angleof the wind minus the 15 degree angle of attack.

However, if we are trying to jibe into the wind, then we do not want tomaximize the lift on the sail. When jibing into the wind, we want to executethe maneuver such that the amount of distance vertically with respect to thewind is minimized. In testing in a MATLAB simulator, if we generated lift withthe sail, we almost doubled the amount of ground lost to a jibe, compared to ifwe set the sail directly into the wind. We do not want to be moving forward ifwe have to drastically turn, because it will further increase the ground lost. Toaccount for this, when jibing, we set the sail directly into the wind.

When setting the tail angle, we can set the tail to in a 0-30 degree range withrespect to the sail on either side. If we are trying to head upwind or downwind,or directly to the waypoint, and the boat orientation is almost exactly the sameas the desired heading (5 degrees on either side) we set the tail directly into thewind, which minimizes the coefficient of lift, because we do not want to turnthe boat at all. If we are slightly off course (5-30 degrees on either side), we setthe tail to 15 degrees to turn the boat back on course. If we are significantlyoff course (more than 30 degrees), we set the tail to 30 degrees with respect tothe sail. While this is not the 15 degree maximal lift angle, in testing we sawthat 15 degrees does not turn the boat the fastest. By setting it to 30 degrees,we can use the coefficient of drag as well. This slows down our boat, but whenjibing, slowing down the boat is desired as it decreases the amount of groundlost. So when jibing, we slow down the boat and turn it to get back on thedesired heading quickly.

More detailed pseudocode for deciding what side to set the sail and tail toin the general turn code in Appendix A.

7.5 Jibing

Previously, we had the algorithm set such that the boat would jibe as soon asit recognized a direct path to its target (see figure 15 below).

19

Page 20: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Figure 15

At point A the boat recognizes that there is a direct path (path 1) to thetarget and begins to jibe in order to reach the waypoint. However, there is acertain amount of air drag on the sails all throughout the jibe, causing the boatto lose ground. As a result, the boat does not head on the intended path (path1)to the target, but instead heads on a path that will inevitably undershoot thetarget (path 2), causing it to jibe again and again until it reaches the waypoint.

We recognized this bug and developed a jibing process that correctly findsthe optimum path to the target. Our refined jibing process is displayed belowin figure 16.

Figure 16

This process saves point A and sets the boat to continue sailing on its headinguntil it travels a certain distance (Jibe Distance) from point A. As soon as itreaches this distance it begins to jibe (Point B), and by the time it has completedthe jibe it is on the correct path (Path 1) to the waypoint.

7.6 Optimal Algorithm

Jibing is not the only the boat can come about. It is also possible to set the sailand tail to the desired heading, and let the wind eventually catch and propel theboat towards the target. At this point in time, we are not sure which processof coming about is faster and more efficient. Therefore we have begun work on

20

Page 21: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

creating a similar algorithm which, instead of jibing, simply sets the sail andtail to the desired heading. The two process of coming about are shown belowin figure 17 and in figure 18.

Figure 17: The process of setting the sail and tail to the next heading. Here theboat completely stops at points B and C, and is travelling backwards at path2. At path 1 it is sailing in the correct direction.

Figure 18: The process of jibing. Here the boat never completely stops, howeverafter point B it is sailing in the opposite direction of which it should be headingin. A point of note though is that while jibing, our present implementation setsthe sail directly into the wind so as to not generate any lift, and thus does notlose as much ground.

As soon as we finish the second algorithm we will conduct a series of testsand comparisons to determine which algorithm is optimal. Several things we

21

Page 22: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

will work on include converting all distance to meters (we have a program thatdoes this already, we just need to implement it), finish the second algorithm inorder to compare and contrast the two, and fix any small bugs left in the originalalgorithm (for example, after the boat hits a waypoint, it simply sails off intothe distance, we want it to turn around and hit it again), and integrate multiplewaypoints into our testing, so that we know the algorithm can sail through acourse.

7.7 Buoy Rounding

We are also in the process of changing the present path-finding algorithm toround a buoy instead of hit a waypoint. The present calculation for whatmaneuver to execute only takes into account the next waypoint. While thisapproach will always get us close to the sequence of waypoints in the correctorder, it will not do so with the optimal number and location of jibes, and thusit will not round the buoys. For example, in Figure 19, the boat heads to thefirst waypoint, jibes around, hits the first waypoint, and then continues on thethe next waypoint. While this hits both waypoints, it does not execute the routethat would make sense.

Figure 19: Sub-optimal waypoint route (triangle represents the sailboat, circlesrepresent waypoints and the lines represents the route)

Figure 20 shows a route that makes more sense, because there is only onejibe, and the boat rounds the first buoy to the right and then heads past, andthen starts to jibe. In order to introduce this kind of path finding into ouralgorithm, we need to take the immediate next waypoint, as well as the oneafter it, into account.

22

Page 23: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Figure 20: Optimal route with rounding buoys (triangle represents the sailboat,circles represent waypoints and the lines represents the route)

Additionally, we cannot head directly to the waypoint, as we will not roundit. To compensate, at every iteration, we try to head to the point tangent to acircle around the waypoint, shown in figure 21.

Figure 21: The sailboat must head to points tangent to a circle around the buoy

The way this algorithm works is that there is an imaginary circle with radiusr around each buoy. The direction the boat wants to round the buoy (clockwiseor counterclockwise) is predetermined and stored in a variable. Based on thisvariable, the algorithm selects one of two possible tangent lines to the circleand finds the point of tangency (point A). This point is what the algorithmaims for, and we choose a maneuver such that our goal is to reach that pointwith the our orientation of the boat facing in the direction of the turn. Afterreaching this point, the boat attempts to circumnavigate the buoy, and if at anypoint it needs to jibe in order to do so, it does. Then, as soon as it “sees” thenext buoy’s point of tangency (seen being the next buoy that there is line fromthe boat to the buoy that rounds all the previous buoys), it breaks off of itscircumnavigation and heads towards the next buoy (at point B). However, once

23

Page 24: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

it sees the next point, it cannot always immediately turn. In the example twofigures above, if the boat saw the second waypoint and immediately jibed toget there, it would backtrack around the first buoy, and never actually round it.To compensate for this, it must check whether it can turn before it starts to turn.

When jibing, we know that we lose a set amount of ground. In order tostart jibing, we have to make sure that that distance will not put us below abuoy that we are trying to round. And to make sure that we execute the fewestnumber of jibes possible, we should not start jibing when the angle that wewould come out of the jibe on would put us below the next waypoint.

In a more formal approach:

1. Each waypoint has an angle associated with it, such that, it is the maxi-mum upwind or downwind angle that we can approach it at (call this maxangle)

2. On the upwind or downwind maneuver, we cross this angle at some point(call this tack point)

3. We lose a known vertical distance to a jibe (call this jibe distance)

4. There is a buoy which is, the last buoy we have “seen”

If that seen buoy is different from the buoy that we are currently trying toreach, then check if we have gone jibe distance past the max angle to the ”seen”buoy, as well as jibe distance past the tacking point from the target buoy. Ifthey are the same, then we can just check if we have gone jibe distance past thetacking point of the target buoy.

Figure 22

24

Page 25: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

Referring to figure 22, the boat is able to round waypoints, and execute fewerjibes, in order to get the optimal path upwind. The process is similar for goingdownwind, however, due to the nature of jibing downwind, the boat does notlose ground when jibing. Because of this, the boat can ignore the need to headpast the maximum upwind angle point, and instead start the jibe immediatelywhen both angles are cleared.

8 Testing

Testing the navigation system of the boat had started prior to the boat beingfully mechanically functional, and has since been continuing well after the boathas reached a mechanically satisfactory stage. Thus far, testing has been donein two primary ways described in sections 8.1 and 8.2. Section 8.3 describes thefinal stage of testing that was begun this semester.

8.1 Testing through simulations

A MATLAB simulation (developed by Sara Gregg, Mechanical Engineering ’16)was used to test the functioning of the navigation algorithm. The simulationtakes in wind direction, initial boat direction, and the destination along withthe code for the algorithm itself to demonstrate what our sailboat tries to do ineach scenario. This simulation was improved upon such that it could be made torun a number of times with different combinations of the wind direction, boatdirection and waypoint. This allowed for thorough testing of the navigationalgorithm during early stages.

8.2 Testing on land

After the implementation of the sensor array and the control system (servos [seesection 2.5)]) was complete, the algorithm was uploaded to the microcontroller(see section 2.1). The whole system was then taken out to the Engineering Quadin Cornell University and tested to ensure that the sensor array was reading cor-rect wind direction, boat direction, boat heading and coordinates, and that thealgorithm was outputting the correct optimal heading, sailing maneuvers andcorresponding sail and tail angles, for the collected data.

Once, the boat was mechanically ready, sailing was ”simulated” on the En-gineering Quad by carrying the boat and reacting (to the best of our abilities)just the way the sailboat would if it sailing, by observing the changing sail andtail angles.

Tests on the simulation and on the Engineering Quad have been promising.The boat correctly collects data from the environment and executes the expectedsailing maneuvers. However, without the boat on water, it is hard to determinehow the boat will actually sail.

25

Page 26: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

8.3 Testing on water

We have been using Cayuga Lake in Ithaca to test the sailboat’s sailing capabil-ity. Thus far, only RC (see section 4) has been used while the boat has been onwater. The navigation algorithm is yet to be tested on the lake. The remote-controlled sailboat demonstrated that with the present height of the sail, thesailboat acts erratically in high winds. Therefore, autonomous navigation willfirst be tested in low wind.

9 Future Work

Our sailboat is currently designed to sail within a radius of 15-20 km, basedon limitations set primarily by our power system. In the future, we plan toimplement a system for the boat to harness solar energy. The small size ofour boat makes such a implementation challenging. According to research byProfessor Andy Ruina, Available solar power for a direct well-aimed solar cellis up to about 200W/m2 in good conditions.” The size of the proposed boatallows for 0.1m2 of solar cells, which reduces that power down to 20W. Takinginto account losses due to: 1) bad orientation (5̃0%) 2) night time at extremelatitudes in winter (2̃5%), and 3) cloud cover (1̃0%) leaves the boat to managewith 0.3W of average electrical power in the worst of scenarios. Prof. Ruina hasnoted that that 0.3 W is not enough power for the boat to run its navigationsystem continuously [1].

We plan to approach the power management problem in a combination of 3ways:

1. Design circuits with low power, low loss components, in combination withan appropriately large capacity battery for energy storage.

2. Design a power circuit such that the conversion from collected solar energyto usable electrical energy is as efficient as possible.

3. Design a power management system which actively chooses to turn offcomponents when they are not in use. For example, when the boat is notactively navigating, and is instead collecting/sampling data from a fixedlocation, the servo motors and the 3 sensors can be turned off or set intolow power mode. Similarly, if Professor Ruina’s passively-directionally-stable sailboat concept pans out, sensors and actuators can be turned offfor periods of time and navigation will continue adequately.

26

Page 27: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

10 Appendix

10.1 Appendix A

General turn Pseudo-code

27

Page 28: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

10.2 Appendix B

Electronic components and respective page links:

1. Microcontroller: Arduino Duehttp://www.arduino.cc/en/Main/ArduinoBoardDue

2. IMU: Yost Labs 3 Space Embedded Sensorhttps://www.yostlabs.com/productdisplay/3-space-embedded-0

3. GPS: Parallax PAM-7Q GPS Modulehttps://www.parallax.com/product/28509

4. Rotary Sensor: AS5147 by AMShttp://ams.com/eng/Products/Magnetic-Position-Sensors/Angle-Position-On-Axis/AS5147

5. Sail Servo: HS-785HB by Hitechttps : //www.servocity.com/html/hs−785hb 3 5 rotations.html#.V yQlijArKCg

6. Tail Servo: HS-5646WP by Hitechttps : //www.servocity.com/html/hs−5646wp servo.html#.V yQl1DArKCg

28

Page 29: CU SAIL Navigation Team Spring 2016 Semester Report...comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation

References

[1] Andy Ruina’s proposal to the National Science Foundation. NRI: Low-costRobotic Sailboats for Long-Term Ocean Monitoring, March 2016.

29