Class BodyRigSensorSources

Recovers the peripheral number behind each of a BodyRig's positional sensor slots by walking the pipeline graph back to the sockets the packets arrive on.

Inheritance
BodyRigSensorSources
Namespace: MOSAIC.Models.Devices
Assembly: MOSAIC.dll
Syntax
public static class BodyRigSensorSources
Remarks

A rig fed from upstream sees only a concatenated vector of quaternions; which ESP node produced group k is not in the data. It is in the configuration, because the firmware derives each node's UDP port from its sensor number — "11" followed by the number, so node 18 transmits on 11018 and node 71 on 11071. Reading the port back is therefore exact, not a convention this code invents.

Ordering comes from the Joiner's declared inputs, which is the same list the Joiner concatenates by, so slot k here is the slot the rig will actually bind.

Display only. Nothing in the kinematics consults this, and a slot it cannot name simply shows without a peripheral rather than guessing one.

Fields

MaxPeripheral

Largest node number that still yields a port in the documented range.

Declaration
private const int MaxPeripheral = 999
Field Value
Type Description
int

PortBase

Port prefix the firmware prepends to the sensor number.

Declaration
public const int PortBase = 11000
Field Value
Type Description
int

ValuesPerSensor

Values one sensor contributes: w, x, y, z.

Declaration
private const int ValuesPerSensor = 4
Field Value
Type Description
int

Methods

FirstInput(BaseBlock, IReadOnlyDictionary<string, BaseBlock>)

Resolves a block's first declared input to an instance, if it has one.

Declaration
private static BaseBlock? FirstInput(BaseBlock block, IReadOnlyDictionary<string, BaseBlock> byName)
Parameters
Type Name Description
BaseBlock block
IReadOnlyDictionary<string, BaseBlock> byName
Returns
Type Description
BaseBlock

OrderedInputs(Joiner, IReadOnlyDictionary<string, BaseBlock>)

The Joiner's inputs in declared order — the order it concatenates in.

Declaration
private static List<BaseBlock> OrderedInputs(Joiner joiner, IReadOnlyDictionary<string, BaseBlock> byName)
Parameters
Type Name Description
Joiner joiner
IReadOnlyDictionary<string, BaseBlock> byName
Returns
Type Description
List<BaseBlock>

PeripheralBehind(BaseBlock, IReadOnlyDictionary<string, BaseBlock>)

Walks upstream from block to the socket the packets arrive on and converts its port back to a node number.

Declaration
private static int? PeripheralBehind(BaseBlock block, IReadOnlyDictionary<string, BaseBlock> byName)
Parameters
Type Name Description
BaseBlock block
IReadOnlyDictionary<string, BaseBlock> byName
Returns
Type Description
int?

Resolve(BodyRig, IReadOnlyDictionary<string, BaseBlock>)

Resolves rig's sensor slots against the blocks of the pipeline it belongs to. Returns an empty list when the rig has no resolvable input.

Declaration
public static IReadOnlyList<BodyRigSensorSource> Resolve(BodyRig rig, IReadOnlyDictionary<string, BaseBlock> byName)
Parameters
Type Name Description
BodyRig rig

The rig whose slots to describe.

IReadOnlyDictionary<string, BaseBlock> byName

Every block in the pipeline, keyed by Name.

Returns
Type Description
IReadOnlyList<BodyRigSensorSource>

WidthOf(BaseBlock)

How many values a source contributes. A Projector states it exactly; for anything else one quaternion is the only defensible assumption.

Declaration
private static int WidthOf(BaseBlock block)
Parameters
Type Name Description
BaseBlock block
Returns
Type Description
int

Search documentation

Start typing to search the documentation.