UNPKG

roslib

Version:

The standard ROS Javascript Library

71 lines (70 loc) 2.17 kB
import { default as Ros } from '../core/Ros.ts'; import { default as Topic } from '../core/Topic.ts'; import { EventEmitter } from 'eventemitter3'; import { actionlib_msgs } from '../types/actionlib_msgs.ts'; /** * An actionlib action server client. * * Emits the following events: * * 'goal' - Goal sent by action client. * * 'cancel' - Action client has canceled the request. */ export default class SimpleActionServer<TGoal = unknown, TFeedback = unknown, TResult = unknown> extends EventEmitter<{ goal: [TGoal]; cancel: undefined; }> { currentGoal: { goal: TGoal; goal_id: actionlib_msgs.GoalID; } | null; nextGoal: { goal: TGoal; goal_id: actionlib_msgs.GoalID; } | null; ros: Ros; serverName: string; actionName: string; feedbackPublisher: Topic<{ feedback: TFeedback; status: actionlib_msgs.GoalStatus; }>; resultPublisher: Topic<{ result?: TResult; status: actionlib_msgs.GoalStatus; }>; statusPublisher?: Topic<actionlib_msgs.GoalStatusArray>; statusMessage: actionlib_msgs.GoalStatusArray; /** * @param options * @param options.ros - The ROSLIB.Ros connection handle. * @param options.serverName - The action server name, like '/fibonacci'. * @param options.actionName - The action message name, like 'actionlib_tutorials/FibonacciAction'. */ constructor({ ros, serverName, actionName, }: { ros: Ros; serverName: string; actionName: string; }); /** * Set action state to succeeded and return to client. * * @param result - The result to return to the client. */ setSucceeded(result: TResult): void; /** * Set action state to aborted and return to client. * * @param result - The result to return to the client. */ setAborted(result: TResult): void; /** * Send a feedback message. * * @param feedback - The feedback to send to the client. */ sendFeedback(feedback: TFeedback): void; /** * Handle case where client requests preemption. */ setPreempted(): void; }