cu sail navigation team spring 2016 semester report sail navigation team spring 2016 semester report...

23
CU SAIL Navigation Team Spring 2016 Semester Report Professor Andy Ruina’s Biorobotics and Locomotion Lab Cornell University Alicia Coto, Alex Pomerenk, Caleb Koch, Orla MacLean, Alec Dean, Arjan Singh December 13, 2016 Abstract CU Sail’s goal for this semester was to iterate on the navigation system developed in Fall 2016 for increased robustness and an expanded feature set. The navigation system allows our boat to autonomously sail from one global position (waypoint) to another. A combination of an electrical array of sensors and a short term navigation algorithm determine appropriate sailing maneuvers for our sailboat to reach its desired destination. The sensor array comprises of a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic Rotary Sensor, which allow the navigation algorithm to access wind direction, current position and boat orientation. The sailing maneuvers thus determined by the navigation algorithm are executed by a control system consisting of servo motors, that rotate the sail and tail to appro- priate angles. Feedback is provided by a short-distance radio communication system as well as visible LED lights. A microcontroller allows for communication between the sensor array, the navigation algorithm, the control system and the feedback system. In addition, the microcon- troller also handles scheduling tasks. The navigation system is powered by a rechargeable 6V, 330 amp hr, NiMH battery pack. Power from the battery is directly supplied to the control system and the microcontroller. The microcontroller in turn, supplies power to the sensor array and the feedback system. The Navigation algorithm operates by first, determining the waypoint to sail to and then finding the optimal heading to sail in, in order to reach that way- point. Then, by taking into account data given by the sensor array, the algorithm determines appropriate sail and tail-vane angles that would execute those maneuvers. The navigation sys- tem has been tested using a MATLAB simulation, on the Engineering Quad and on Cayuga Lake with general success in accomplishing basic tasks such as sailing to a waypoint and back; our system obtained accurate data from the environment and set correct sail and tail angles to execute the optimal maneuver for such simple scenarios. CU Sail also started development that would allow future iterations of Sail-Vane to detect and avoid obstacles, and draw power from a power system operated on solar power. 1

Upload: dolien

Post on 29-Mar-2018

216 views

Category:

Documents


1 download

TRANSCRIPT

CU SAILNavigation Team

Spring 2016 Semester Report

Professor Andy Ruina’s Biorobotics and Locomotion LabCornell University

Alicia Coto, Alex Pomerenk, Caleb Koch, Orla MacLean, Alec Dean, Arjan Singh

December 13, 2016

Abstract

CU Sail’s goal for this semester was to iterate on the navigation system developed in Fall2016 for increased robustness and an expanded feature set. The navigation system allows ourboat to autonomously sail from one global position (waypoint) to another. A combinationof an electrical array of sensors and a short term navigation algorithm determine appropriatesailing maneuvers for our sailboat to reach its desired destination. The sensor array comprisesof a Global Positioning System sensor, an Inertial Measurement Unit and a magnetic RotarySensor, which allow the navigation algorithm to access wind direction, current position andboat orientation. The sailing maneuvers thus determined by the navigation algorithm areexecuted by a control system consisting of servo motors, that rotate the sail and tail to appro-priate angles. Feedback is provided by a short-distance radio communication system as well asvisible LED lights. A microcontroller allows for communication between the sensor array, thenavigation algorithm, the control system and the feedback system. In addition, the microcon-troller also handles scheduling tasks. The navigation system is powered by a rechargeable 6V,330 amp hr, NiMH battery pack. Power from the battery is directly supplied to the controlsystem and the microcontroller. The microcontroller in turn, supplies power to the sensorarray and the feedback system. The Navigation algorithm operates by first, determining thewaypoint to sail to and then finding the optimal heading to sail in, in order to reach that way-point. Then, by taking into account data given by the sensor array, the algorithm determinesappropriate sail and tail-vane angles that would execute those maneuvers. The navigation sys-tem has been tested using a MATLAB simulation, on the Engineering Quad and on CayugaLake with general success in accomplishing basic tasks such as sailing to a waypoint and back;our system obtained accurate data from the environment and set correct sail and tail anglesto execute the optimal maneuver for such simple scenarios. CU Sail also started developmentthat would allow future iterations of Sail-Vane to detect and avoid obstacles, and draw powerfrom a power system operated on solar power.

1

Contents1 Introduction 3

2 Microcontroller and Sensors 32.1 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Magnetic Rotary Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3 Inertial Measurement Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4 GPS Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.5 Servo Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Communication System 6

4 Remote Control 7

5 Power System 7

6 Printed Circuit Boards 76.1 Control Hub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76.2 Rotary Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

7 Solar Power 107.1 Solar Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107.2 Solar Charger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117.3 Future Work for Solar Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

8 Navigation Algorithm 12

9 Error Analysis 169.1 Distance Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169.2 Course Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

10 Pixy CMUcam5 1910.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1910.2 Obstacle avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2010.3 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2110.4 Future Work for Pixy CMUcam5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

11 Appendix 2211.1 Appendix A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2211.2 Appendix B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2

1 Introduction

