@gov.nasa.jpl.honeycomb/arksml-loader
v0.0.6
Published
Class for loading and parsing the ARKSML file format.
Downloads
8
Readme
ARKSML Loader
Loader and parser for ARKSML files using the built in XML parser.
Use
Parsing Raw Annotations
import { ArksmlLoader } from '@gov.nasa.jpl.honeycomb/arksml-loader';
const loader = new ArksmlLoader();
loader.parsers = {
'CustomAnnotation': node => {
// ... parse node to object ...
}
};
loader
.load('.../path/to/file.arksml')
.then(result => {
// ... parsed arksml ...
});Parsing Annotations into Frame Data
import { ArksmlLoader } from '@gov.nasa.jpl.honeycomb/arksml-loader';
const loader = new ArksmlLoader();
loader.outputFrames = true;
loader.parsers = {
'CustomAnnotation': node => {
// ... parse node to object ...
}
};
loader
.load('.../path/to/file.arksml')
.then(result => {
// ... parsed arksml ...
});API
Functions
ParserFunction
ParserFunction( element : XMLElement ) : ObjectparsePosition
parsePosition( node : XMLElement ) : { x : Number, y : Number, z : Number }Parses a node with 2 or 3 numbers.
parseQuaternion
parseQuaternion( node : XMLElement ) : { x : Number, y : Number, z : Number, w : Number }Parses a node with 4 numbers.
parseRMCSite
parseRMCSite( node : XMLElement ) : { rmcSite : Number }Parses a node with <RMC_Site> and <RMC_Drive> children.
parseRectangle
parseRectangle(
node : XMLElement
) : { position : Object, angle : Number, halfWidth : Number, halfHeight : Number }Parses a node.
parseTriangle
parseTriangle( node : XMLElement ) : { points : Array<Object> }Parses a node.
parseCircle
parseCircle( node : XMLElement ) : { position : Object, radius : Number }Parses a node.
parseKeepZone
parseKeepZone(
node : XMLElement
) : { shape : Object, shapeType : String, keepZoneType : 'in' | out }Parses a node.
parseNavGoal
parseNavGoal( node : XMLElement ) : { position : Object, radius : Number }Parse a node.
parseArmTarget
parseArmTarget( node : XMLElement ) : { position : Object, quaternion : Object, name : String }Parse a node.
parseRoverState
parseRoverState( node : XMLElement ) : Object<String, Number>Parse the entire rover state out of an XML node and return an object with key being the name and value being the html content For example, 0.000000 {'ARM_NAMED_TARGET_3_POSE_FULL_Z': 0.0}
parseImageAcquire
parseImageAcquire(
node : XMLElement
) : { camera : String, position : Object, quaternion : Object, roverState : Object }Parse an ImageAcquire block from an XML node
<ImageAcquire Camera="NAVR">
<RMC_Site>1</RMC_Site>
<RMC_Drive>0</RMC_Drive>
<Position>0.000000 0.000000 0.000000</Position>
<Quaternion>0.000000 -0.000000 0.000000 1.000000</Quaternion>
<RoverState>...</RoverState>
</ImageAcquire>AnnotationData
type
type : StringThe name embedded in the ARKSML file.
ArksmlResult
name
name : StringThe name embedded in the ARKSML file.
spans
spans : Array<{ startTime : Number, endtime : Number, annotations : Array<AnnotationData> }>List of annotation spans within the file.
events
events : Array<{ time : Number, annotations : Array<AnnotationData> }>List event annotation data.
ArksmlFramesResult
name
name : StringThe name embedded in the ARKSML file.
frames
frames : Array<{ time : Number, state : { annotations : Array<AnnotationData> } }>The array of annotations converted to frames. A new frame is inserted every time the list of relevant annotations change. This includes events.
events
events : Array<{ time : Number, annotations : Array<AnnotationData> }>List event annotation data.
ArksmlLoader
Extendable class for loading and parsing ARKSML files.
parsers
parsers : ObjectDictionary of parsers. By default ArmTarget, Target, KeepZone, NavGoal,
and ImageAcquire tags are parsed.
outputFrames
outputFrames : Boolean = falseWhether or not to return the data as a set of frames in an array of the form
[{
time,
state: {
annotations: [...]
}
}, ...]eventDuration
eventDuration : Numbar = 5.0What the minimum duration for events should be when converting to frames.
minimumDuration
minimumDuration : Numbar = 5.0The minimum duration of any given annotation in the file. If an annotaiton is shorter than this then it is extended from its startTime to this time.
fetchOptions
fetchOptions : Object = { credentials: 'same-origin' }Fetch options for loading the file.
constructor
constructor( parsers : Object<String, ParserFunction> = {} ) : voidTakes a dictionary of parser functions for parsing annotation tags. The parser functions are keyed based on the name of the annotation tag it should parse.
load
load( url : String ) : Promise<ArksmlResult | ArksmlFramesResult>Loads and parses the ARKSML file. The promise resolves with the returned data from the parse function.
parse
parse( str : String ) : RKSMLResultParses the contents of the given ARKSML and returns an object describing the telemetry.
preprocessFrames
preprocessFrames(
rawSpans : Array<{ startTime : Number, endtime : Number, annotations : Array<AnnotationData> }>,
rawEvents : Array<{ time : Number, annotations : Array<AnnotationData> }>,
name : String
) : voidOverrideable function called when we need to preprocess spans and events
