Skip to content

Commit

Permalink
use &key instead of &rest in baxter angle-vector
Browse files Browse the repository at this point in the history
use &key instead of &rest args in :angle-vector methods in baxtereus and
refine codes.
  • Loading branch information
knorth55 committed Nov 26, 2016
1 parent d90667e commit 82b5ffe
Showing 1 changed file with 34 additions and 40 deletions.
74 changes: 34 additions & 40 deletions jsk_baxter_robot/baxtereus/baxter-interface.l
Expand Up @@ -232,57 +232,51 @@
(ros::publish "/robot/head/command_head_nod" msg)
)
)
(:angle-vector-raw (av &optional (tm :fast) (ctype controller-type) (start-time 0) &rest args)
(send* self :angle-vector-sequence-raw (list av) (list tm) ctype start-time args))
(:angle-vector-raw (av &optional (tm :fast) (ctype controller-type) (start-time 0) &key (scale 2.2) (min-time 0.05))
(send self :angle-vector-sequence-raw (list av) (list tm) ctype start-time :scale scale :min-time min-time))
(:angle-vector-sequence-raw (avs &optional (tms :fast) (ctype controller-type) (start-time 0) &key (scale 2.2) (min-time 0.05))
;; force add current position to the top of avs
(if (atom tms) (setq tms (list tms)))
(setq ctype (or ctype controller-type)) ;; use default if ctype is nil
(send-super :angle-vector-sequence avs tms ctype start-time :scale scale :min-time min-time))
(:angle-vector
(av &optional tm (ctype controller-type) &rest args)
(av &optional tm (ctype controller-type) (start-time 0) &key (move-arm :arms) (scale 2.2) (min-time 0.05))
"Send joind angle to robot with self-collision motion planning, this method returns immediately, so use :wait-interpolation to block until the motion stops.
- av : joint angle vector [rad]
- tm : (time to goal in [msec]) ;; currently this value is ignored
"
(let ((arm :arms))
(setq ctype (or ctype controller-type)) ;; use default if ctype is nil
(when (position :move-arm args)
(setq arm (elt args (+ (position :move-arm args) 1))))
;; for simulation mode
(when (send self :simulation-modep)
(return-from :angle-vector (send* self :angle-vector-raw av tm ctype args)))
(if (and (get self :moveit-environment)
(send (get self :moveit-environment) :robot))
(progn
(when (not (numberp tm))
(warning-message 3 ":angle-vector tm is not a number, use :angle-vector av tm args"))
(unless tm (setq tm 3000))
(send-super :angle-vector-motion-plan av :ctype ctype :move-arm arm :total-time tm :start-offset-time 0.01 :use-torso nil :clear-velocities t))
(progn
(warning-message 3 "moveit environment is not correctly set, execute :angle-vector-raw instead~%")
(unless tm (setq tm :fast))
(return-from :angle-vector (send* self :angle-vector-raw av tm ctype args))))))
(setq ctype (or ctype controller-type)) ;; use default if ctype is nil
;; for simulation mode
(when (send self :simulation-modep)
(return-from :angle-vector (send self :angle-vector-raw av tm ctype start-time :scale scale :min-time min-time)))
(if (and (get self :moveit-environment)
(send (get self :moveit-environment) :robot))
(progn
(when (not (numberp tm))
(warning-message 3 ":angle-vector tm is not a number, use :angle-vector av tm args"))
(unless tm (setq tm 3000))
(send-super :angle-vector-motion-plan av :move-arm move-arm :total-time tm :start-offset-time 0.01 :use-torso nil :clear-velocities t))
(progn
(warning-message 3 "moveit environment is not correctly set, execute :angle-vector-raw instead~%")
(unless tm (setq tm :fast))
(return-from :angle-vector (send self :angle-vector-raw av tm ctype start-time :scale scale :min-time min-time)))))
(:angle-vector-sequence
(avs &optional tm (ctype controller-type) &rest args)
(let ((arm :arms))
(setq ctype (or ctype controller-type)) ;; use default if ctype is nil
(when (position :move-arm args)
(setq arm (elt args (+ (position :move-arm args) 1))))
;; for simulation mode
(when (send self :simulation-modep)
(return-from :angle-vector-sequence (send* self :angle-vector-sequence-raw avs tm ctype args)))
(if (and (get self :moveit-environment)
(send (get self :moveit-environment) :robot))
(progn
(when (not (numberp tm))
(warning-message 3 ":angle-vector-sequence tm is not a number, use :angle-vector-sequence av tm args"))
(unless tm (setq tm 3000))
(send-super :angle-vector-motion-plan avs :ctype ctype :move-arm arm :total-time tm :start-offset-time 0.01 :use-torso nil :clear-velocities t))
(progn
(warning-message 3 "moveit environment is not correctly set, execute :angle-vector-sequence-raw instead~%")
(unless tm (setq tm :fast))
(return-from :angle-vector-sequence (send* self :angle-vector-sequence-raw avs tm args))))))
(avs &optional tm (ctype controller-type) (start-time 0) &key (move-arm :arms) (scale 2.2) (min-time 0.05))
(setq ctype (or ctype controller-type)) ;; use default if ctype is nil
;; for simulation mode
(when (send self :simulation-modep)
(return-from :angle-vector-sequence (send self :angle-vector-sequence-raw avs tm ctype start-time :scale scale :min-time min-time)))
(if (and (get self :moveit-environment)
(send (get self :moveit-environment) :robot))
(progn
(when (not (numberp tm))
(warning-message 3 ":angle-vector-sequence tm is not a number, use :angle-vector-sequence av tm args"))
(unless tm (setq tm 3000))
(send-super :angle-vector-motion-plan avs :ctype ctype :move-arm move-arm :total-time tm :start-offset-time 0.01 :use-torso nil :clear-velocities t))
(progn
(warning-message 3 "moveit environment is not correctly set, execute :angle-vector-sequence-raw instead~%")
(unless tm (setq tm :fast))
(return-from :angle-vector-sequence (send self :angle-vector-sequence-raw avs tm ctype start-time :scale scale :min-time min-time)))))
(:ros-state-callback
(msg)
(let ((robot-msg-names (send msg :name)) (torso-index))
Expand Down

0 comments on commit 82b5ffe

Please sign in to comment.