Wednesday, April 29, 2015

Crowdfunding Cast Episode 138 “Quadmaran”

Crowdfunding Cast interviewd me (Vince) for their podcast.   I like how the interview came out.   You can hear it here.

Crocus Bay Apr 29, 2015

We took the boat out today to see if it would finally go longer than 30 minutes autonomously. However, it was 4:30 pm when we got to the beach.   The course would be just going back and forth between two points along the East side of the bay.

 After we carried everything to the beach and sent the boat off we then focused on getting smoothies before the beach restaurant closed at 5 pm, as last time we wanted to get them but missed out. After we started to drink we looked up and the boat was on the rocks to the East. Took the kayak out to rescue it and it seemed ok, so let it go on but followed it. Out from the beach there was a strong breeze from the South. The boat has more trouble turning left and with the wind blowing on the back of the boat it did not make the turn to the North.

 Again at about 30 minutes we had trouble. This time the motors had less and less power, and then the side LEDs did not even go on when the motors were turning. These side LEDs (with red and green filters on them) are on the same relay as the motor on their side. So the only thing that made any sense was that the voltage was too low for them to go on. When we got home we checked the main battery voltage and it was a bit under 10 volts. So this late in the day with some clouds the solar was not charging the battery nearly as fast as we were using the power.

There is no school Friday so we hope to be able to launch then closer to mid day.

EPS Foam can take on water

We took off 2 lbs when we took of the water break.   But the boat did not really seem to ride any higher.  We wondered if the foam might be taking on some water.

The floats are EPS foam.   I had read that it was closed cell but checking further it turns out there is more to it.   It is really a bunch of closed cells stuck together with open air gaps between them.   So it seems we did not really use the ideal foam for the floats.  There have been cracks between the wood and the foam, between the driveshaft and the foam, and so water could get into the foam.

We did a test last night to see how bad this is.  We cut out a big piece of EPS foam, put it in a 5 gallon bucket with a sledge hammer to hold it down and filled it with water.  Then left it overnight (like 10 pm to 7 am).

We put a piece of Saran Wrap over our digital scale so water would not get to it.

After cut and dust off:  53 grams
Put under water and then shake off:  65 grams
After soaking all night:  170 grams.

So it does take on water.  Around 105 grams overnight. 

This is not the ideal foam for crossing the Atlantic.   We are probably ok going to St Marten and back though.

Testing All Night

We changed the Bluetooth code, connected a 12 volt battery charger to our main battery and ran all night.   It was just turning the light on and off (note glow at one corner of solar panel).  But to do this our code has to keep running and the bluetooth has to keep working.    It did, so we hope that next time it goes in the water it will not have trouble at the 30 minute mark.

Monday, April 27, 2015

Crocus Bay Run Apr 27, 2015

 Note you can click the red dots above to get the status info at that time clock.

We took off the water break and programmed the boat to turn sideways to the wind instead when it is supposed to minimize drift, like during the night.   It is really turning 90 degrees to a line going to a point where it started this ParkBoat command.  We tested this today and it kind of worked.  It was doing this at the bottom left between clocks about 5000 and 7000 (300 seconds or 5 minutes).  But the wind drag on the back of the boat is much more than the front so it still has to use a lot of battery to stay sideways. The second boat, the orange one, will not have so much unbalanced drag.

It also did the ParkBoat between the first and second loop near the beach.   This was only for 1 minute or 3 of the 20 second status reports.  These would have been reports where motors were not on the full 200 clock ticks, so seem to be 13433, 13533.  This is out from the beach a ways after one loop.

The hope is that a more balanced boat will not need to use the motors too often to stay sideways to the wind and so be able to get through the night using minimal battery and still not drift too much.  Getting rid of the water break saves about 2 lbs, so it will be nice if we can get this to work reasonably well.

This time the phone was charging from the main battery and we set the developer option for the phone not to sleep as long as it was charging.  So it did not go off after 30 minutes like last time.  However, the bluetooth connection failed after 30 minutes, so instead of making the 90 degree corner like the first pass it drifted up and to the left.  Then we paddled out and towed it in and that is the line in the top right.