Sail-Vane must be able to sail to a designated set of coordinates by taking into account its presentlatitude and longitude, perceived wind direction, the boat heading, and the boat direction. Theboat direction refers to the direction the nose of the boat points to, with respect to true North,while the boat heading refers to the direction the boat is moving, also with respect to true North. Asailboat generally does not move in the direction that its nose points, which makes this distinctionbetween heading and direction important. We approach the task in three parts; 1) Acquisition ofdata relevant for navigation; 2) Using the acquired data to determine appropriate sailing maneu-vers; and 3) Executing the sailing maneuvers. The first part of the process is achieved by a set ofsensors; A magnetic rotary sensor allows the detection of wind direction, a GPS sensor determinesour boats coordinates and boat heading, and an Inertial Measurement Unit provides boat direction.The second part is done via an algorithm which uses sensor data to determine the next direction ofthe boat, and the relevant sailing maneuver to sail in that direction. The final part is accomplishedby a set of servo motors. A microcontroller acts as a bridge between the three parts and allowsthe flow of data from the sensors, to the algorithm and finally to the motors. Sail-Vane also hassupplementary sub-systems that allow for communication and data-logging; a set of on-board LEDlights and a pair of radio transceivers. CU Sail also started developing other sub-systems to allowfor an expanded feature set in future iterations of Sail-Vane. Such systems include a vision systemthat will be used for obstacle detection and solar power for the vessel, which will allow the boatto be on the water for large instances of time.

2 Microcontroller and Sensors

2.1 Microcontroller

The microcontroller handles scheduling tasks, determining how often the sensors must activate andcollect data, a new heading must be calculated, a new maneuver needs to be executed to stay oncourse and communication must be made. We are currently using the Arduino Due as the sailboat’smicro-controller. The processor core of the Due is made by Atmel (Atmel SAM3X8E), and runsat 84 MHz. This microcontroller has enough ports and pins to accommodate our current sensorarray, and even additions we might make in the future. The high clock speed of the processoralso allows us to stay clear of potential bottlenecks in terms of the frequency at which we mightwant to run the navigation algorithm. The processor communicates with the sensor array throughvarious communication protocols that vary between devices. The following protocols are used byour navigation system:

1. Serial Communication. Communication between two devices is considered serial when datais transferred one bit at a time. This serial communication can be aided by a clock signal (aconstant sequence of alternating 1s and 0s) generated by the processor. In such a case, datawill only be transferred when the clock signal changes from 0 to 1 (rising edge) or when theclock signal changes from 1 to 0 (falling edge). This serial protocol is considered synchronous.In the case where the clock is not used, the serial protocol is considered asynchronous. Acommonly used asynchronous serial communication protocol (which the Arduino Due alsouses), is known simply as Serial Communication. This communication protocol uses twochannels for communication between devices: one to receive data (RX) and one to transferdata (TX). The connection between two devices is made as shown in Figure 1. The RX portof one device connects to the TX port of the other device. The Arduino Due has four serialports labeled Serial 0, Serial 1, Serial 2 and Serial 3. By default, the Arduino uses Serial 0to communicate with the users personal computer (PC). Serial 0 is used to print statementson the screen and also to upload program(s) to the microcontroller.

2. Serial Peripheral Interface or SPI, is an example of Synchronous Serial Communication.Bits (1 or 0) are transferred one at a time through designated Transfer and Receive channels.Because this communication is synchronous, the transfer of bits is synchronized with the clocksignal produced by the Arduino. This requires one more channel of communication betweenthe devices- The clock signal. Furthermore, in SPI protocol, it is possible for multiple devices

3

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

to use the same clock, transfer, and receive channels. The restriction, however, is that in thecase of our processor, only one device can use the channels at any given moment. This givesrise to a fourth channel, called the chip select or slave select. The device with an active chipselect signal from the Arduino will be allowed to use the SPI protocol of the microcontroller.Once that chip select signal becomes inactive, the device can no longer use the SPI protocol.The transfer and receive channels are referred to as MOSI (Master Out Slave In) and MISO(Master In Slave Out). In our case, the Master is the Arduino Due, and the Slave is thesensor communicating with the Arduino Due. The clock channel is the CLK or SCK channel,and the chip select channel is abbreviated to CSn or SS.

3. Inter-Integrated Circuit or I2C, is another form of Synchronous Serial Communication. I2Crequires two channels for communication between devices: The SDA (or the data line) and theSCL (or the clock line). Unlike SPI and Asynchronous Serial Communication, I2C handlessending and receiving data on one channel. Since a pair of I2C lines can be used to drivemultiple devices, each device has a pre-defined address which is either 7-bits or 10-bits long.These addresses can be found in the data-sheet of the device. The function of this addresscan be thought of as being similar to that of the chip select signal used in SPI communication(See item above). In our case, the Arduino would serve as the "master" and communicatingsensors would serve as "slaves". This means that the Arduino would control the clock rateand also initiate data transfers over the SDA line, allowing it (and inevitably, us) to controlthe flow of data across the channel.

4. Pulse Width Modulation or PWM, is a timed digital signal. A digital signal is one that iseither low (0) or high (1). A PWM signal is one where the duration for which a digital signalis high (or low) is measured to produce a duty cycle. The percentage of time a signal is highin a period of time compared to the period is called the signals duty cycle. For example, ifthe signal is high for half the period of time, the duty cycle is 50% (see Figure 2). At a highenough frequency ( 100 Hz), changing the duty cycle of a signal can result in analog values(values across a range; not just ”high” or ”low”) obtained from the digital signal. PWM isused to control 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 position of a shaft. Ourmagnetic sensor does this task by measuring the orientation of the magnetic field of a permanentmagnet which is mounted underneath the shaft, whose angular position is to be determined. Figure3 below demonstrates the position of the sensor relative to the magnet. We need this sensor toobtain the wind direction with respect to the boat direction. A magnet is attached to the bottomof the shaft of a wind vane, below which sits the rotary sensor. As the wind vane rotates dueto the wind, the magnet underneath moves. The associated change in magnetic field is detected

4

by the rotary sensor, which outputs an angular position. The Magnetic Rotary Sensor uses theSPI protocol for communication, which requires a 4-channel connection to the microcontroller inaddition to power, as described in section 2.1.

Problems encountered: Although a very rugged, low cost and accurate sensor, mechanicalintegration with the wind-vane has been a source of problems. Designing a housing for the sensorthat places a magnet at a favorable distance from the chip while ensuring a freely rotating shaftand a water-proof environment has been a challenge.

