CubieTruck Chartplotter Setup

As I did with the Raspberry Pi, below is a complete set of instructions to set up the CubieTruck as a dedicated OpenCPN chartplotter:

20141004_102259

Base Operating System

  • Download the latest Cubian OS image from Cubian.org
  • Write the image to a micro SD card (I used a 32 gig card) I used Win32DiskImager on my Widows machine
  • Insert SD card into the CubieTruck, connect HDMI monitor, Keyboard, and mouse, and boot.
  • Login as cubie/cubie
  • Setup Wifi
    • sudo modprobe bcmdhd
    • edit /etc/modules and add bcmdhd module so that WiFi will be available on reboot
  • apt-get update
  • apt-get upgrade
  • Install cubian-update
    • The deb command was already in /etc/apt/sources.list so that step could be skipped
  • Turn off the screensaver
    • apt-get remove xscreensaver
  • Auto-Login to the system
    • create a new user and grant them sudo access
      • I can’t understand vi (Hey, I’m a Windows guy), so I used nano to update visudo:
        • su root
        • export VISUAL=nano; visudo
    • edit /etc/lightdm/lightdm.conf and add:
      • autologin-user={new user}
      • autologin-user-timeout=0
    • In a terminal run:
      • sudo groupadd autologin
      • sudo gpasswd -a {user} autologin
  • Install Hardware acceleration
    • apt-get install mesa-utils build-essential git cmake libx11-dev
    • install a user version of libGL from source
    • install libGLU from source
    • set the LD_LIBRARY_PATH environment variable to use usr/local/lib
      • edit ~/.bashrc file
        • add export LD_LIBRARY_PATH=/usr/local/lib
    • Verify with glxgears
      • over 100 FPS and a minimum of CPU usage

Setup OpenCPN

  • Build and install OpenCPN
    • $ git clone git://github.com/OpenCPN/OpenCPN.git
    • $ cd OpenCPN/
    • $ mkdir build
    • $ cd build
    • $ cmake ../
    • $ make
    • $ sudo make install
  • Download the appropriate charts
    • For all US waters, it’s very easy to find appropriate charts at NOAA
    • I decided to try ENC vector charts this time. On the Raspberry Pi the rendering was just simply too slow and I used Raster charts.
    • Expand into an appropriate directory. I used /usr/local/include/Charts
    • run opencpn with the -unit_test_1 flag to ingest and process all the charts that were downloaded
  • Restart the gpsd service
    • sudo killall gpsd
    • sudo gpsd -n -D 2 /dev/ttyUSB0
    • Note: cubian auto-starts the gpsd service on a restart
  • Launch OpenCPN
  • Set the charts directory to the directory you expanded your charts into
  • Add a connection for the gpsd service
    • Settings -> Connections -> Add Connection
      • Network
      • GPSD protocol
      • localhost address
      • 2947 port

At this point, in one weekend day, I had a complete chartplotter solution running on a CubieTruck:
20141005_175023

Resources

CubieTruck Upgrade to CPN Pilot

I love the Raspberry Pi. I really do.

I have three of them, and will probably purchase more. As a movie player (XBMC), or low powered (battery) computer, it really is great. And the price cannot be beat. Also, if you simply want a cheap integrated chartplotter, the Raspberry Pi is by far the most cost-effective platform. It also has the best community support.

However, for the autopilot/chartplotter project, I actually am running into limitations with it’s processing power. For example, when testing AIS functionality, the CPU was pretty much maxed out when running the services as well as OpenCPN — so much so that the entire UI would hang for a few seconds.

After researching the different inexpensive, low-powered, single-board computers, I decided to go with CubieBoard. Specifically the CubieBoard3, aka CubieTruck. It has a DualCore 1Ghz A7 SOC processor, 2Gigs of RAM, 4Gigs of NAND flash memory for an OS as well as micro SD, built in WiFi and Bluetooth, and most importantly a graphical processor that complies with OpenGL ES 2.0/1.1 so the graphics can be offloaded from the CPU. It should be more than capable for my needs in this project, especially since I still consider the performance of the Raspberry Pi to be sufficient.

It does come at a cost — It’s about twice the price of a Raspberry Pi, it consumes about 1.5 times the energy (2 amps at 5v), and is about twice the size physically:

RPI and CT

AIS on the CPN Pi-lot project

First of all, what is AIS?

