File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed
Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1111; ; https://raw.githubusercontent.com/rhaschke/executive_smach_tutorials/indigo-devel/examples/state_machine_simple.py
1212; ;
1313(setq count 0 )
14- (defun func-foo (&rest args)
14+ (defun func-foo (&rest args) " document foo "
1515 (format t " Execute state FOO~% " )
1616 (cond ((< count 3 ) (incf count ) :outcome1 )
1717 (t :outcome2 )))
Original file line number Diff line number Diff line change 4343 (:state-machine (&rest args) (forward-message-to sm args))
4444 ; ;
4545 (:publish-status
46- (&optional (userdata nil ) (machine sm) (path (format nil " /~A " root-name)))
46+ (&optional (userdata nil ) (machine sm) (path (format nil " /~A " root-name)) (info) )
4747 (let ((msg (instance smach_msgs ::SmachContainerStatus :init ))
4848 (initial (send-all (flatten (list (send machine :start-state ))) :name ))
4949 (active (send-all (flatten (list (send machine :active-state ))) :name )))
5454 (send msg :initial_states (mapcar #' string initial))
5555 (send msg :active_states (mapcar #' string active))
5656 (send msg :local_data (pickle ::dump userdata))
57+ (send msg :info info)
5758 (ros ::publish (concatenate string srv-name " /smach/container_status" ) msg)
5859 ; ; recursive call for publish active sub-machines
5960 (dolist (active-state (flatten (list (send machine :active-state ))))
Original file line number Diff line number Diff line change 1818Returns:
1919 the last active state
2020"
21- (let ((insp (instance state-machine-inspector :init sm :root-name root-name :srv-name srv-name)))
21+ (let ((insp (instance state-machine-inspector :init sm :root-name root-name :srv-name srv-name)) acs act doc )
2222 (unix ::usleep (round (* 0.5 1e6 )))
2323 (send sm :reset-state )
2424 (send insp :publish-structure ) ; ; publish once and latch
@@ -31,7 +31,20 @@ Returns:
3131 (when spin
3232 (send insp :spin-once )
3333 (if (and (boundp ' *ri*) *ri* ) (send *ri* :spin-once )))
34- (send insp :publish-status mydata)
34+ (setq acs (send sm :active-state ))
35+ (if (atom acs) (setq acs (list acs)))
36+ (setq doc " " )
37+ (dolist (a acs)
38+ (setq act (send a :action ))
39+ (setq d
40+ (cond ((and (functionp act) (not (listp act)))
41+ (documentation act))
42+ ((and (listp act) (eq (car act) ' lambda))
43+ (format nil " ~A ~A ..." (butlast act) (if (listp (car (last act))) (subseq (car (last act)) 0 3 ) act)))
44+ (t
45+ (format nil " ~A " act))))
46+ (push (cond ((stringp d) d) (t (string (send (send sm :active-state ) :name )))) doc))
47+ (send insp :publish-status mydata sm (format nil " /~A " root-name) (apply #' concatenate string doc))
3548 (when (send sm :goal-reached )
3649 (return ))
3750 (when iterate
Original file line number Diff line number Diff line change 221221 (send-super :init name))
222222 ; ; check if this state is state-machine, then return it
223223 (:submachine () (if (derivedp action state-machine) action nil ))
224+ ; ; accessor to action
225+ (:action (&rest args) (forward-message-to action args))
224226 ; ; remap userdata names
225227 (:remap-list
226228 (&rest args)
You can’t perform that action at this time.
0 commit comments