Live GPS and Vehicle Tracking

Overview

RAPID provides live GPS tracking and it is potentially one of the most useful tools a fleet monitoring service can provide. It allows you to visualize where each one of your vehicles is on a map alongside how fast they are going and other vehicle status information-very useful for making sure your trucks are keeping on schedule. Setting up a PC with a USB GPS dongle is perhaps the simplest way to provide vehicle GPS data and also the simplest part of displaying this data. We utilize a third-party publish-subscribe MQTT service to allow for communication of vehicle data between our edge devices and our cloud API.

Building Real-Time Vehicle Tracking

One way to set this up is to have the module take a snapshot of the current GPS data every second using gpsd. GPSD is an open-source solution for Unix-like systems that support TCP/IP transportation of GPS data from serial connections. Once we’ve captured a series of GPS coordinates, we can then pump that data up to the cloud. But how do we visualize this for our customers?  One way is to use realtime subscribers to listen for the GPS data. We run a PubNub subscriber in the frontend of our web application that is subscribed to the channel devices are sending their GPS data to. This allows us to display incoming location data neatly and quickly since there will be zero database queries to get the vehicle data to display on our map. As for assigning a vehicle to the GPS data, we provide an identifier for each vehicle along with the GPS data payload over MQTT. This allows us to display multiple vehicles with their information on the map at the same time, making it easier to get a full picture of where all the fleet vehicles are at any given moment. The following is an example of how we would set up a subscriber to track fleets in our frontend using EmberJS:
import ENV from 'project/config/environment';
import AbstractPubnub from 'project/services/pubnub';
import PubNub from 'pubnub';

export default class PubnubService extends AbstractPubnub {
  constructor() {
    super(...arguments);

    this.client = new PubNub({
      publishKey: ENV.pubnub.publishKey,
      subscribeKey: ENV.pubnub.subscribeKey,
      uuid: this.currentUser.user.id
    });

    this.client.addListener({
      status: this.status.bind(this),
      message: this.message.bind(this),
      presence: this.presence.bind(this)
    });
  }
}

Fleet Management Framework

Rapidly build better fleet & asset apps, with less code.

Blog Author:

Subscribe

Sign up for our Newsletter and stay up to date on the latest at ESG USA.  New blog posts, newsletters, case studies, and more.