Automatic Identification System, or AIS for short, is a system for automatically displaying location, tracks and information about ships (and other large vessels) It works automatically, transmitting the data over standard VHF frequencies. The information provided is then generally rendered by a chartplotter or other software.

There are some very interesting websites on the web that display AIS information in near realtime. MarineTraffic.com is one of my favorites.

I wanted to add the capability to receive real-time AIS information and display it on the CPN Pi-lot project I’ve been building. Fortunately, once again, the hard work and research has already been performed by other people across the world. They have discovered that USB software defined radio dongles (SDR-RTL) have the capability to extract AIS information using cheap and readily-available hardware and software.

I recently purchased a usb dongle from Amazon that was listed to work with SDR-RTL, and wanted to see if I could get any usable data out of it.

AIS on the Raspberry Pi

I followed the instructions on a few different blogs and forums. The following is the steps I performed to get AIS around all the small gotchas:

sudo apt-get install git-core
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0-dev
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
sudo ldconfig
cd ~
sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
sudo reboot
rtl_test -t

At this point, the rtl_test program displayed the following error:

Kernel driver is active, or device is claimed by second instance of librtlsdr.
In the first case, please either detach or blacklist the kernel module
(dvb_usb_rtl28xxu), or enable automatic detaching at compile time.
usb_claim_interface error -6
Failed to open rtlsdr device #0.

To resolve it, I needed to edit the /etc/modprobe.d/raspi-blacklist.conf file, by adding the following lines:

blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830

After a reboot, the rtl_test program confirmed that I was receiving samples from the USB dongle.

The next step was to install an AIS receiver:

sudo  apt-get  install  libasound-dev  libpulse-dev
wget  http://www.aishub.net/downloads/aisdecoder.tar.gz
tar  zxvf  aisdecoder.tar.gz
cd  aisdecoder
mkdir  build
cd  build
cmake  ../ -DCMAKE_BUILD_TYPE=Release
make

Then, open up two terminal windows. In the first terminal, type:

mkfifo /tmp/aisdata
rtl_fm -f 161975000 -g 40 -p 95 -s 48k -r 48k /tmp/aisdata

and in the second termnial, type:

./aisdecoder -h 127.0.0.1 -p 10110 -a file -c mono -d -l -f /tmp/aisdata

At this point, it appears I’m getting data flowing through, as I see the following:

Level on ch 0: 50 %
Level on ch 0: 50 %
Level on ch 0: 50 %
.
.
.

Since I am currently at home, and not within range of any ships that should be broadcasting AIS, I believe this is a success. However, I will need to bring all this gear down to the boat, test it there (where I know there are AIS signals) to confirm.

References

New TV Mounted

We watch a lot of TV aboard our boat. Quite often we will go down to the boat just to watch a Seahawks or Sounders game outside of the house. And most of the time when we are working on a project, we will throw a movie up on the screen. Or take a nap.

IMG_20120513_160637

 

We had a nice LCD TV that we just put in the aft, right next to the sliding door entry. This was not the best spot on the boat for a TV for viewing, as none of the seats in the boat were able to comfortably see it. Plus it had a tendency to fall over in rough water;  recently it got knocked off the shelf, and the screen cracked.

Taking the opportunity to upgrade, we decided to get a bigger TV, mount it, and move it to a more visible location.

Recently we purchased a Samsung TV from Costco, and an under cabinet mount. Then we spent a few hours installing it — a very straightforward process of drilling holes, and running bolts backed with big washers through the ceiling. The mount has a very secure latch on it when it is stored up and out of the way.

Up:

20140731_201921

And down:

20140731_201856

We haven’t done any electrical work for it yet, but eventually this will be the display for the Chartplotter/Autopilot project too. The Raspberry Pi will be stored up and out of the way in the open area above, with just the HDMI cable coming down and attaching to the tv. I also want to run an inverter powered 110v outlet for the TV to plug into as well.

But for now, the power cable can hang down and connect to the current inverter that is located to port, and the TV is perfectly usable.

Sometimes It’s the Little Things

Not every boat improvement project needs to involve large purchases, multiple trips to the hardware store, and days of work.

