Skip to main content

Sensor

Our Sensor system allows for generating spatial queries to understand a Matterport digital twin. By utilizing and setting up Sources around the scene, some questions that can be answered are:

  • "what things are currently visible on screen?"
  • "what things are near me?"

where "things" can be Mattertag posts, sweeps, arbitrary locations (that you choose), or any combination of those.

Types

BoxVolume

BoxVolume: object
PropertyType
centerVector3
The center position of the box.
orientationOrientation
The orientation of the box. The rotations are applied in yaw, pitch, then roll order.
sizeVector3
The length, width, and depth of the box volume.

CylinderVolume

CylinderVolume: object
PropertyType
basePointVector3
The point which defines the position (base) from which the height in the +Y, and radius in the XZ-plane are relative to.
heightnumber
The height of the cylinder.
radiusnumber
The radius of the cylinder.

SensorReading

SensorReading: object

Information about the Source as read by the Sensor.

PropertyType
directionVector3
The world-space direction from the sensor to the source.
distancenumber
The distance between the sensor and the source.
distanceSquarednumber
The squared distance from the sensor to the source.
inRangeboolean
The sensor is currently within the broadcast range of the source.
inViewboolean
The sensor is within the source's broadcast range and the sensor has clear line of sight to the source.

SourceOptions

SourceOptions<UserData>: object

Additional userData to associate with an ISource when creating it. This is a free dictionary that can contain any key/values deemed necessary.

PropertyType
userDataUserData

SphereVolume

SphereVolume: object
PropertyType
originVector3
The origin of the sphere.
radiusnumber
The distance from origin of the sphere volume.

Volume

type Volume = SphereVolume | BoxVolume | CylinderVolume

Enumerations

SensorType

SensorType: enum
MemberValue
CAMERA"sensor.sensortype.camera"

SourceType

SourceType: enum
MemberValue
BOX"sensor.sourcetype.box"
CYLINDER"sensor.sourcetype.cylinder"
SPHERE"sensor.sourcetype.sphere"

Methods

createSensor

createSensor(type: Sensor.SensorType.CAMERA): Promise<Sensor.ISensor>

Create an ISensor which can sense and provide information about ISource.

const sensor = await mpSdk.Sensor.createSensor(mpSdk.Sensor.SensorType.CAMERA);
// add sources from calls to `Sensor.createSource()`
sensor.addSource(...sources);
// start listening for changes to the sensor's readings
sensor.readings.subscribe({
onAdded(source, reading) {
console.log(source.userData.id, 'has a reading of', reading);
},
onUpdated(source, reading) {
console.log(source.userData.id, 'has an updated reading');
if (reading.inRange) {
console.log(source.userData.id, 'is currently in range');
if (reading.inView) {
console.log('... and currently visible on screen');
}
}
}
});
ParameterType
typeSensor.SensorType.CAMERA

Returns: Promise<Sensor.ISensor>

createSource

createSource: method3 overloads
createSource(type: Sensor.SourceType.SPHERE, options: Partial<Sensor.SphereVolume & Sensor.SourceOptions<UserData>>): Promise<Sensor.ISource<Sensor.SphereVolume, UserData>>

Create a spherical ISource which can be sensed by an ISensor.

A shallow copy of options.userData is applied to the Source upon creation.

Omitting options.origin will default the source's volume.origin to { x: 0, y: 0, z: 0 }.

Omitting options.radius will default the source's volume.radius to Infinity.

const sources: Array<Sensor.ISource<Sensor.SphereVolume, { id: string }>> = await Promise.all([
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.SPHERE, {
origin: { x: 1, y: 2, z: 3 },
radius: 20,
userData: {
id: 'sphere-source-1',
},
}),
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.SPHERE, {
radius: 4,
userData: {
id: 'sphere-source-2',
},
}),
]);
// attach to a sensor previously created with `Sensor.createSensor()`
sensor.addSource(...sources);
ParameterType
typeSensor.SourceType.SPHERE
optionsPartial<Sensor.SphereVolume & Sensor.SourceOptions<UserData>>
volume and userData options for the sphere source

Returns: Promise<Sensor.ISource<Sensor.SphereVolume, UserData>>

createSource(type: Sensor.SourceType.BOX, options: Partial<Sensor.BoxVolume & Sensor.SourceOptions<UserData>>): Promise<Sensor.ISource<Sensor.BoxVolume, UserData>>

Create an box shaped ISource which can be sensed by an ISensor.

A shallow copy of options.userData is applied to the Source upon creation.

Omitting options.center will default the source's volume.center to { x: 0, y: 0, z: 0 }.

Omitting options.size will default the source's volume.size to { x: Infinity, y: Infinity, z: Infinity }. Omitting options.orientation will default the source's volume.orientatin to { yaw: 0, pitch: 0, roll: 0 }.

const sources: Array<Sensor.ISource<Sensor.BoxVolume, { id: string }>> = await Promise.all([
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.BOX, {
center: { x: 1, y: 1, z: 1 },
size: { x: 2, y: 1, z: 2 },
userData: {
id: 'box-source-1',
},
}),
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.BOX, {
size: { x: 2: y: 2, z: 2 },
orientation: { yaw: 45, pitch: 45, roll: 45 },
userData: {
id: 'box-source-2',
},
}),
]);
// attach to a sensor previously created with `Sensor.createSensor()`
sensor.addSource(...sources);
ParameterType
typeSensor.SourceType.BOX
optionsPartial<Sensor.BoxVolume & Sensor.SourceOptions<UserData>>
volume and userData options for the box source

Returns: Promise<Sensor.ISource<Sensor.BoxVolume, UserData>>

createSource(type: Sensor.SourceType.CYLINDER, options: Partial<Sensor.CylinderVolume & Sensor.SourceOptions<UserData>>): Promise<Sensor.ISource<Sensor.CylinderVolume, UserData>>

Create a cylindrical ISource which can be sensed by an ISensor.

A shallow copy of options.userData is applied to the Source upon creation.

Omitting options.basePoint will default the source's volume.basePoint to { x: 0, y: 0, z: 0 }.

Omitting options.radius will default the source's volume.radius to Infinity.

Omitting options.height will default the source's volume.height to Infinity.

const sources: Array<Sensor.ISource<Sensor.CylinderVolume, { id: string }>> = await Promise.all([
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.CYLINDER, {
basePoint: { x: 0, y: 0, z: 0 },
radius: 2,
height: 5,
userData: {
id: 'cylinder-source-1',
},
}),
mpSdk.Sensor.createSource(mpSdk.Sensor.SourceType.CYLINDER, {
basePoint: { x: 1, y: 2, z: 3 },
radius: 3,
userData: {
id: 'cylinder-source-2',
},
}),
]);
// attach to a sensor previously created with `Sensor.createSensor()`
sensor.addSource(...sources);
ParameterType
typeSensor.SourceType.CYLINDER
optionsPartial<Sensor.CylinderVolume & Sensor.SourceOptions<UserData>>

Returns: Promise<Sensor.ISource<Sensor.CylinderVolume, UserData>>