-
Notifications
You must be signed in to change notification settings - Fork 3
/
aizuspider-interface.l
163 lines (160 loc) · 5.33 KB
/
aizuspider-interface.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
(require :aizuspider "package://aizuspider_description/AizuSpiderSS.l")
(require :robot-interface "package://pr2eus/robot-interface.l")
(defclass aizuspider-interface
;;:super robot-move-base-interface
:super robot-interface
:slots ()
)
(defmethod aizuspider-interface
(:init
(&rest args)
(let ((r (instance AizuSpiderSS-robot :init)))
;; make controller configuration from joint-list
#|
(dolist (limb (list 'rarm 'lleg 'rleg))
(let ((key (intern (string limb) *keyword-package*))
(mname (intern (string-upcase (format nil "~A-controller" limb)) *keyword-package*))
)
;;
(eval
`(defmethod aizuspider-interface
(,mname
nil
(list
(list
(cons :controller-action ,(format nil "~A_controller/follow_joint_trajectory" limb) )
(cons :controller-state ,(format nil "~A_controller/state" limb) )
(cons :action-type control_msgs::FollowJointTrajectoryAction)
(cons :joint-names
',(mapcar #'(lambda (j) (send j :name)) (send r key :joint-list)) )
)
)))
)
))
|#
;;
(send-super*
:init
:robot r
;; :namespace "AizuSpider"
;; :move-base-action-name "move_base"
;; :base-frame-id "/base_link"
;; :odom-topic "/odom"
:groupname "aizuspider_interface" args)
)
;;
#|
(dolist (ct (list :rarm-controller
:rleg-controller
:lleg-controller))
(send self :add-controller ct :create-actions nil))
|#
)
;;
#|
(:default-controller nil
(append (send self :rarm-controller)
(send self :rleg-controller)
(send self :lleg-controller))
)
|#
(:default-controller nil
(list
(list
(cons :controller-action "fullbody_controller/follow_joint_trajectory")
(cons :controller-state "fullbody_controller/state")
(cons :action-type control_msgs::FollowJointTrajectoryAction)
(cons :joint-names (list "FR_FLIPPER" "FL_FLIPPER" "BR_FLIPPER" "BL_FLIPPER"
"SHOULDER" "ARM" "FOREARM" "WRIST1" "WRIST2" "HAND"
"FINGER1" "FINGER2" "FINGER3"
))
))
)
#|
(:rarm-controller nil
(list
(list
(cons :controller-action "rarm_controller/follow_joint_trajectory")
(cons :controller-state "rarm_controller/state")
(cons :action-type control_msgs::FollowJointTrajectoryAction)
(cons :joint-names (list "r_shoulder_p_joint" "r_shoulder_r_joint" "r_shoulder_y_joint"
"r_elbow_joint" "r_wrist_y_joint" "r_wrist_p_joint" "r_wrist_r_joint"
"r_hand_y_joint"
))
))
)
(:larm-controller nil
(list
(list
(cons :controller-action "larm_controller/follow_joint_trajectory")
(cons :controller-state "larm_controller/state")
(cons :action-type control_msgs::FollowJointTrajectoryAction)
(cons :joint-names (list "l_shoulder_p_joint" "l_shoulder_r_joint" "l_shoulder_y_joint"
"l_elbow_joint" "l_wrist_y_joint" "l_wrist_p_joint" "l_wrist_r_joint"
"l_hand_y_joint"
))
))
)
|#
(:start-grasp
(&rest args &key (tm 1000) (position 90) &allow-other-keys)
(let ((av (send self :state :reference-vector)))
(setf (elt av 6) position)
(setf (elt av 7) position)
(setf (elt av 8) position)
(send *ri* :angle-vector av tm)
))
(:stop-grasp
(&rest args &key (tm 1000) &allow-other-keys)
(let ((av (send self :state :reference-vector)))
(setf (elt av 6) 0)
(setf (elt av 7) 0)
(setf (elt av 8) 0)
(send *ri* :angle-vector av tm)
))
)
(defun aizuspider-init (&rest args &key (namespace "AizuSpider") &allow-other-keys)
(if (not (boundp '*ri*))
(setq *ri* (instance* aizuspider-interface :init
:namespace namespace args)))
(if (not (boundp '*robot*))
(setq *robot* (AizuSpiderSS)))
)
;;;;; okiagari functions (thanks to Iori Yanokura[https://github.com/iory] )
(defun okiagari-right ()
;; reset pose
(send *robot* :reset-pose)
(send *ri* :angle-vector (send *robot* :angle-vector) 1000)
(send *ri* :wait-interpolation)
;;
(send *robot* :rarm :move-end-pos #f(0 -500 -300))
(send *ri* :angle-vector
(send *robota* :angle-vector) 100);;??
(send *ri* :wait-interpolation)
;;
(send *robot* :reset-pose)
(send *ri* :angle-vector (send *robot* :angle-vector) 1000)
(send *ri* :wait-interpolation)
)
(defun okiagari-left ()
;; reset pose
(send *robot* :reset-pose)
(send *ri* :angle-vector (send *robot* :angle-vector) 1000)
(send *ri* :wait-interpolation)
;;
(send *robot* :rarm :move-end-pos #f(0 -500 -300))
(send *ri* :angle-vector
(send *robota* :angle-vector) 100);;??
(send *ri* :wait-interpolation)
;;
(send *robota* :rarm :move-end-pos #f(0 0 -200))
(send *robota* :forearm :joint-angle 90)
(send *ri* :angle-vector
(send *robota* :angle-vector) 100);;??
(send *ri* :wait-interpolation)
;;
(send *robot* :reset-pose)
(send *ri* :angle-vector (send *robot* :angle-vector) 1000)
(send *ri* :wait-interpolation)
)
;;;;;