Figure 3: Structure of a magnetic rotary sensor unit after installation, displaying the sen-sor(bottom), the shaft and a cylindrical magnet. (source: machinedesign.com)

2.3 Inertial Measurement Unit

The inertial measurement unit, or IMU, allows measurement of the orientation of the boat, in termsof the roll, pitch and yaw see figure 4. It does this using a combination of 3 sensors: a gyroscope, amagnetometer and an accelerometer. A gyroscope measures the rate of change of the three angles.A magnetometer measures the direction of the earths magnetic field relative to the boat. Thisallows for two things: determining the boat heading with respect to North, and determining winddirection with respect to North. In the previous section about the Magnetic Rotary Sensor, Imentioned that the sensor determines wind direction with respect to the boat direction. Knowingthe boat direction with respect to North allows us to obtain wind direction with respect to trueNorth. Lastly, the accelerometer measures the acceleration due to the forces on it. In the caseof our boat, this means detecting the direction of Earths gravitational force relative to the boat.In other words, it detects which way is down, with respect to the boat, measuring the tip of theboat. With a combination of these three outputs from the 3 sensors, and an on-board processor,an IMU determines the roll, pitch and yaw i.e. the orientation, of the boat. The IMU also usesthe SPI protocol. It can thus, share the MOSI, MISO and CLK (see section 2.1) with the RotarySensor, but requires a different chip select channel for successful communication with the ArduinoDue.

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

Problems encountered: The principle purpose of the IMU on Sail-Vane is the detection of boatdirection. The boat direction is given by the Yaw angle measured by the IMU. This measurement

5

has been subject to a substantial amount of inaccuracy during lake and land testing. This hasbeen attributed to the following factors:

1. Presence of magnetic interference: This was a great factor when testing the device indoors.Depending on where testing was done, the yaw angle obtained had an error of anywherebetween 0 to 20 degrees. When testing inside the boat, the problem persisted due to theIMU being in close proximity to the GPS Sensor (See section 2.4) and the Battery. Toavoid such inaccuracies in the Yaw angle reading, the IMU must be isolated from all otherelectronics on the boat.

2. Calibration: The IMU’s accelerometer and magnetometer can be calibrated using the YEI3-Space Sensor Software Suite provided by Yost Labs for the Sensor. See 11.2 for instructions.

Another problem encountered arose from the fact that the IMU shared the MOSI, MISO andCLK lines with the Rotary Sensor (See section 2.2). During lake testing, if the rotary sensorgot wet resulting in any of the 3 lines getting shorted, the IMU also stopped functioning.

2.4 GPS Sensor

A global positioning system sensor, or GPS Sensor, is a sensor that, through connection with GPSsatellites provides latitude, longitude, time, heading and speed. The GPS uses Serial communica-tion to communicate with the microcontroller. The RX port of the GPS connects to the TX portof the Serial channel on 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).

Problems encountered: The GPS has thus far functioned very well in all testing environments.The only fact to keep in mind is that the GPS does not function indoors and takes 2 minutes tostart providing position data once outside.

2.5 Servo Motors

A servo motor or a servo, is a device that is a combination of a motor and an angular positionsensor (the magnetic rotary sensor is an example of such a sensor). The motor allows a shaft torotate as required, while the position sensor keeps track of the position of the shaft. Such sensingallows us to move the 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 PWM pins 2.1 on themicrocontroller.

The three sensors above (magnetic rotary sensor, IMU, GPS) allow the microcontroller to obtainthe necessary data required to successfully implement our navigation algorithm, which then assignsthe sail and tail to be set to the required angles. The servo motors then use that output from thealgorithm to set the sail and tail accordingly.

3 Communication System

Our sailboat achieves short distance communication through small radio modules manufacturedby Digi International. These Xbee-Pro S3B modules allow for wireless communication between themicrocontroller and a personal computer (PC). An Xbee module can transmit, in a Serial manner(see section 2.1), data to a linked Xbee module. One of these modules is connected to a Serialchannel of the Arduino Due (Serial1), while the other is connected via USB (which also uses a formof serial protocol), to a PC. The Xbee modules thus channel data from the Arduino Due to theuser’s computer. It is important to keep in mind that in real world scenarios, the range is about100m when maintaining a line-of-sight. This range reduces greatly when there are obstructionsbetween the receiver and transmitter.

6

4 Remote Control

The remote control (RC) system was also developed as a fail safe to bring the boat back to shorein case the navigation algorithm makes the boat malfunction. The circuit for the RC involves theuse of a multiplexer. A multiplexer is a device that has multiple inputs and one output. Thedevice selects one of the inputs to pass through and become the output depending on the stateof a digital ”select” signal. In our case, the multiplexer has two inputs; one input is the remotecontrol, while the other is the microcontroller. The digital ”select” signal is controlled by a switchon the transmitter. The overview of the system can be seen in figure 5. On receiving power, themultiplexer defaults to outputting the signal from the remote control, which means that unless theRC functions, the boat will not run. This acts as an effective safeguard that ensures the boat isnever 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 input voltage require-ments. The Arduino Due requires an input voltage in the range of 6-16 V. This input voltage isthen regulated down to the operating voltage of the processor, 3.3 V, by the microcontroller circuitboard. The three sensors were chosen such that they do not operate at a voltage higher than theoperating voltage of the microcontroller. The IMU, GPS Sensor and the Rotary Sensor require3.3V for their operation. This 3.3V can be provided directly by the microcontroller through oneof its power-output pins. The servo motors require an input voltage of 4.8-6 V. Strictly lookingat these voltage limits, the servo motors can be powered by the microcontroller, however, in cer-tain load conditions it is possible for the servos to require higher current ( 800 mA), than themicrocontroller pins can provide ( 700mA). With these requirements in mind, the following systemhas been put in place: An external 6V battery powers the microcontroller and the servo motors,while the microcontroller in turn provides the required 3.3V for the IMU, GPS and Rotary Sensor.Refer to Figure 6 for a schematic of the power system. It is important to remember that becausethe servos receive their respective signals from the microcontroller, but are powered by an exter-nal battery, the reference ground voltages (GND) of the microcontroller and the battery must beconnected.

