A DataFrame is one unit of work travelling through the model. It carries a set of DataObjects, one of which is the source — the object the frame is about.
import { DataFrame, DataObject } from '@openhps/core';
const phone = new DataObject('phone', 'My Phone');
const frame = new DataFrame(phone);
frame.addObject(new DataObject('beacon-1'));
frame.source; // the phone
frame.getObjects(); // every object in the frame
A DataObject is identified by its uid. The same physical thing keeps the same
uid across frames, which is what lets services accumulate history for it.
An absolute position places an object in a known frame of reference.
| Class | Use |
|---|---|
| Absolute2DPosition | Planar x, y |
| Absolute3DPosition | x, y, z |
| GeographicalPosition | Latitude, longitude and altitude on WGS84 |
import { Absolute2DPosition, GeographicalPosition, LengthUnit } from '@openhps/core';
phone.setPosition(new Absolute2DPosition(3, 4, LengthUnit.METER));
phone.setPosition(new GeographicalPosition(50.8206, 4.3922, 12));
Every position carries the unit it was expressed in, so a position created in centimetres and one created in metres compare correctly.
A relative position describes an object with respect to another object rather than in absolute terms. This is what most sensors actually measure.
| Class | Measurement |
|---|---|
| RelativeDistance | Distance to a reference object |
| RelativeAngle | Azimuth to a reference object |
| RelativeOrientation | Orientation with respect to a reference object |
| Relative2DPosition / Relative3DPosition | Offset vector to a reference object |
| RelativeLinearVelocity / RelativeAngularVelocity | Velocity with respect to a reference object |
import { RelativeDistance, LengthUnit } from '@openhps/core';
phone.addRelativePosition(new RelativeDistance(beacon, 5, LengthUnit.METER));
phone.getRelativePositions();
Positioning nodes turn these into an absolute position. MultilaterationNode does so from three or more distances, TriangulationNode from three angles.
A
RelativeAngleholds a single azimuth. Azimuths constrain an object to a vertical plane, so no number of them determines altitude; angle-based triangulation is inherently planar.
Units are values, not strings, and convert between each other explicitly.
import { LengthUnit, AngleUnit, TimeUnit } from '@openhps/core';
LengthUnit.CENTIMETER.convert(250, LengthUnit.METER); // 2.5
AngleUnit.DEGREE.convert(180, AngleUnit.RADIAN); // Math.PI
TimeUnit.SECOND.convert(1, TimeUnit.MILLISECOND); // 1000
Derived units are provided as their own classes rather than composed on the fly: LinearVelocityUnit, AngularVelocityUnit, AccelerationUnit, MagnetismUnit, TemperatureUnit, PressureUnit, LuminanceUnit and LuminanceIntensityUnit.
import { LinearVelocityUnit, AngularVelocityUnit } from '@openhps/core';
LinearVelocityUnit.CENTIMETER_PER_SECOND.convert(250, LinearVelocityUnit.METER_PER_SECOND);
AngularVelocityUnit.DEGREE_PER_SECOND.convert(90, AngularVelocityUnit.RADIAN_PER_SECOND);
An SI prefix can be applied to any unit with specifier():
import { LengthUnit, UnitPrefix } from '@openhps/core';
const nanometer = LengthUnit.METER.specifier(UnitPrefix.NANO);
A ReferenceSpace is a transform — translation, rotation and scale — between two coordinate systems. It lets a model work in whichever space is convenient and convert at the boundary.
import { ReferenceSpace, Euler, AngleUnit } from '@openhps/core';
const screenSpace = new ReferenceSpace().translation(0, 200).rotation(new Euler(180, 0, 0, 'ZXY', AngleUnit.DEGREE));
ModelBuilder.create().from(sourceNode).convertFromSpace(screenSpace).to(sinkNode);