Data Object
Data objects represent the object or person that you are trying to determine a position for. It can also represent any other landmark or sensor that could have an absolute or relative position.
A data object is considered a snapshot of a the current state and should not contain any temporary information.
Initialization
ts
import {DataObject } from '@openhps/core';// Create an object with unique identifier 'bsigner'constmyObject = newDataObject ("bsigner", "Beat Signer");
A data object can be created using its constructor that takes a unique identifier and an optional display name. More information on its construction can be found in the API documentation here.
Custom data object
Depending on what type of positioning system you are creating, you may find yourself having to add data to data frames or data objects that do not exist yet.
An important design principle in OpenHPS is the serializability of every frame, object and data that is included in those data types. This requires the use of decorators to indicate if data should be serialized.
ts
import {DataObject ,SerializableObject ,SerializableMember } from '@openhps/core';@SerializableObject ()export classQRCode extendsDataObject {@SerializableMember ()publicurl : string = "";@SerializableMember ()publicimageBase64 : string = "";}
Custom sensor object
Creating a sensor is done by extending the SensorObject
. A sensor object takes an optional type generic to indicate the value it contains.
ts
import {SerializableObject ,LuminanceIntensityUnit ,SensorObject ,SensorValue ,} from '@openhps/core';@SerializableObject ()export classAmbientLightSensor extendsSensorObject <SensorValue <LuminanceIntensityUnit >> {constructor(uid ?: string,value ?:SensorValue <LuminanceIntensityUnit >,frequency ?: number,displayName ?: string) {super(uid ,value ?? newSensorValue (),frequency ,displayName );}}