6 Printed Circuit Boards

6.1 Control Hub

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

7

Figure 6: Schematic of the power system for the sailboat

printed circuit board, or PCB, electrically connects electronic components using copper etchingsthat are essentially printed wires on a non-conducting plate or board. It acts as the hub of theelectronic system, to which the microcontroller, sensors, and servo motors attach. Componentssuch as resistors and capacitors are soldered on the board itself. This makes the setup modular andeasy to set up. Once attached, these components are electrically connected through the previouslymentioned conductive tracks made by the copper etchings on the board, removing the need for loosewires. The PCB was designed on a computer-aided design (CAD) software called ”EagleCAD”.After the board is printed, the different pins and parts are manually soldered onto the board. Referto figure 7 and table 1 for the description of the connections on the PCB.

Figure 7: PCB ports and connections

8

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

6.2 Rotary Sensor

A custom printed circuit board houses the AS5047 rotary sensor chip wind vane. The new boardwill be used on all future iterations of Sail-Vane as its reduced footprint compared to a stockevaluation board helps with the design of the wind-vane. The schematic and board layout can beseen in figure 8

Figure 8: Schematic and Board layout for the AS5147 PCB

9

7 Solar Power

Part of the International Robotic Sailing Regatta that we plan to attend in spring 2017 includesthe Endurance Challenge. For this challenge, we must complete laps around 4 buoys for up to 8hours. Each lap is about one Nautical Meter (NM) or approximately 1852 meters. One point isawarded for each lap completed for a maximum of 4 points and then an additional point is addedfor each hour completed with a maximum total score of 10. In order to complete this challenge tothe best of our ability, we cannot have Sail-Vane rely on just the battery we are using now. Forthat reason, I have taken on the task of incorporating solar panels onto the boat to prolong batterylife.

7.1 Solar Panels

Currently we own two solar panels, both outputting around 6 volts, but one a bit larger with ahigher power rating. As these panels were purchased in previous years, I do not know the specificpower rating of each panel. From the data Ive collected, the larger panel seems to output abouttwice the amount of amps as the smaller one. The larger panel measures 17.5 cm by 22 cm. Thesmaller panel measures 11 cm by 21 cm. Figure 10 shows the two panels we currently have. Figure9 shows example data collected regarding the output of each panel over the course of an averageday.

Figure 9: This data was taken on November 5th, 2016, a somewhat cloudy day. The estimatedpower was calculated by multiplying half the open circuit voltage by half the short circuit current.

Figure 10: Above are the two 6 volt panels we currently possess.

10

7.2 Solar Charger

These solar panels will be connected to a solar charger that will charge our battery continuouslyin order to extend the battery life, when starting testing or a competition we should always makesure the battery starts at full charge in order to keep the battery charged for as long as possible.The power outputs shown in figure /reffig:solar panel data are not high enough to keep the boatrunning at full power for an entire day so in the future we will need to find another solution, suchas adding more panels on the sail. For now, extending the battery life should be sufficient to scorehighly in the endurance competition. The Solar Charger we purchased this year is a simple chargerusing PWM that can charge 6 or 12 Volt batteries and can carry a load using a maximum of 3Amps, which is sufficient for our needs. This charger is not a Maximum Power Point Trackingcharger or MPPT charger, which is considered the best on the market. The MPPT charger allowsthe panel to operate at a higher power output by finding the point where the voltage and ampoutput matches that of the maximum power it can achieve. These chargers are far more expensive,potentially costing hundreds of dollars, and I could not find an MPPT charger suitable to chargeour 6 volt battery. Therefore, I stuck with the less effective solar charger found in figure 11.In thefuture we may want to look into an MPPT charger if the one we have now does not output enoughpower to meet our needs.

Figure 11: Above is the solar charge controller we will use to extend the battery life of the 6 voltbattery we currently use.

Figure 11 above shows the solar charger with its three channels: one for the solar panels (A), onefor the battery (B) and one for the load (C). To test the charger, hook up the solar panels to thepositive and negative terminals shown by arrow A. Then, put wires coming out of the rest of theterminals. Use a multi-meter to measure the voltage and amps of the terminals. When a batteryis not hooked up to the charger, the load terminals will show zero volts and amps. When onlythe large panel or small panel is hooked up, a high enough voltage is not available to charge thebattery. When this occurs, all the LEDs at the top will flash repeatedly. For example, when justthe large panel was hooked up I found that that the battery terminal outputted only 5.46 V and.02 amps. Then, once I connected the panels in series, the LEDs stopped flashing and the batteryterminal outputted 8.2 Volts and .01 amps. When simply measuring the output of the panels inseries not connected to the charger, I found the output to be 11.43 volts and .01 amps. Somepower was lost due to the charger finding a suitable voltage to charge the batter with.

Information regarding the purchase of the solar charger:

3A, 6V/12V Solar Charger

http://store.sundancesolar.com/solar-charge-controller-3a-6v-12v/

11

7.3 Future Work for Solar Power

