/** * Base teleoperator interface and abstract class for Web platform * Defines the contract that all teleoperators must implement */ import type { MotorConfig } from "../types/teleoperation.js"; import type { MotorCommunicationPort } from "../utils/motor-communication.js"; /** * Type definition for state update callback parameters */ interface StateUpdateCallbackParams { previousMotorConfigs: MotorConfig[]; newMotorConfigs: MotorConfig[]; previousMotorConfigsNormalized: MotorConfig[]; newMotorConfigsNormalized: MotorConfig[]; commandSentTimestamp: number; positionChangedTimestamp: number; } /** * Type definition for state update callback function */ type StateUpdateCallback = (params: StateUpdateCallbackParams) => void; /** * Type definition for array of state update callbacks */ type StateUpdateCallbackArray = Array; /** * Base interface that all Web teleoperators must implement */ export declare abstract class WebTeleoperator { protected onStateUpdateCallbacks: StateUpdateCallbackArray; motorConfigs: MotorConfig[]; abstract initialize(): Promise; abstract start(): void; abstract stop(): void; abstract recordingTaskIndex: number; abstract recordingEpisodeIndex: number; abstract setEpisodeIndex(index: number): void; abstract setTaskIndex(index: number): void; abstract disconnect(): Promise; abstract getState(): TeleoperatorSpecificState; abstract onMotorConfigsUpdate(motorConfigs: MotorConfig[]): void; abstract addOnStateUpdateCallback(fn: StateUpdateCallback): void; } /** * Teleoperator-specific state (union type for different teleoperator types) */ export type TeleoperatorSpecificState = { keyStates?: { [key: string]: { pressed: boolean; timestamp: number; }; }; leaderPositions?: { [motor: string]: number; }; gamepadState?: { axes: number[]; buttons: boolean[]; }; }; /** * Base abstract class with common functionality for all teleoperators */ export declare abstract class BaseWebTeleoperator extends WebTeleoperator { protected port: MotorCommunicationPort; motorConfigs: MotorConfig[]; protected isActive: boolean; isRecording: boolean; recordingTaskIndex: number; recordingEpisodeIndex: number; recordedMotorPositionEpisodes: any[]; constructor(port: MotorCommunicationPort, motorConfigs: MotorConfig[]); abstract initialize(): Promise; abstract start(): void; abstract stop(): void; abstract getState(): TeleoperatorSpecificState; disconnect(): Promise; setEpisodeIndex(index: number): void; setTaskIndex(index: number): void; onMotorConfigsUpdate(motorConfigs: MotorConfig[]): void; normalizeMotorConfigPosition(motorConfig: MotorConfig): number; /** * Normalize an entire list of motor configurations * * This follows the guide at https://github.com/huggingface/lerobot/blob/cf86b9300dc83fdad408cfe4787b7b09b55f12cf/src/lerobot/robots/so100_follower/so100_follower.py#L49 * Meaning, for everything except gripper, it normalizes the positions to between -100 and 100 * and for gripper it normalizes between 0 - 100 */ normalizeMotorConfigs(motorConfigs: MotorConfig[]): MotorConfig[]; /** * Dispatches a motor position changed event * Gets the motor positions, normalized * * This follows the guide at https://github.com/huggingface/lerobot/blob/cf86b9300dc83fdad408cfe4787b7b09b55f12cf/src/lerobot/robots/so100_follower/so100_follower.py#L49 * Meaning, for everything except gripper, it normalizes the positions to between -100 and 100 * and for gripper it normalizes between 0 - 100 * * @param motorName The name of the motor that changed * @param motorConfig The motor configuration * @param previousPosition The previous position of the motor * @param currentPosition The current position of the motor * @param timestamp The timestamp of the event */ dispatchMotorPositionChanged(prevMotorConfigs: MotorConfig[], newMotorConfigs: MotorConfig[], commandSentTimestamp: number, positionChangedTimestamp: number): void; /** * Adds an onstateupdate callback * to return a response for the user with motor config states and timestamps * @param fn Callback function that receives state update parameters */ addOnStateUpdateCallback(fn: StateUpdateCallback): void; get isActiveTeleoperator(): boolean; } export {}; //# sourceMappingURL=base-teleoperator.d.ts.map