jsk-ros-pkg / jsk_roseus

ROS EusLisp Client
http://wiki.ros.org/roseus/Tutorials
17 stars 56 forks source link

What is the right way to define preemptable action servers? #671

Open Affonso-Gui opened 3 years ago

Affonso-Gui commented 3 years ago

To accept /cancel messages from other topics during the execution of a ros::simple-action-server callback I had to use something like the following.

(defun execute-cb (server goal)
  ;; ...

  ;; Check for interruption
  (send server :spin-once)
  (when (send server :is-preempt-requested)
    (send server :set-preempted)
    (return-from execute-cb nil))

  ;; ...
)

Am I missing something here or is this actually the right way to do it?

Also I could not find any solid examples for the action server implementation, do we have any?

k-okada commented 3 years ago

Also I could not find any solid examples for the action server implementation, do we have any?

that's true, is there any good example of action server written in other languages? we will start with translating that code to euslisp c.f. https://github.com/jsk-ros-pkg/jsk_roseus/blame/b214284e24ad6287bf17545b9a73c541190fac1a/roseus/test/add-two-ints-server.l#L3

Affonso-Gui commented 3 years ago

Maybe this one? http://wiki.ros.org/actionlib_tutorials/Tutorials/SimpleActionServer%28ExecuteCallbackMethod%29

It is similar to the one implemented in https://github.com/jsk-ros-pkg/jsk_roseus/blob/b214284e24ad6287bf17545b9a73c541190fac1a/roseus/test/fibonacci-server.l , but it can be interrupted.

Should I upgrade the example and send a PR?

k-okada commented 3 years ago

Should I upgrade the example and send a PR?

yes please

Affonso-Gui commented 3 years ago

PR created, but I still think it would be nice if the sample had a bit more visibility, maybe with some documentation similar to http://wiki.ros.org/ja/ROS/Tutorials/WritingServiceClient%28euslisp%29 or included in the roseus_tutorials?