In the next semester, before the competition, we must buy two new panels of equal power ratingbecause when two panels of inequivalent power ratings are connected together in series, the currentmatches the current of the panel with the smaller power rating. This reduces the power of thelarger panel, therefore not being as effective as possible. When using the solar charger, it seemsthe voltage also gets reduced to the correct amount to charge the battery, therefore, we shouldnot need panels that output more than 12 volts. When looking for panels, we need to look for thehighest power rating possible. Ive considered two different options for the new solar panels. Onebeing two 6 volt panels connected in series, the other being two 9 volt or 12 volt panels connectedin parallel. The benefit of connecting the panels in parallel is that the amps produced from bothpanels will add together, resulting in a higher power rating. When purchasing the panels, the sizemust also be taken in consideration. The panels must fit on the top of the deck, and preferablythey will sit nicely on top of the hatch openings. We should work closely with the mechanical teamto ensure a good fit. The panels must also be weather proof since they will most certainly comein contact with the water. Another challenge for the future is wiring the solar charger so that itcan connect to the battery, solar panels and loads neatly in the boat. The battery must be easilyremovable so we can charge it not using the panels if necessary. Also, next semester, thoroughtests should be done to determine how long the battery can run the boat with the solar chargingsystem.

8 Navigation Algorithm

In these sections, we outline the navigation algorithm background, the goals of the current algo-rithm, the theory the current algorithm is based on, and the future work that we aim to accom-plish.

The goal of the navigation algorithm is to sail an autonomous boat between a series of waypoints(our target latitude longitude coordinates). In order to accomplish this, the boat must be able togo upwind, downwind, recognize when it has hit a waypoint, and turn. In the past, we attemptedto use a finite state machine to solve this problem. This approach had a series of states (suchas "tack left", "head upwind to the right", "head directly to the waypoint"... ). For each state,there were triggers to transition to different states (for example, when the state is tack left, if theboat is facing directly towards the next waypoint, "stop turning" and transition to the state "headdirectly to the waypoint"). While this approach worked in a two-dimensional simulator, when theboat was placed in the water, there were too many variables such as constantly changing boatorientation and wind direction, that were unaccounted for in the transition model of the finitestate machine.

To remedy this issue, we changed our approach from a finite state machine to a solely positionbased algorithm. In this approach, we aimed to have the only determinants of position be theboats position, the wind direction, and the location of the next waypoint. This eliminated a lot ofthe variables that were introduced by a state machine, and so would be able to get the best sailand tail angle at any position, regardless of past behavior.

Overall, our algorithm is:

1. Check if the boat has hit a waypoint

2. If so, head to the next waypoint

3. If not, find the intended angle the boat should be sailing at

4. Set the sail and tail of the boat according to the intended angle

We aimed to take advantage of the directional stability of the boat in order to sail accordingto these steps, diagrammed in Figure 12. To accomplish step four in the overall algorithm, wecreated functions that set intended angle of the boat, named for their intended angle with respectto (WRT) the wind: upRight, upLeft, rightTarget, leftTarget, downLeft, and downRight. Thenwith this intended angle, we set the sail and tail of the wind according to the offset of the intendedangle to the boat orientation.

12

Figure 12: The algorithm steps taken.

In order to call these functions, we determine which sector of the navigation diagram (picturedin figure 13) the boat is in. Depending on what the angle to the waypoint is, we select a sector.For example, if the waypoint is directly upwind, the angle to the waypoint would be 0 WRT thewind. If the boat is facing right, we would look in the first circle below. Because the angle tothe waypoint is 0, which falls in sector 0, we would call the upRight function, and would set theintended angle to be upRight of the wind.

Figure 13: The directions that we sail depending on where the boat is in relation to the wind andthe waypoint.

These different sectors select an intended angle, and a sail angle of attack (AoA), according toTable 2:

13

Sector Intended Angle WRT North Sail AoA WRT North

Upwind Right WindDir + Optpolartop PositiveUpwind Left WindDir - Optpolartop Negative

Downwind Right WindDir + 180 - Optpolarbot PositiveDownwind Left WindDir + 180 + Optpolartop Negative

Left to Waypoint AngletoWaypoint NegativeRight to Waypoint AngletoWaypoint Positive

Table 2: Where WindDir is the angle of the wind WRT North, Optpolartop is the optimal upwindangle, Optpolarbot is the optimal downwind angle, AngletoWaypoint is the angle to the waypointWRT North

All of our functions that set the sail and tail rely on the same basic structure. At any time, theboat has an intended angle that it is trying to course correct to sail at. The goal is to set thesail and to tail at the angle that they would be at if the boat was heading in the direction of theintended angle. To accomplish this, first, it calculates the difference (Offset) between the currentboat direction, and the intended angle that the boat should be sailing at. This offset can be positiveor negative, depending on whether the intended angle is clockwise or counterclockwise from thecurrent boat orientation. The offset is then added to the wind direction to get the tail angle, thenthe sail AoA determined from the function called (positive or negative) is added to the tail angle.This produces a sail and tail angle that match the intended angle.

In the example below, given the wind direction and angle to the waypoint, we aim to find theintended angle and set the sail and tail accordingly. In the example on the left, the boat orien-tation is to the right of the wind, and the angle to the waypoint is upwind. Because of this, weaim to sail upwind to the right, so we call the function upRight, and get an intended angle ofWindDir+OptPolarTop.

Figure 14: An example of the offset correction to sail upwind.

In the example on the right, we similarly see the boat orientation is to the right of the wind, andthe angle to the waypoint is upwind. Because of this, we aim to sail upwind to the right, so wecall the function upRight, and get an intended angle of WindDir+OptPolarTop.

In both examples, the intended angle is the same. To get the sail and tail angles, we then find thedifference between the boat orientation and the intended angle, and then add this difference to the

14

wind to get the tail angle. Then, because we called the upRight function, the sail AoA is positive,so we add the angle of attack to the tail angle to get the sail angle. In this way, the boat is ableto correct its course, depending on which angle it should be sailing at.

