Positioning Model
A positioning model is a processing network with a graph topology that samples sensor data and produces a position as output. You define it with the ModelBuilder, adding nodes, shapes and services:
SourceNodes push data frames into the model.ProcessingNodes transform the data.SinkNodes store or finalize data frames.
Creating a positioning model
The ModelBuilder lets you chain nodes from source to processing node to sink using a fluent API.
Example
tsimport {ModelBuilder ,CallbackSourceNode ,CallbackSinkNode ,CallbackNode ,DataFrame ,DataObject ,Model } from '@openhps/core';ModelBuilder .create ().from (newCallbackSourceNode (() => {constmyObject = newDataObject ("bsigner", "Beat Signer");constframe = newDataFrame (myObject );returnframe ;})).via (newCallbackNode ((frame :DataFrame ) => {// Process the frame (e.g. compute a position)})).to (newCallbackSinkNode ((frame :DataFrame ) => {// Store or display the result})).build ().then ((model :Model ) => {// The model is now ready to be used});
Instead of extending the base Node class, most models extend a SourceNode, ProcessingNode or SinkNode. See the source node, processing node and sink node pages for more details.
Merging data frames
OpenHPS supports merging multiple sources of data frames in different ways.
Merging streams of data frames
Pass multiple source nodes to from() to merge their streams. Every frame that reaches a node is processed independently.
tsimport {ModelBuilder ,CallbackSourceNode ,CallbackSinkNode ,CallbackNode ,DataFrame ,DataObject } from '@openhps/core';ModelBuilder .create ().from (newCallbackSourceNode (() => {constframe = newDataFrame (newDataObject ("object-a"));returnframe ;}), newCallbackSourceNode (() => {constframe = newDataFrame (newDataObject ("object-b"));returnframe ;})).via (newCallbackNode ((frame :DataFrame ) => {// Process each frame independently})).to (newCallbackSinkNode (() => {})).build ();
Merging frames of the same type
You can also merge the information contained within multiple frames of the same type, for example to combine sensor readings in a single frame. See the data frame page for more information on how frames can be combined.