Skip to content

rhiniodontypus/trackmyvessel

Repository files navigation

trackmyvessel (TMV)

1. Introduction

trackmyvessel (TMV) is a tool to receive and decode a live feed of AIS AIVDM signals from ships.

It allows to define a personal list of ships and to track them. It also allows to define certain regions, so that when the ship reaches or leaves the region, an information e-mail is sent.

The program accepts an AIVDM data stream on UDP port 10110 and evaluates each incoming packet individually, compares it with the information from the database and initiates an e-mail dispatch if applicable.

Please be aware that this software is not intended for safety-critical applications, but for hobby use only. I disclaim all responsibility for any damage caused by the use of this software.

2. Setting up the virtual environment for Ruby with Rbenv

  1. Installing Rbenv (Installation Guide)

for MacOS

brew install rbenv ruby-build

for Debian, Ubuntu and derivatives

sudo apt install rbenv
  1. Learn how to init
rbenv init
  1. Close your Terminal window and open a new one so your changes take effect.

  2. Install a Ruby version ~> 2.0

rbenv install 2.7.4
  1. Switch to your local repository and set your local Ruby version.
rbenv local 2.7.4
  1. Install bundler for installing ruby gems
gem install bundler
  1. Specify the local gem installation directory: In the root of your project directory, create a file named .bundle/config (create the .bundle directory if it doesn't exist) and add the following content:
mkdir .bundle/
nano .bundle/config
--- 
BUNDLE_PATH: "vendor/bundle"
  1. Now you can install the Gemfile
bundle install

If this fails make sure you have installed the developmental libraries:

sudo apt-get install ruby-dev
sudo apt install libmariadb-dev-compat libmariadb-dev
  1. Activate the gem environment:
rbenv rehash

This will update the rbenv shims to include the locally installed gems.

3. Creating the database

I use the MariaDB database.

1a. MacOs

brew install mariadb

and activate it (after each reboot)

mysql.server start

or for auto-start MariaDB service

brew services start mariadb

1b. Debian/Ubuntu

sudo apt install mariadb-server
  1. Now run the configuration process:
sudo mysql_secure_installation
  1. Check if the service is running:
sudo systemctl status mariadb

Now you can import the table structures and the data: The user 'vesseltracker' is created and the password 'password' is set. I recommend to change the password in line 12 and 13 before you import the database in tmv_database.sql (combined table structures for all tables and area and terminal data for the port of Hamburg). After that you can import the database:

sudo mariadb < ./database/tmv_database.sql

4. Creating your personal vessel list

To create your personal list of vessels to track run

sh ./scripts/tmv_myvessels_insert_new_vessel.sh

and enter the vessel's details. So far you can only enter one vessel at a time.

5. Setting up your binding IP address, UDP port and DB and mail client credentials

Add your database credentials to nmea_main.rb:

  • IP address at line 50: "@socket.bind('<IPv4>', @port)"
  • if necessary: UDP port at line 490: "client = Main.new(<UDP port>)"

Add your database credentials to DB_CONNECT.rb.

Add your mail client credential to nmea_mailer.rb.

6. Running the code

In the main repo folder start the program with

ruby nmea_main.rb

7. Future work

  • Optimization of the database access to reduce CPU and memory usage
  • Implementation of additional features such as
    • easier insertion of ships to be tracked into the database
    • graphical representation of ship positions
    • creation of a dashboard with additional information about the ships

This software is licensed with CC BY-NC-SA 4.0

About

Real-time AIS vessel tracking including e-mail notification

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published