Return the current position either in relative units (ticks away from a zero position) or absolute units (degrees along a circle).
Optional
positionType: PositionTypeThe type of position the encoder returns (ticks or degrees)
Optional
extra: Structconst encoder = new VIAM.EncoderClient(machine, 'my_encoder');
// Get the position of the encoder in ticks
const [position, posType] = await encoder.getPosition(
EncoderPositionType.POSITION_TYPE_TICKS_COUNT
);
console.log('The encoder position is currently', position, posType);
For more information, see Encoder API.
Return the encoder's properties.
Optional
extra: Structconst encoder = new VIAM.EncoderClient(machine, 'my_encoder');
// Get whether the encoder returns position in ticks or degrees
const properties = await encoder.getProperties();
For more information, see Encoder API.
Set the current position of the encoder as the new zero position.
Optional
extra: Structconst encoder = new VIAM.EncoderClient(machine, 'my_encoder');
// Reset the zero position of the encoder
await encoder.resetPosition();
For more information, see Encoder API.
Represents a physical encoder.