Goby v2
|
Table of Contents for goby-moos: An overview of the Goby/MOOS interoperability library.
iFrontSeat is a MOOS application used to interface a Goby/MOOS community (the "backseat") running pHelmIvP with a given manufacturer's vehicle (the "frontseat"). The usage of iFrontSeat and the existing driver suite is explained in the Goby user manual (see Resources).
iFrontSeat is intended to interface to a wide range of vehicles using any interface (e.g. proprietary extensions of NMEA-0183). The purpose of the driver is to implement the Goby FrontSeatInterfaceBase in the language of the particular frontseat vehicle system. Minimally, these are the requirements of the frontseat:
Additionally, the frontseat may provide or consume:
The state of iFrontSeat (as shown in the following diagram) is determined by a combination of the state of the frontseat and the state of pHelmIvP. Only the state of the frontseat must be determined by each new driver, as the state of pHelmIvP is determined by code shared by all the drivers.
The state of the frontseat consists of two parallel state charts (command and data):
The state transitions for the iFrontSeat interface states are (using the names as defined in the enumerations in moos/protobuf/frontseat.proto)
From | To | Action |
Start | INTERFACE_STANDBY | Configuration Read |
INTERFACE_STANDBY | INTERFACE_LISTEN | frontseat_providing_data == true |
INTERFACE_LISTEN | INTERFACE_COMMAND | FRONTSEAT_ACCEPTING_COMMANDS && HELM_DRIVE |
INTERFACE_COMMAND | INTERFACE_LISTEN | (FRONTSEAT_IN_CONTROL || FRONTSEAT_IDLE) && HELM_DRIVE |
INTERFACE_COMMAND | INTERFACE_HELM_ERROR | HELM_NOT_RUNNING || HELM_PARK |
INTERFACE_LISTEN || INTERFACE_COMMAND | INTERFACE_HELM_ERROR | HELM_PARK || if (helm_enabled) HELM_NOT_RUNNING (after timeout) |
INTERFACE_LISTEN || INTERFACE_COMMAND | INTERFACE_FS_ERROR | FRONTSEAT_NOT_CONNECTED || frontseat_providing_data == false |
INTERFACE_STANDBY | INTERFACE_FS_ERROR | FRONTSEAT_NOT_CONNECTED (after timeout) |
INTERFACE_HELM_ERROR | INTERFACE_STANDBY | HELM_DRIVE |
INTERFACE_FRONTSEAT_ERROR | INTERFACE_STANDBY | (if(ERROR_FRONTSEAT_NOT_CONNECTED) !FRONTSEAT_NOT_CONNECTED) || (if(ERROR_FRONTSEAT_NOT_PROVIDING_DATA) frontseat_providing_data == true) |
We will show you how to a write a new driver by example. To do so, we have created a simple frontseat simulator ("abc_frontseat_simulator") that is intended to represent the real vehicle frontseat control system. The full source code for this example is given at:
examples/moos/abc_frontseat_driver/abc_frontseat_driver_config.proto
A complete production driver is provided by BluefinFrontSeat for the Bluefin Robotics AUVs that conform to the Bluefin Standard Payload Interface version 1.8 and newer.
The transport for the ABC frontseat is TCP: the simulator (frontseat) listens on a given port and the driver connects to that machine and port. The wire protocol is a simple ascii line-based protocol where lines are terminated by carriage-return and newline (<CR><NL> or "\r\n"). Each message has a name (key), followed by a number of comma-delimited, colon-separated fields:
Key | Description | Direction (relative to frontseat) | Format | Example |
START | Simulator initialization message | Receive | START,LAT:{latitude decimal degrees},LON:{longitude decimal degrees},DURATION:{simulation duration seconds} | START,LAT:42.1234,LON:-72,DURATION:600 |
CTRL | Frontseat state message | Transmit | CTRL,STATE:{PAYLOAD (if backseat control) or IDLE} | CTRL,STATE:PAYLOAD |
NAV | Navigation message generated from very primitive dynamics model (depth & heading changes are instantaneous) | Transmit | NAV,LAT:{latitude decimal degrees},LON:{longitude decimal degrees},DEPTH:{depth in meters},HEADING:{heading in degrees},SPEED:{speed in m/s} | NAV,LAT:42.1234,LON:-72.5435,DEPTH:200,HEADING:223,SPEED:1.4 |
CMD | Desired course command from backseat | Receive | CMD,HEADING:{desired heading in degrees},SPEED:{desired speed in m/s},DEPTH:{desired depth in m} | CMD,HEADING:260,SPEED:1.5,DEPTH:100 |
CMD | Reponse to last CMD | Transmit | CMD,RESULT:{OK or ERROR} | CMD,RESULT:OK |
Your driver will be (at a minimum) a C linkage function "frontseat_driver_load" and a subclass of FrontSeatInterfaceBase. It should be compiled into a shared library (.so on Linux).
The C function is used by iFrontSeat to load your driver:
First you should decide what configuration your driver will accept. Your configuration object is an extension to the Google Protobuf message "iFrontSeatConfig". For the ABC frontseat driver, we use the abc_frontseat_driver_config.proto file to define the configuration:
In this case, we need to know what IP address and TCP port the abc_frontseat_simulator is listening on, and the starting position of the simulator.
Next, you should fill out the virtual methods of FrontSeatInterfaceBase:
The method "frontseat_state" reports the driver's belief of the frontseat command state (see State charts).
In this case, we set the value of frontseat_status_ based on the received "CTRL" messages:
Now, the final task is to call the appropriate signals in FrontSeatInterfaceBase upon receipt of data and responses to commands. The signals are called just like normal functions with the corresponding signatures. These signals (except signal_raw_to_frontseat) are typically called in response to data received in the loop() method.
For testing the ABC driver to see how it functions, you will need to run
abc_frontseat_simulator 54321
where 54321 is the port for the simulator to listen on.
Then, run iFrontSeat in a MOOS community with pHelmIvP with the following configuration:
ProcessConfig = iFrontSeat_bluefin { common { verbosity: DEBUG1 } [abc_config] { # (optional) tcp_address: "localhost" # (required) tcp_port: 54321 # (optional) (default=54321) start { lat: 44.0888889 lon: 9.84861111 duration: 600 } } }
You can change the start position as desired.