This is an advanced task for AUV Workbench developers.
Writing an importer that reads a robot telemetry file into AUVWorkbench generally involves reading a text file and then translating it into XML using Autonomous Vehicle Command Language (AVCL).
TelemetryFileTranslator
in the
package avcl.translate
getDefaultAvclDocument()
. This method
should create the overall skeleton of the AVCL document in an
appropriate way, for example by creating an AVCL file for a surface
vehicle, underwater vehicle, air vehicle, etc.
The AVCL format is defined via JAXB, and JAXB 2.0 documents can be
created manually by using the ObjectFactory
class. The general strategy
for creating an AVCL document is to manually create the top level
document and all its elements by making calls to ObjectFactory
. For
example:
factory = new ObjectFactory();
defaultAvcl = factory.createAVCL();
defaultAvcl.setVersion("2.0");
AvclHeadType avclHead = factory.createAvclHeadType();
defaultAvcl.setHead(avclHead);
This is very similar to building a DOM tree; create an element, and add it to its parent.
The TelemetryFileTranslator
abstract contains the basic structure for
creating a resulting AVCL file from a text file. It implements the
TelemetryTranslatorInterface
, which defines the overall methods for
creating an AVCL file from telemetry. The TelemetryTranslatorInterface
is there in case we need to create an AVCL file from some other source,
for example from network-based events rather than a file. The
TelemetryTranslatorInterface
is largely redundant at this point since
our only current method for importing telemetry is from a file.
The subclass of TelemetryFileTranslator
you are writing should have a
constructor that sets an input filename that contains the telemetry
data. The constructor should call the superclass's
setInputFilename()
method to set this.
You should override the getDefaultAvclDocument()
class, and in the
implementation make a call to the superclass's method:
avclDocument = super.getDefaultAvclDocument();
getAvclDocument().setVehicleType("AMN");
In the subclass method you should set the vehicle type (underwater, air, surface, etc), add any metadata such as the name of the translator and the date of translation, and set the geo-origon for the data.
The geoOrigin is the latitude and longitude for the project. The Workbench generally uses (x,y) coordinates for telemetry position, and these (x,y) coordinates are offset from a latitude and longitude origin. This origin should be set to that of the AuvWorkbench project.
The parse()
method is the heart of the import process. This reads the
telemetry file and creates the corresponding AVCL elements for the
telemetry. The data in telemetry files is often corrupted or wildly off
base; if you're reading latitude and longitude, for example, it's not
uncommmon to get zeros for both, or to have wildly off-base time hacks,
or simply bogus data that does not match anything at all. Very often
the telemetry data is exported from a spreadsheet, and there will be
text column headers interspersed at random places in the data lines.
One thing that you must do is translate the latitude and longitude
readings--the most common location format--into (x,y) positions. This
is done via OpenMap libraries. This is handled by a method in the
TelemetryFileTranslator
superclass:
LatLonPoint location = new LatLonPoint(Float.parseFloat(latitude), Float.parseFloat(longitude));
Point2D xy = this.latLongToXY(projectGeoOriginLatLon, location);
The method takes the project geo-origin and the vehicle latitude and longitude as arguments, and then translates them into an (x,y) position.
Another thing to be alert for is very frequent or large telemetry sets. The AVCL file is kept in memory, and a large telemetry data set may exceed the RAM of a host. To alleviate this problem, you should allow the user to filter on the frequency of telemetry points.
After completing the subclass of TelemetryFileTranslator
, you must
modify some other files. TelemetryTranslatorGui.java in the
workbench.main package should have changes made to the
fileFormatStateChanged()
method and vehicleNames
variable. The
configuration file
configuration/templates/c_app.xml
should be
changed to include the new translator class.
Back to the Help page index, the AUV Workbench: Introduction page, or online to AUV Workbench home page.