Skip to content

Commit 235777d

Browse files
committed
Merge pull request start-jsk#129 from hyaguchijsk/hrp2w_grasp_and_base_control
Hrp2w grasp and base control
2 parents 766df9b + bd8d188 commit 235777d

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

hrpsys_ros_bridge_tutorials/euslisp/hrp2w-interface.l

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,52 @@
1010
(:init (&rest args)
1111
(send-super* :init :robot hrp2w-robot args)))
1212

13-
(defun hrp2w-init ()
13+
;; methods for grasp controller
14+
(defmethod hrp2w-interface
15+
(:start-grasp
16+
(limb &key (target-error 0.15) (gain-percentage 5) &rest args)
17+
(case limb
18+
(:larm
19+
(send* self :set-servo-gain-percentage
20+
"LARM_JOINT7" gain-percentage args)
21+
(send* self :graspcontrollerservice_startgrasp
22+
:name "LHAND"
23+
:target_error target-error args))
24+
(:rarm
25+
(send* self :set-servo-gain-percentage
26+
"RARM_JOINT7" gain-percentage args)
27+
(send* self :graspcontrollerservice_startgrasp
28+
:name "RHAND"
29+
:target_error target-error args))
30+
)
31+
)
32+
(:stop-grasp
33+
(limb &rest args)
34+
(case limb
35+
(:larm
36+
(send* self :set-servo-gain-percentage "LARM_JOINT7" 100 args)
37+
(send* self :graspcontrollerservice_stopgrasp
38+
:name "LHAND"
39+
args))
40+
(:rarm
41+
(send* self :set-servo-gain-percentage "RARM_JOINT7" 100 args)
42+
(send* self :graspcontrollerservice_stopgrasp
43+
:name "RHAND"
44+
args))
45+
)
46+
)
47+
)
48+
49+
(defun hrp2w-init (&key (sim nil))
1450
(if (not (boundp '*ri*))
1551
(setq *ri* (instance hrp2w-interface :init)))
1652
(if (not (boundp '*hrp2w*))
17-
(setq *hrp2w* (instance hrp2w-robot :init))))
53+
(setq *hrp2w* (instance hrp2w-robot :init)))
54+
(unless sim
55+
(if (not (boundp '*vmax*))
56+
(progn
57+
(require :vmax "package://vmax_controller/euslisp/vmax-interface.l")
58+
(setq *vmax* (instance vmax-interface :init)))))
59+
(setq ((send *hrp2w* :head :neck-p) . max-angle) 44)
60+
)
61+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
;; stop and start grasp
2+
(defun hrp2w-stop-grasp (limb)
3+
(when (boundp '*hrp2w*)
4+
(case limb
5+
(:larm
6+
(send *hrp2w* :larm :thumb-r :joint-angle -45.0)
7+
)
8+
(:rarm
9+
(send *hrp2w* :rarm :thumb-r :joint-angle 45.0)
10+
))
11+
(when (boundp '*ri*)
12+
(send *ri* :angle-vector (send *hrp2w* :angle-vector) 1000)
13+
(send *ri* :wait-interpolation)
14+
(send *ri* :stop-grasp limb)
15+
)
16+
)
17+
)
18+
19+
(defun hrp2w-start-grasp (limb &key
20+
(angle 0.0)
21+
(target-error 0.15)
22+
(gain-percentage 5))
23+
(when (boundp '*hrp2w*)
24+
(case limb
25+
(:larm
26+
(send *hrp2w* :larm :thumb-r :joint-angle angle)
27+
)
28+
(:rarm
29+
(send *hrp2w* :rarm :thumb-r :joint-angle angle)
30+
))
31+
(when (boundp '*ri*)
32+
(send *ri* :start-grasp limb
33+
:target-error target-error
34+
:gain-percentage gain-percentage)
35+
(send *ri* :angle-vector (send *hrp2w* :angle-vector) 1000)
36+
(send *ri* :wait-interpolation)
37+
)
38+
)
39+
)

0 commit comments

Comments
 (0)