UNPKG

@foxglove/ros1

Version:

Standalone TypeScript implementation of the ROS 1 (Robot Operating System) protocol with a pluggable transport layer

113 lines 4.19 kB
import { MessageDefinition } from "@foxglove/message-definition"; import { HttpServer, XmlRpcValue } from "@foxglove/xmlrpc"; import { EventEmitter } from "eventemitter3"; import { LoggerService } from "./LoggerService"; import { Publication } from "./Publication"; import { RosFollower } from "./RosFollower"; import { RosFollowerClient } from "./RosFollowerClient"; import { RosMasterClient } from "./RosMasterClient"; import { RosParamClient } from "./RosParamClient"; import { Subscription } from "./Subscription"; import { TcpSocketCreate, TcpServer, TcpAddress, NetworkInterface } from "./TcpTypes"; export type RosGraph = { publishers: Map<string, Set<string>>; subscribers: Map<string, Set<string>>; services: Map<string, Set<string>>; }; export type SubscribeOpts = { topic: string; dataType: string; md5sum?: string; tcpNoDelay?: boolean; }; export type PublishOpts = { topic: string; dataType: string; latching?: boolean; messageDefinition?: MessageDefinition[]; messageDefinitionText?: string; md5sum?: string; }; export type ParamUpdateArgs = { key: string; value: XmlRpcValue; prevValue: XmlRpcValue; callerId: string; }; export type PublisherUpdateArgs = { topic: string; publishers: string[]; prevPublishers: string[]; callerId: string; }; export interface RosNodeEvents { paramUpdate: (args: ParamUpdateArgs) => void; publisherUpdate: (args: PublisherUpdateArgs) => void; error: (err: Error) => void; } export declare class RosNode extends EventEmitter<RosNodeEvents> { readonly name: string; readonly hostname: string; readonly pid: number; rosMasterClient: RosMasterClient; rosParamClient: RosParamClient; rosFollower: RosFollower; subscriptions: Map<string, Subscription>; publications: Map<string, Publication>; parameters: Map<string, XmlRpcValue>; private _running; private _tcpSocketCreate; private _connectionIdCounter; private _tcpPublisher?; private _localApiUrl?; private _log?; constructor(options: { name: string; hostname: string; pid: number; rosMasterUri: string; httpServer: HttpServer; tcpSocketCreate: TcpSocketCreate; tcpServer?: TcpServer; log?: LoggerService; }); start(port?: number): Promise<void>; shutdown(_msg?: string): void; subscribe(options: SubscribeOpts): Subscription; advertise(options: PublishOpts): Promise<Publication>; publish(topic: string, message: unknown): Promise<void>; isSubscribedTo(topic: string): boolean; isAdvertising(topic: string): boolean; unsubscribe(topic: string): boolean; unadvertise(topic: string): boolean; getParamNames(): Promise<string[]>; setParameter(key: string, value: XmlRpcValue): Promise<void>; subscribeParam(key: string): Promise<XmlRpcValue>; unsubscribeParam(key: string): Promise<boolean>; subscribeAllParams(): Promise<Readonly<Map<string, XmlRpcValue>>>; unsubscribeAllParams(): Promise<void>; getPublishedTopics(subgraph?: string): Promise<[topic: string, dataType: string][]>; getSystemState(): Promise<RosGraph>; tcpServerAddress(): Promise<TcpAddress | undefined>; receivedBytes(): number; static RequestTopic(name: string, topic: string, apiClient: RosFollowerClient): Promise<{ address: string; port: number; }>; private _newConnectionId; private _getPublication; private _callerApi; private _handleParamUpdate; private _handlePublisherUpdate; private _handleTcpClientConnection; private _handleTcpPublisherError; private _registerSubscriber; private _registerPublisher; private _unregisterSubscriber; private _unregisterPublisher; private _registerSubscriberAndConnect; _subscribeToPublisher(pubUrl: string, subscription: Subscription): Promise<void>; static GetRosHostname(getEnvVar: (envVar: string) => string | undefined, getHostname: () => string | undefined, getNetworkInterfaces: () => NetworkInterface[]): string; static IsPrivateIP(ip: string): boolean; } //# sourceMappingURL=RosNode.d.ts.map