When implemented, this allows the boat to sail upwind, downwind, to the target, and turn. In thesame example above, with the waypoint upwind, the boat would select sector 0 first. As it sailsupwind and to the right, the angle to the waypoint will increase(shown below).

Figure 15: A trace of the boat position when sailing upwind.

As the boat sails upwind to the right, the angle to the waypoint increases. At the last position,where it is 45 degrees, when going into the sector diagram, it will now fall in sector 1, turn. Now,the boat will call the leftTarget function, which will adjust the boats position to sail to the waypointto the left. In this way, the boat will sail upwind, turn left, and hit a waypoint.

This algorithm achieves our basic goals of sailing upwind and downwind, and hitting waypoints.The full code is referenced here on our Github. However, the tasks that still have yet to beimplemented that are necessary for competition are: Buoy rounding, maximum tacking width, andtask-specific algorithms.

To accomplish buoy rounding, we could manually set waypoints around a buoy to simulate round-ing. However, this is not fundamentally correct, and could lead to issues if the boat starts roundinga waypoint but fails. In order to achieve this, we will need to modify our approach to waypointhitting, to instead constantly aim to round a buoy.

Another task that we aim to complete next semester is a function of maximum tacking width.Currently, the algorithm aims to sail to a waypoint in one turn only. While this is usually the mostoptimal route, as turns slow the overall traversal down, it leads to issues when distances becomelarge. For example, when trying to sail up Cayuga lake, one end cannot be reached from the otherin one maneuver. Instead, the code should execute a series of tacks in accordance with the belowexample.

In Figure 16, the boat is trying to sail upwind to the waypoint. Instead of trying to achieve thisin one tack, and possibly hit the shore or an area that we do not want to head, the boat shouldsail with multiple maneuvers to hit the target.

This can be remedied by modifying our current code structure. We will create a line using twoGPS coordinates that represents the center of whatever body of water we are trying to sail across.Then, in the algorithm before checking for waypoints, we will check if the perpendicular distance

15

Figure 16: A trace of the boat position when sailing upwind, making multiple maneuvers to notexceed the maximum tacking width.

from the center line to the current boat position is greater than a threshold we set. If it is, thenthe boat must immediately turn, as it is past the maximum tacking width.

9 Error Analysis

To optimize navigation between waypoints, we introduce a method to calculate how far off theboat is from its current course. The idea is that given two waypoints w0, wf which are pairs oflatitude/longitude values (i.e. wn = (λn, ϕn) where λ is longitude and ϕ is latitude) then we wantto calculate how far away the boat is from where it would be on a linear course from w0 to wf . Thesituation is depicted graphically in Figure 17. This calculation involves determining the distancebetween points of latitude and longitude (e.g. the distance between w0 and wf ). Since we want tobe able to calculate this distance in multiple instances, we develop it separately.

w0

wa

wf

wa

wq

Figure 17: Setup of problem: w0 is starting point, wf is the waypoint, wa iswhere we expect the boat to be, wq is where the boat actually is. We want tocalculate dist (wa, wq)

9.1 Distance Calculation

Given two points of latitude and longitude, one can calculate the great-circle distance between themby applying the haversine formula.1 Alternatively, one can calculate the Euclidean distance by

1The great-circle distance is the shortest distance between points on a sphere, see Figure 18

16

assuming the Earth is locally flat.2 We study both methods by considering their implementations.Currently, the boat uses the haversine formula.

A haversine is by definition expressed as

hav(x) = sin2(x2

).

Using this, we can express the law of haversines in terms of points B,C,D in the figure below.Namely we have

hav(>BD) = hav(

>BC−>

CD) + sin(>BC) sin(

>CD) hav(C)

where C is the angle between>BC and

>CD.

Figure 18: Sphere with Great Circle Distances

This law is derived from the law of cosines for spheres:

cos(>BD) = cos(

>BC) cos(

>CD) + sin(

>BC) sin(

>CD) cos(C)

using cos(>BC − b) = cos(

>BC) cos(

>CD) + sin(

>BC) sin(

>CD) and the relation cos(x) = 1 − 2 hav(x).

Hence the haversine formula is the case where we make the point B the north pole and D,C arethe points of interest. Thus we have

d = 2r arcsin(√

hav(ϕ2 − ϕ1) + cos(ϕ1) cos(ϕ2) hav(λ2 − λ1))

= 2r arcsin

(√sin2

(ϕ2 − ϕ1

2

)+ cos(ϕ1) cos(ϕ2) sin

2

(λ2 − λ1

2

))

where

• d is distance

• r is earth’s radius

• ϕ1, ϕ2 are latitude values2The Euclidian distance is the lengh between points in a plane

17

• λ1, λ2 are longitude values.

This is the haversine formula that we implement in our method for the boat.3

Alternatively, if we assume that we are dealing with a flat surface (rather than a section of asphere), then we can use right triangle trigonometry to calculate the distance between ϕ1, λ1 andϕ2, λ2. Specifically, let θm = |ϕ1 − ϕ2| and θo = |λ1 − λ2|. Then, the distance between the pointsis

d = r

√θ2m cos2

(λ1 + λ2

2

)+ θ2o

We compare these two methods at three different distances (approximately): 250 kilometers at theequator, 1 kilometer across Cayuga lake, and 0.08652 kilometers across the engineering quad.

H (km) D (km) H Error (%) D Error (%)

250.33 km (equator) 250.33 250.342 0.0 < 0.0050.995833 km (Cayuga lake) 0.995833 0.995833 0.0 0.00.08667 km (Quad) 0.0866682 0.0866682 0.0 0.0

