[Documentation] [TitleIndex] [WordIndex


actionlib_lisp is a native implementation of actionlib in Common Lisp. It provides a simple server and a client. In contrast to the implementations of actionlib in C++ and Python which provide a simple action client/server and a complex one, the lisp equivalent provides only one server and client implementation. The server is similar to the simple action server and the client is a little bit more powerful than the simple action client but not as complex as the complex C++ equivalent.



The interface consists of the following methods:


This example shows how to construct an action client for the fibonacci action of the actionlisp_tutorials package, send a goal to it and wait for the result.

(defparameter *ac* (make-action-client "/fibonacci" "actionlib_tutorials/FibonacciAction"))

(send-goal-and-wait *ac* (make-action-goal *ac* :order 10) :exec-timeout 20 :result-timeout 0.5)

To run it, you need to have the actionlib-lisp and actionlib_tutorials-msg loaded and be in a package that uses the actionlib package.


The server is similar to the C++ simple action server. It can handle only one goal at a time and if another goal is received while the server is processing an old goal, it is preempted and the new goal is executed.



This example shows how to implement a simple fibonacci action server.

(def-exec-callback fib-callback (order)
  "This function takes in the FibonacciGoal message and pursues the action."
  (ros-debug (fib callback) "entering callback with goal ~a" order)
  (let ((a 1) (b 1) (seq (make-array 0 :adjustable t :fill-pointer 0)))
    (dotimes (i order)
      (when (cancel-request-received)
        (ros-debug (fib callback) "goal ~a canceled" order)
        (preempt-current :sequence seq)) ;; Note that this exits the callback
      (psetq a b b (+ a b))
      (vector-push-extend a seq) 
      (ros-debug (fib callback) "publishing feedback for goal ~a" order)
      (publish-feedback :sequence seq)
      (sleep 1.0))
    (ros-debug (fib callback) "succeeding on goal ~a" order)
    (succeed-current :sequence seq)))

(defun fib-server ()
  (with-ros-node ("fib")
    (start-action-server "fibonacci" "actionlib_tutorials/FibonacciAction" #'fib-callback)))

2024-07-13 12:37