jsk-ros-pkg / jsk_roseus

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

[roseus_smach] add before and after hook for state machine execution #724

Open knorth55 opened 2 years ago

knorth55 commented 2 years ago

before-hook-func and after-hook-func

this PR add before-hook-func and after-hook-func for state-machine execution. in the loop, we can add befor hook and after hook for smach execution.

(catch :exec-state-machine-loop ...) for global exit from hook-func with throw.

I also add catch :exec-state-machine-loop for global exit from the loop. with this PR, we can exit from the execution loop from the hook with (throw :exec-state-machine-loop).

this is the example of the hook usage.

(exec-state-machine *sm*
  :before-hook-func
  #'(lambda (userdata)
     (if *stopped*
       (progn
         (ros::ros-warn "Stopped...")
         (setf (cdr (assoc 'count userdata)) 0)
         (throw :exec-state-machine-loop t))))
  :after-hook-func
  #'(lambda (userdata)
     (send *irtviewer* :draw-objects))
  )