In the table, H represents haversine distances and D represents Euclidian distances. Note thatfor small distances the two methods give virtually the same results. However, in general, as thedistances increase, so does the resulting error (but not by much, as evidenced by the error at theequator). Moreover, it is apparent that for the distances in the sailing competition (which are lessthan 1 kilometer), either method would suffice.

9.2 Course Error

Now that we have established the distance calculation between two location points, we can calculatehow far off the sailboat is from its expected course. The first step in making this calculation isestablishing the expected course between two points. Since our objective is to get the averageerror, we assume a linear trajectory between the start point and the end waypoint. Furthermore,we assume a constant velocity v. We parametrize the x position of the boat in kilometers by time.To use x as a measure of distance we use the conversion x ≈ 111.32 cos(ϕ). Similarly, we canconvert latitude to kilometers via y ≈ 110.57ϕ where ϕ is the latitude in degrees.4 Now supposethe first point is given by w0 and the waypoint is wf . Assuming that the boat starts at t0 = 0,the final time tf is given by

tf =dist (w0, wf )

v.

So, if we are given a time tq and a corresponding location wq = (λq, ϕq) (see Figure 17), we cancalculate how far off course the boat is by

dist(wq, wa)

where wa = (λa, ϕa) is the predicted location. It is calculated by

xq = x0 +vxtq

where vx is the velocity in the x direction and x is calculated by the aforementioned conversion.Once we calculate xq we can calculate yq via

yq =yf − y0xf − x0

(xq − x0) + y0.

Notice this assumes a linear course from w0 to wf . Now that we have wa, we can calculate theerror as dist(wa, wq).

3found at github.com/apomerenk/CUSail/blob/master/Individual%20Functions%20for%20Arduino%20Code/haversineDistanceCalculator.cpp

4both conversions averaged from https://en.wikipedia.org/wiki/Longitude

18

10 Pixy CMUcam5

The Pixy CMUcam5 (referred to as “Pixy”) is a 4 square inch visual detection system equipped witha dual core processor and is capable of capturing and processing 50 frames per second. It worksby detecting color signatures of objects and reporting the location of the blocks containing thatobjects. The team’s need for Pixy is twofold. First, the sailboat needs to detect and avoid objects.Second, it needs to be able to find objects and sail towards them.5 Both of these functionalitiesare required by the International Robotic Sailing Competition.

Given the object data from Pixy, we can extract the location of the object relative to the frame andreact accordingly (depending on whether we want to avoid the object or sail towards it). Figure 19is a labeled diagram showing the back of the Pixy.6

Figure 19: Back of Pixy

10.1 Setup

Pixy is made to communicate easily with an Arduino microcontroller via the Arduino’s SerialPeripheral Interface (SPI) bus. The makers of Pixy provide a library, Pixy.h, specifically designedfor such communication. With it, one can simply instantiate a Pixy object, then call getBlocks()on that object. This method returns the number of objects Pixy has detected. If there are anyblocks, one can access their properties (location, signature, dimensions of block) by calling theappropriate methods on the Pixy object.7

The first step in setting up Pixy with the Arduino is to create and upload a program using theaforementioned Pixy library. Then, without connecting Pixy to the computer, one connects Pixy’scommunication cable to the SPI bus on the Arduino board. The wires of the communication cableshould lead away from the Arduino’s processing core so that the pins are aligned properly. Thesetup should resemble the setup in Figure 20.

Notice that the Arduino already has power from the computer. To view the output of Pixy, oneopens the Serial Monitor in the Arduino IDE (Crtl + shift + M). If the setup is done correctly,and the default test program8 is used on the Arduino, the output should resemble Figure 21.9 Alsonote that if Pixy is simultaneously connected to the computer it stops communicating with theArduino.

With the current library, Pixy cannot be taught objects programmatically. Instead, one has toeither use the native PixyMon software or teach Pixy in real time. To teach Pixy objects in realtime one can hold down the white button (see Figure 19) and let the LED cycle through colors.The button should be released once the LED turns red. Then one can position the object to be

5For exact specifications of the object detection and search tasks see sailbot.org/6taken from http://cmucam.org/projects/cmucam57The specific methods can be found at http://cmucam.org/projects/cmucam5/wiki/Arduino_API8found at https://github.com/cakoch10/PixyCam/blob/master/test_pixy.ino9found at http://320volt.com/pixy-cmucam5-dijital-kamera-modulu-inceleme

19

Figure 20: Pixy setup

learned by Pixy in front of the lens. The color of the LED should change to that object’s color.Once it does, one can finish by tapping the white button. If it is successful, the LED will flashthen turn off. Pixy can be taught multiple objects by repeating this process. If the process fails atsome point, one can restart by holding the white button. To get optimal results, it is importantto position the object directly in front of the lens and it is also important that the user is not in adark setting.

The PixyMon software can also be used to teach the PixyCam objects. Once the PixyCam istaught an object it can be disconnected from the computer and connected with the Arduino (whilestill remembering the objects it was taught).

Figure 21: Serial Monitor output

10.2 Obstacle avoidance

For obstacle avoidance, we assume Pixy should be avoiding the object with signature 1. Moreover,the algorithm uses the x position of the object exclusively. Specifically, it uses a list of x positionvalues, and it works by comparing the most recent two readings (assuming there are at least twovalues in the list). The main idea behind the algorithm is that if the last two readings show thatthe object has not changed its position relative to the frame of the camera, then the boat is on

20

a collision path. So in this case, the avoidance maneuver is executed. Otherwise, we adjust theboat’s direction so it heads away from the object. The basic structure of the avoidance maneuveris depicted by Algorithm 1.