The boat has a measure of its own health.   It can tell if it is turning the way it wants to or going forward when it wants to.  As it drifted off course the health measure went negative.  We will probably change the software to reconnect to the bluetooth when its measure of health is negative.

Wednesday, April 15, 2015

Java App Features

There are several things that we really want to do that just can't be done in App Inventor.   We will make a Java app that we can call from App Inventor to do these.   The list of functions is below.  If someone has some function they would like to use from App Inventor,  please let me know!   We want to make our Java app useful when making all kinds of bluetooth toys into robots using an Android phone and App Inventor.

  1. Get battery charge level and temperature
  2. Turn on and off the LED on the phone
  3. Use camera without any operator help (both front and back, and different resolutions, save to file)
  4. OCR (will just specify color range for letters, return text)
  5. Computer vision (where is the Red blob, which way to yellow ball, return X,Y and number of pixels)
  6. Get distance camera autofocus reports

This app we will probably sell on Play Store for $10.  It could be nice for anyone using App Inventor. 

Possible Additions

Some other things that we might want to add to this Java app:
  1. Access/control GoPro camera.  There is a GoProJavaApi.
  2. Measure sonar distance using phone speaker and microphone 

Demo of App Inventor with Vision

We will do a project or two where we use an Android phone, App Inventor, our Java app, and some toy to do something fund with robot vision.
  1.  Lots of bluetooth toys
  2. More bluetooth toys
  3.  Deskpets - like $28 for a cute little toy with tank treds - also shooting tank
  4.    Sphero - ball rolls around based on commands - with vision could be fun LED glow should make it easy for vision to identify ball
  5.    Robot arm
  6.    A toy car
  7.    Toy Truck

Tuesday, April 7, 2015

Computer Vision

We would like to be able to use computer vision to do the following:

  1. Obstacle avoidance - recognize seaweed or other things and not hit them
  2. Autonomously link together with another boat out in the ocean
  3. See when a fish was making the fishing pole bend
  4. Have the boat come right up to a dock so it was easy to retrieve
  5. See where the coast is or where waves are breaking over a reef 
  6. See a which way a bit of yarn was blowing to know wind direction
  7. See if there are whitecaps so can turn into them to not to tip over 
  8. read main battery voltage from sensor LED lights(OCR)

These are enough reasons to figure out how to use computer vision software and we will probably come up with more over time.  The phone has a 2 cameras, so there is no extra cost.  The one aiming backward can look at a fishing pole.  The one forward can see where the boat should go.

The phone also has a light, so computer vision could work even at night.

OpenCV software for Computer Vision