No, really. They don’t. I even did a couple this weekend:

  • Moved the Magma grill from the cockpit to the flybridge. This uncluttered the starboard side of the cockpit which is where we board and disembark at our home slip.
  • Moved the PVC storage rack from the cockpit to the flybridge. We moved all the supplies that were stored in it (fuel stick gauge, deck brush) into the stern storage compartment, and turned the rack into a DIY rocket-launcher
  • Added pole holders to the cockpit stern railing. We now have three holders — port, starboard, and center. In theory we could set up three rigs for trolling with divers
  • Added cut up sections of an old hose as chafe protection on our bow lines.
  • Swapped the fender racks from inboard to outboard. At the cost of a theoretical increase in risk of losing a fender, we gained much better traffic flow to the foredeck and back. Plus we have plans to install permanent fenders and docklines at our home slip, so it wouldn’t be the worst thing to clip/tie/attach the fenders in the racks to the railing for more secure storage.
    20140720_190512

 

I make Fire! Again!

As mentioned in I make Fire (the first time), the propane system we inherited when we purchased our boat was old, corroded, and out of compliance with the most recent regulations.

The existing Magic Chef range and oven, while it worked in that it produced a good flame, did not have a propane thermocouple. This little safety device is designed to shut down the flow of propane in the event that the flame is extinguished for some reason. So for the past year, whenever we used it, we had to be careful that the flame didn’t blow out and fill the cabin with explosive propane gas. In short, it needed to be replaced.

20140525_142236 20140525_142218

Unfortunately, marine stoves and ranges cost over $1000, even online, so we decided to go with an RV model at less than a third the cost. It has 3 cooktop burners, an oven/broiler, and yes, a thermocouple. It also has a piezo-ignition so that we don’t need to light from a match or lighter, just click the button.

This weekend we installed it.  After removing the old stove, we cleaned the recessed area, cut away and pulled out the old corroded copper lines, and ran a brand new LPG rubber hose from the tank outside to the appliance.

20140525_143124 20140525_171053

The next step was to install the new range. Of course no boat project can go completely smoothly, and in this case the range that was shipped to us was the larger model than the one we had ordered. It didn’t fit into the cutout by 1/4″. So I had to use a router and cut away a bit of the wall. After that, the range slid into place perfectly.

20140601_182206

The last step was to connect the propane hose to the T in the cockpit, turn on the valve and solenoid, drain the air from the line (just a few seconds), and test:

20140601_182032 20140601_182053

Fire hot. Fire good.

 

 

 

 

 

OpenCPN Chartplotter Software Plugins

The Chartplotter functionality of my off-season project is complete, due to the fact that the OpenCPN software package is, for the most part, a turn-key solution that had all the necessary features already included. It is a remarkable solution. I prefer the Raspberry Pi platform, for a low-powered dedicated device, but on a small laptop or dedicated PC, it is even faster and extremely effective.

However, like any piece of software, it doesn’t have every feature that every user desires. So they also have a plugin mechanism that allows a user to build their own extensions to the base system, and create those features themselves.

I have done exactly this during the winter, writing a pair of plugins that I think enhance product and make it even more perfectly suited to my particular desires.

Remembrancer

The first plugin is Remembrancer. Remembrancer is a mostly-made-up word that describes the notion that it is used as a reminder. The concept is simple. All it does is bring up an alert box, and play a sound, after a configured length of time.

The idea is that on a long route, with the autopilot steering, the helmsman may become distracted or forgetful, and this plugin will force him/her to remember to do a safety sweep of the water, route, and equipment. The time delay is fully configurable, as is the sound that is played.

Remembrancer

The source files for the plugin can be found on GitHub.

NOAA Doppler

The second plugin, NOAA Doppler, is much more involved. Quite often while cruising we just want to know where it’s raining, so we jump online or on our phone, and view one of the many apps that show the current weather map. This plugin is designed to incorporate that feature into OpenCPN, and renders doppler radar imagery directly over the chart.

NOAA provides free images of the current radar returns for all domestic ground stations. If you live in the United States and know your station ID (Seattle area is ATX (Everett), you can find the live reflectivity, storm velocity, precipitation, and other readings. They also provide a GIS “world file”. The values in this file can then be used to calculate the projection.

I also added a blur factor to the image before rendering, so that the blockiness is reduced. It works fairly well.

Weather Out

Weather In

However, the NOAA Doppler plugin is still not complete:

  • The rendering works, though there are bugs with OpenGL’s transparency
  • The blur feature works perfectly
  • The overlay is correctly positioned, and matches up with NOAA’s own rendering as well as Google Earth
  • It does not download live images, and instead only uses the image previously stored
  • The world file values are hard-coded and don’t change when the stations change

The source files can also be found on GitHub

Resources