Algorithm 1 Obstacle avoidance1: procedure UpdateDirection2: r1 ← Most recent reading3: r2 ← Second to last reading4: s← Sail Angle5: t← Tail Angle6: if r1, r2 ̸= 400 then ▷ Check if an object was detected at r1 and r27: d← r1 − r28: r1 ← 2r1/319− 1 ▷ Scale r1 to the range [−1, 1]9: if |d| < 0.1 then ▷ If the object’s x position approximately remained the same

10: if r1 > 0 then11: r1 ← 1− r1 ▷ reverse r1 so that closer to 1 ⇒ closer to center12: else13: r1 ← −1− r114: s← s+ 45r1 ▷ Scale r1 by 45 degrees15: t← t+ 45r116: else if r1 < r2 then ▷ Make a starboard turn17: r1 ← |45r1|18: s← s+ r119: t← t+ r120: else21: r1 ← |45r1|22: s← s− r123: t← t− r1

We make several remarks regarding this algorithm:

• The readings r1, r2 are the x coordinate position of the object at different times

• The value of the readings range from 0 to 319 with a larger value being closer to the rightedge of the frame

• If the reading is 400, then at that particular time, the object was not detected

• Sail angle and tail angle are in degrees

• The sail angle represents the angle of the main sail vane

• The variable d gives the difference between the readings and theoretically it would be 0 ifthe boat is on a collision course

• This algorithm is placed right after the code that updates the sail and tail angles.

The avoidance maneuver essentially works by performing a starboard turn if the object is detectedon the port side of the boat and a port side turn otherwise. These turns are proportional to howfar the objects x position is from the center of the camera frame. In the case that no avoidancemaneuver is needed, we perform a turn that simply moves the boat farther from the object.

10.3 Searching

This part of object detection requires adjusting the direction of the boat so it sails towards a desiredobject. The searching algorithm is similar to Algorithm 1 with a few minor adjustments. First, weonly need one reading since the boat needs to sail towards the detected object . Hence, the mainconditional statement of the searching algorithm determines which half of the frame contains theboat (with respect to the vertical axis). If the object is on the port side, the boat makes a portside turn and vice versa if it is on the starboard side. Moreover, the size of the turn is proportional

21

to the distance from the objects x position to the center of the frame (just as in Algorithm 1). Theimplementations of both of the algorithms are on GitHub.10

10.4 Future Work for Pixy CMUcam5

The current setup with Pixy still needs to be assessed and improved. Testing should determinewhether the sail adjusts correctly according to an object presented to Pixy. Moreover, testingshould first occur in a lab setting then proceed to the lake. After this testing occurs, a caseneeds to be designed for the image processor so that it can be mounted on the boat. We haveinvestigated a number of options for the case design. There are several preexisting CAD files thatcould potentially work.11 Once the case is printed, it can be waterproofed and then fitted on thebow of the boat.

In the long term, we would explore alternative devices for obstacle detection since Pixy is limited inboth functionality and adaptability. The functionality is limited because Pixy can only differentiateobjects based on predefined colors. In the future we would like to detect all objects around theboat not just objects of a certain color. This brings us to another limitation. In the current design,Pixy is fixed at the boat’s bow, facing forward. So we are limited to detecting objects directly infront of the boat. This could be problematic in settings where we are trying to make a tack or jiband want to track an object (such as a buoy) around the turn. Moreover, it is difficult to adaptPixy to any other type of detection since the Arduino library, Pixy.h, provides minimal supportfor the device’s features. One example of the library’s limitation is that it does not allow one toprogrammatically adjust the color of a signature. Instead, this adjustment must be made from thePixyMon software or by manually reprogramming Pixy. Regardless, there are other platforms thatsolve these issues. In the future, we would investigate such platforms including motion detectors,(ultrasonic) laser range finders, and LiDAR and assess each’s potential to replace Pixy.

11 Appendix

11.1 Appendix A

Electronic components and respective page links:

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

2. IMU: YEI 3 Space Embedded Sensorhttps://yostlabs.com/product/3-space-embedded-evaluation-kit/

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

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

5. Sail Servo: HS-785HB by Hitechttps://www.servocity.com/html/hs-785hb_3_5_rotations.html#.VyQlijArKCg

6. Tail Servo: HS-5646WP by Hitechttps://www.servocity.com/html/hs-5646wp_servo.html#.VyQl1DArKCg

7. 3A, 6V/12V Solar Chargerhttp://store.sundancesolar.com/solar-charge-controller-3a-6v-12v/

10https://github.com/apomerenk/CUSail/blob/master/Individual%20Functions%20for%20Arduino%20Code/pixy.cpp

11for example:• http://www.thingiverse.com/thing:820353

• http://www.thingiverse.com/thing:1417326

• https://www.makexyz.com/3d-models/order/b3ea31c2c60b3b008ff23de9d320a331

22

11.2 Appendix B

IMU calibration procedure: Before beginning please ensure you have the latest version of the YEI3-Space Sensor Suite available at this link: https : //old.yostlabs.com/yei− 3− space− sensor −software − suite. Please also ensure you are in an environment with not a lot of magneticinterference (ensuring this is not trivial; one way to check for this is to use a different compassand ensure that it points to North. Of course having a rough idea of which was North is, will behelpful). Also note that the following steps are in reference to the Yost Labs 3-Space EmbeddedSensor referenced in 11.1.

1. Ensure the two jumpers on the top left and right are set to position 1 and the power-switch(above the right jumper) is off

2. Connect the sensor to your computer using the USB Mini port and turn the sensor on

3. Start the YEI 3-Space Sensor Suite, select the 3-Space Sensor from the list of connecteddevices (If the sensor does not show up, click Refresh) and click Connect

4. Once connected, run the Gradient Descent Calibration through the top menu and followthe steps.

5. Once completed, make sure to Save/Commit these settings before disconnecting the sensorfrom the PC.

23