openCV - Open Source Computer Vision - Seems to be the most popular and runs on Android, Windows, and Ubuntu.   Documentation online.   We have started playing with this.  We can compile sample vision apps with Android Studio and load onto our phone.  Modifying them to do what we want does not seem too hard.

     Using a $50 robot arm and OpenCV
       An example of using OpenCV and phone for a robot.
 Some videos for learning about CV in general and openCV 
  1. Tutorial: Real-Time Object Tracking Using OpenCV 
  2. Finger drawing - with OpenCV
  3. Brush drawing - with OpenCV
  4. OpenCV Tutorial: Multiple Object Tracking in Real Time (1/3)
  5. Lecture 01 Introduction to Computer Vision
  6. Real Time Object Recognition using SURF and OpenCV EEL6562
    Some books on CV
    Tesseract OCR - open source
    1. Open source and sponsored/hosted at Google.
    2. Sample Java/Android code
    3. More complete example for Android
    4. Also OCR apps on play store - may be able to just call one but...

    Thoughts on Boat Linkup

    With GPS one boat can get near the other boat but for the last 50 feet of the approach we probably want to use the camera.  

    We are planning to use powerful magnets on a flexible thing so that docking has a little margin for error.    But this is only like an inch in each direction.

    If we get near the waves will make for some up and down motion, so this should match up given a bit of time.

    The boats both have compasses.  They could talk to each other with bluetooth, wifi, SMS, or G3 Internet.   So one can point into the wind and tell the other what GPS coordinates it is at and what heading and speed (slow or stop) it will be at.  

    Could have just the CV in Java and the rest of the code still in App Inventor.  There is no need to pass images back and forth so communication is not a problem.

    Ordered Parts for Second Robot Quadmaran-5 / Similitude of boat models

    Ordered parts for second Quadmaran-5

    We raised enough money already from our Indigogo crowdfunding campaign to order the parts to make the second Quadmaran-5 robot so I did so today.  They will come by boat so 2 to 4 weeks probably.

    I can't wait to be able to have two of these motoring around in train formation.

    Models and Similitude

    People should know that boat models show you what a larger boat would do in waves.   All you have to do is shoot a video and then slow it down by the square root of the scaling factor.  Our Quadmaran-5 is 1:16 scale model for a Quadmaran-80.   So if we slow the video of the Quadmaran-5 down by a factor of 4 we can see what a Quadmaran-80 would look like in waves 16 times larger than in the test.    This is called Similitude.   Most people use expensive wave tanks to test out engineering models of boats.   We are using real waves.  

    Our approach is much cheaper.  However, we don't get to turn a dial on a machine to pick the wave heights we want.   In Anguilla getting an interesting size wave is not too much trouble because we have many different harbors with different size waves on different days.   The biggest trouble with our approach is that the winds are usually far too strong for the scale we are at.   Inside a building with a wave tank they don't have any wind issue.

    Sunday, April 5, 2015

    Ease of App Inventor Coding

    Using App Inventor 2 to write apps for a phone is so easy an 11 year old or 13 year old can do it (see video above).   You do not need to install and setup some big development environment.   It is mostly done on a web page.  The steps are:
    1. On your phone or tablet go to Play Store and download "App Inventor 2 Companion".  This app will download and install your app when you point the camera at a 2D bar code later.
    2. On your desktop computer go to   
    3. You first make a user interface by grabbing things like buttons and dropping them on the image of a phone.
    4. Then you click on "blocks" (top right) and you write the code.  For each user interface thing there are things you can get, like if the Button is called "Forward" you can get a "" that will run when the button is clicked.  Then you put whatever code you want in there.   To write your code you drag and drop things that then snap together.    So you click on "control" and drag an "if then else", then click on procedures and get a "Call Forward", etc.   Unlike most computer languages, it really helps prevent you from making lots of kinds of mistakes.  It is really fun to use.
    5. When you want to test the code you click "Build" near the top.  Then run app inventor companion on your phone/tablet and click "scan QR code" and point it at the 2D barcode that will show up on the screen.  It will then download the code and ask if you want to install it, then open it.   It will also be a regular app on your phone that you can run later.

    In the image above you can see the block for HornOff.Click which is what is called when you touch the "Horn Off" button in the Manual Mode in our app.  This then calls the function "HornOff" which sends a "q" by bluetooth to the relay controller.  This is the code for turning off the relay that the horn is using.

    The Forward code sends "ef" to the relay controller, which turns on the two relays for the two motors.

    Above is the code that does the Morse code.  First it divides down the regular clock, only doing something every MorseCodeClockDivider ticks of the regular clock.  Then it reads out from a string if it is supposed to be on or off at this time.  Then it turns the horn or light on or off.

     Above is the code that decides if the boat should turn left, turn right, go forward, or stop.  Do a "right click" and then "view image" to make it a bit larger so you can read everything.  There are 3 main types of boat movement this has to handle.
    1. GoTo - where the boat is trying to get to some GPS coordinate. 
    2. ParkBoat - where the boat wants to stay near some GPS coordinate
    3. AimBoat - where the boat is trying to point at some location (for horn or light to reach someone)
    This is the most complicated part of the code and it did require some walking around with the phone to test and debug before it all worked right.

    I think that if one person on your project has computer programming experience then using App Inventor will be fine for everyone.   It was my 2 older boys first experience programming computers and I think it is a great way to start.   If you use our code you will be able to do all kinds of things without changing any code.  We will document our "Robot command language" in a future post.

    Early on any of our computers were fine for App Inventor.   As our code got larger it got slower to move around the screen on our older computers.  Eventually it got too painful on most of our computers.   Now we only work on our main app using our fastest computer.  This is the lowest end Dell gaming computer (Alienware) as of January 2015.  On this computer editing is still very fast.  This computer also has a 32 inch screen, which really helps for this graphical programming method.   These huge screens are down to like $150.  They are so nice I think all computers should have them.

    Saturday, April 4, 2015

    Phone charging from boat main battery

    The biggest problem we had on the last run was the phone going to sleep after 30 minutes.   We found a developer option that makes the phone not go to sleep as long as it is charging.   Getting the phone charging then became top priority. 

    We cut the charging cord for the phone.  Drilled a hole the size of the cord in the side of the small container.   Put the cord through and tied a knot on each side of the hole.  Then put Gorilla Glue on each side.   It does not really stick to the container well.

    Before doing this I thought, will have to put my phone on the boat to charge, kind of fun.  After I thought, I will really need to get another cord to be able to connect the phone to the computer and get data/pictures off.

    Wired up the red and black wires from the cord to wires that I had previously put through the PVC elbow into the main container.  Wired the red and black from the other end of the cord to the other ends of these.  Plugged it into the 12 V USB charger.
     Sure enough, the phone started charging.  Since it is now hooked into the main battery, which charges from solar, the phone should now be fine as long as the sun is out.   If the motors and lights are turned off, the main battery should have no trouble keeping the phone charging through the night.  With the sea brake it may even be ok for the phone to go to sleep at night, as long as it wakes up when the sun comes up and it is getting charged again. Not doing overnight tests just yet though.

    Put the solar panel back on and we are ready to try for longer than 30 minute runs.

    Thursday, April 2, 2015

    Day at the Beach

    School got out early today so we went to the beach.  Set the boat in with instructions to go out 600 feet, come back, toot the horn, send some Morse code with the light (can do horn but it is so loud) and then loop and do it again.  Things went perfect for about a half hour then it acted up.   Only then we remembered that there is a problem where the phone powers down the screen and the bluetooth after a half hour.  We could not see any way to set it longer.  Once it does this, even though our software is running it can no longer talk to the relay controller.  So we touched the screen and sent it out again but took it in about a half hour later.

    The current software only bothers to turn if it is aimed more than 15 degrees off target.  So it can be far off the centerline in the middle.  We could use more than 2 waypoints to make it stay closer to a fixed path.

    We ended up using different types of couplers between the motor and the driveshaft on the left and right.  One seems to lose a lot of power.  So the other side has to be off much of the time to keep going straight.   Will get more of the good couplings in the next 2 weeks.  Once this problem is fixed it should go a bit faster.
    Boat is in far right near the top

    Someone had to go check it out

    Boat right is green, here boat left red is on. Shows that side motor is on.  The new purple foam on the front is in case we run into something.  Did not have any such trouble today.

    We will still be at Roys for awhile longer.   If you get here before we leave we can give you a demo.

    Data and Results

    The data from this run that is logged to Google in real time is available here and the map with data in clickable points is here.  Note there were a couple bad tracks after the tracks at the top were posted.  One time when it was far out it kept going.  It seems the wind out there was strong enough it was having trouble turning.   There was one track near shore where it went under the dock.  This was when the phone went to sleep.

    Note clock ticks are 100 ms, so 10 ticks per second.   Status reports are 20 seconds apart, so there should be 200 clock ticks between reports.

    There is some more stuff logged to the phone but mostly to help figure out what went wrong if something goes wrong.  Also have more detailed GPS data logged to the phone.

    If I look at the data from clock 9678 to 12278, which is 260 seconds I calculate it covered 0.12 miles.  This is 1.66 MPH.   That was coming into the wind.

    If I look at the data from clock 14478 to 16278 I calculate 506 feet in 180 seconds or 1.9 MPH.  That is going downwind.

    These were good parts (no turns or stopping to send Morse code).  So an average of about 1.8 MPH in good parts.  Not bad.

    From clock 12478 to 13278 it was not using the motors.  During this 80 seconds it drifted 50 feet.  This is 0.4 MPH with waterbreak on.  There are other times it moved much less while the motors were off, though there might have been a human holding it for a bit.

    So if it can go 1.8 MPH during the day and only drift 0.4 MPH at night, it can make progress even into the wind.  :-)  At least on days like this were it was not too windy.

    Fix to 30 minute sleep problem

    Update:   There is an Android developer option to "Stay Awake" while charging.   We have now set this option and will connect the phone to the USB power before launching again.  This should fix our 30 minute limit problem.