|
66 | 66 | (upper-leg-weight 2152.7) (lower-leg-weight 898.7) (foot-weight 313.5)
|
67 | 67 | )
|
68 | 68 | (send-super* :init :name name args)
|
69 |
| - ;; 1. make links and assoc all links |
70 |
| - (let* ((aroot-link (send self :make-root-link waist-length waist-weight)) |
71 |
| - (torso-info (send self :make-torso-links torso-length torso-weight)) |
72 |
| - (torso (cdr (assoc :links torso-info))) |
73 |
| - (torso-end-coords (cdr (assoc :end-coords torso-info))) |
74 |
| - (torso-root-link (cdr (assoc :root-link torso-info))) |
75 |
| - (head-info (send self :make-head-links head-weight)) |
76 |
| - (head (cdr (assoc :links head-info))) |
77 |
| - (head-end-coords (cdr (assoc :end-coords head-info))) |
78 |
| - (head-root-link (cdr (assoc :root-link head-info))) |
79 |
| - (rarm-info (send self :make-arm-links :rarm |
80 |
| - arm-radius upper-arm-length lower-arm-length shoulder-width hand-length |
81 |
| - upper-arm-weight lower-arm-weight hand-weight)) |
82 |
| - (rarm (cdr (assoc :links rarm-info))) |
83 |
| - (rarm-end-coords (cdr (assoc :end-coords rarm-info))) |
84 |
| - (rarm-root-link (cdr (assoc :root-link rarm-info))) |
85 |
| - (larm-info (send self :make-arm-links :larm |
86 |
| - arm-radius upper-arm-length lower-arm-length shoulder-width hand-length |
87 |
| - upper-arm-weight lower-arm-weight hand-weight)) |
88 |
| - (larm (cdr (assoc :links larm-info))) |
89 |
| - (larm-end-coords (cdr (assoc :end-coords larm-info))) |
90 |
| - (larm-root-link (cdr (assoc :root-link larm-info))) |
91 |
| - (rleg-info (send self :make-leg-links :rleg |
92 |
| - leg-radius upper-leg-length lower-leg-length ankle-length crotch-width foot-depth foot-width foot-thickness foot-offset |
93 |
| - upper-leg-weight lower-leg-weight foot-weight)) |
94 |
| - (rleg (cdr (assoc :links rleg-info))) |
95 |
| - (rleg-end-coords (cdr (assoc :end-coords rleg-info))) |
96 |
| - (rleg-root-link (cdr (assoc :root-link rleg-info))) |
97 |
| - (lleg-info (send self :make-leg-links :lleg |
98 |
| - leg-radius upper-leg-length lower-leg-length ankle-length crotch-width foot-depth foot-width foot-thickness foot-offset |
99 |
| - upper-leg-weight lower-leg-weight foot-weight)) |
100 |
| - (lleg (cdr (assoc :links lleg-info))) |
101 |
| - (lleg-end-coords (cdr (assoc :end-coords lleg-info))) |
102 |
| - (lleg-root-link (cdr (assoc :root-link lleg-info)))) |
| 69 | + ;; 1. make links links and assoc all links |
| 70 | + (let ((aroot-link (send self :make-root-link waist-length waist-weight))) |
| 71 | + (setq torso (send self :make-torso-links torso-length torso-weight) |
| 72 | + head (send self :make-head-links head-weight) |
| 73 | + rarm (send self :make-arm-links :rarm |
| 74 | + arm-radius upper-arm-length lower-arm-length shoulder-width hand-length |
| 75 | + upper-arm-weight lower-arm-weight hand-weight) |
| 76 | + larm (send self :make-arm-links :larm |
| 77 | + arm-radius upper-arm-length lower-arm-length shoulder-width hand-length |
| 78 | + upper-arm-weight lower-arm-weight hand-weight) |
| 79 | + rleg (send self :make-leg-links :rleg |
| 80 | + leg-radius upper-leg-length lower-leg-length ankle-length crotch-width foot-depth foot-width foot-thickness foot-offset |
| 81 | + upper-leg-weight lower-leg-weight foot-weight) |
| 82 | + lleg (send self :make-leg-links :lleg |
| 83 | + leg-radius upper-leg-length lower-leg-length ankle-length crotch-width foot-depth foot-width foot-thickness foot-offset |
| 84 | + upper-leg-weight lower-leg-weight foot-weight)) |
103 | 85 | ;; arrange limbs
|
104 | 86 | (send (car rarm) :translate (float-vector 0 (- shoulder-width) (- torso-length 25)) :world)
|
105 | 87 | (send (car larm) :translate (float-vector 0 shoulder-width (- torso-length 25)) :world)
|
|
163 | 145 | jll0 jll1 jll2 jll3 jll4 jll5
|
164 | 146 | jlr0 jlr1 jlr2 jlr3 jlr4 jlr5
|
165 | 147 | ))
|
166 |
| - |
167 |
| - ;; add limbs |
168 |
| - (send self :add-limb :torso :links torso :end-coords torso-end-coords :root-link torso-root-link) |
169 |
| - (send self :add-limb :head :links head :end-coords head-end-coords :root-link head-root-link) |
170 |
| - (send self :add-limb :rarm :links rarm :end-coords rarm-end-coords :root-link rarm-root-link) |
171 |
| - (send self :add-limb :larm :links larm :end-coords larm-end-coords :root-link larm-root-link) |
172 |
| - (send self :add-limb :rleg :links rleg :end-coords rleg-end-coords :root-link rleg-root-link) |
173 |
| - (send self :add-limb :lleg :links lleg :end-coords lleg-end-coords :root-link lleg-root-link) |
174 |
| - |
175 | 148 | ;; These are for robot-model.
|
| 149 | + (setq larm-root-link (car larm) rarm-root-link (car rarm) |
| 150 | + lleg-root-link (car lleg) rleg-root-link (car rleg) |
| 151 | + torso-root-link (car torso) head-root-link (car head)) |
176 | 152 | (setq collision-avoidance-links (list aroot-link (elt torso 1) (elt larm 3) (elt rarm 3)))
|
177 | 153 |
|
178 | 154 | ;; set max torques
|
|
190 | 166 | ;; set sensors
|
191 | 167 | (setq force-sensors
|
192 | 168 | (mapcar #'(lambda (l)
|
193 |
| - (send (send self :limb l :end-coords :parent) :assoc |
194 |
| - (make-cascoords :coords (send self :limb l :end-coords :copy-worldcoords) |
| 169 | + (send (send self l :end-coords :parent) :assoc |
| 170 | + (make-cascoords :coords (send self l :end-coords :copy-worldcoords) |
195 | 171 | :name (format nil "~A-fsensor" (string-downcase l)))))
|
196 | 172 | (list :rarm :larm :rleg :lleg)))
|
197 | 173 | (setq imu-sensors
|
198 | 174 | (list (let ((sen (make-cascoords
|
199 |
| - :worldpos (send (car (send self :limb :torso :waist-p :child-link :bodies)) :centroid) |
| 175 | + :worldpos (send (car (send self :torso :waist-p :child-link :bodies)) :centroid) |
200 | 176 | :name "torso-imusensor")))
|
201 |
| - (send (send self :limb :torso :waist-p :child-link) :assoc sen) |
| 177 | + (send (send self :torso :waist-p :child-link) :assoc sen) |
202 | 178 | sen)))
|
203 | 179 | (setq cameras
|
204 | 180 | (mapcar #'(lambda (pos name)
|
205 | 181 | (let ((sen (instance camera-model :init (make-cylinder 10 20) :name name)))
|
206 | 182 | (send sen :rotate pi/2 :y)
|
207 | 183 | (send sen :rotate -pi/2 :z)
|
208 |
| - (send sen :locate (v+ pos (send (car (send (send self :limb :head :neck-p :child-link) :bodies)) :centroid)) :world) |
209 |
| - (send (send self :limb :head :neck-p :child-link) :assoc sen) |
| 184 | + (send sen :locate (v+ pos (send (car (send (send self :head :neck-p :child-link) :bodies)) :centroid)) :world) |
| 185 | + (send (send self :head :neck-p :child-link) :assoc sen) |
210 | 186 | sen))
|
211 | 187 | (list (float-vector 0 30 0) (float-vector 0 -30 0))
|
212 | 188 | (list "left-camera" "right-camera")))
|
|
229 | 205 | (send bc2 :set-color :green)
|
230 | 206 | (setq bc2 (instance bodyset-link :init (make-cascoords :pos #f(0 0 -12.5)) :bodies (list bc2) :name :torso-link1 :weight torso-weight))
|
231 | 207 | (send bc1 :assoc bc2)
|
232 |
| - (list (cons :links (list bc1 bc2)) |
233 |
| - (cons :root-link bc1)))) |
| 208 | + (list bc1 bc2))) |
234 | 209 | (:make-head-links
|
235 | 210 | (head-weight)
|
236 | 211 | (let ((bh0 (make-default-robot-link 0 50 :y :head-link0))
|
237 | 212 | (bh2 (make-cube 120 100 150))
|
238 | 213 | (bh2e (make-cylinder 10 30))
|
239 |
| - (bh1) |
240 |
| - (end-coords)) |
| 214 | + (bh1)) |
241 | 215 | (send bh2 :locate #f(0 0 80))
|
242 | 216 | (send bh2 :set-color :green)
|
243 | 217 | (send bh2e :rotate pi/2 :y)
|
244 | 218 | (send bh2e :locate #f(60 0 70) :world)
|
245 | 219 | (send bh2e :set-color :green)
|
246 | 220 | (send bh2 :assoc bh2e)
|
247 | 221 | (setq bh1 (instance bodyset-link :init (make-cascoords) :bodies (list bh2 bh2e) :name :head-link1 :weight head-weight))
|
248 |
| - (setq end-coords (make-cascoords :pos #f(60 0 100) :rpy (float-vector 0 pi/2 0))) |
249 |
| - (send bh1 :assoc end-coords) |
| 222 | + (setq head-end-coords (make-cascoords :pos #f(60 0 100) :rpy (float-vector 0 pi/2 0))) |
| 223 | + (send bh1 :assoc head-end-coords) |
250 | 224 | (send bh0 :assoc bh1)
|
251 |
| - (list (cons :links (list bh0 bh1)) |
252 |
| - (cons :root-link bh0) |
253 |
| - (cons :end-coords end-coords)))) |
| 225 | + (list bh0 bh1))) |
254 | 226 | (:make-arm-links
|
255 | 227 | (l/r arm-radius upper-arm-length lower-arm-length shoulder-width hand-length
|
256 | 228 | upper-arm-weight lower-arm-weight hand-weight)
|
|
260 | 232 | (ba4 (make-default-robot-link lower-arm-length arm-radius :y (read-from-string (format nil "~A-link3" l/r))))
|
261 | 233 | (ba5 (make-default-robot-link 0 arm-radius :z (read-from-string (format nil "~A-link4" l/r))))
|
262 | 234 | (ba6 (make-default-robot-link 0 arm-radius :x (read-from-string (format nil "~A-link5" l/r))))
|
263 |
| - (ba7 (make-default-robot-link hand-length arm-radius :y (read-from-string (format nil "~A-link6" l/r)))) |
264 |
| - (end-coords)) |
| 235 | + (ba7 (make-default-robot-link hand-length arm-radius :y (read-from-string (format nil "~A-link6" l/r))))) |
265 | 236 | (send ba3 :weight upper-arm-weight)
|
266 | 237 | (send ba4 :weight lower-arm-weight)
|
267 | 238 | (send ba7 :weight hand-weight)
|
268 | 239 | (case l/r
|
269 | 240 | (:rarm
|
270 |
| - (setq end-coords (make-cascoords)) |
271 |
| - (send end-coords :locate (float-vector 0 0 (- hand-length))) |
272 |
| - (send end-coords :rotate pi/2 :y) |
273 |
| - (send ba7 :assoc end-coords)) |
| 241 | + (setq rarm-end-coords (make-cascoords)) |
| 242 | + (send rarm-end-coords :locate (float-vector 0 0 (- hand-length))) |
| 243 | + (send rarm-end-coords :rotate pi/2 :y) |
| 244 | + (send ba7 :assoc rarm-end-coords)) |
274 | 245 | (:larm
|
275 |
| - (setq end-coords (make-cascoords)) |
276 |
| - (send end-coords :locate (float-vector 0 0 (- hand-length))) |
277 |
| - (send end-coords :rotate pi/2 :y) |
278 |
| - (send ba7 :assoc end-coords))) |
| 246 | + (setq larm-end-coords (make-cascoords)) |
| 247 | + (send larm-end-coords :locate (float-vector 0 0 (- hand-length))) |
| 248 | + (send larm-end-coords :rotate pi/2 :y) |
| 249 | + (send ba7 :assoc larm-end-coords))) |
279 | 250 | (send ba6 :assoc ba7)
|
280 | 251 | (send ba5 :assoc ba6)
|
281 | 252 | (send ba5 :translate (float-vector 0 0 (- lower-arm-length)) :world)
|
|
284 | 255 | (send ba3 :assoc ba4)
|
285 | 256 | (send ba2 :assoc ba3)
|
286 | 257 | (send ba1 :assoc ba2)
|
287 |
| - (list (cons :links (list ba1 ba2 ba3 ba4 ba5 ba6 ba7)) |
288 |
| - (cons :root-link ba1) |
289 |
| - (cons :end-coords end-coords)))) |
| 258 | + (list ba1 ba2 ba3 ba4 ba5 ba6 ba7))) |
290 | 259 | (:make-leg-links
|
291 | 260 | (l/r leg-radius upper-leg-length lower-leg-length ankle-length crotch-width foot-depth foot-width foot-thickness foot-offset
|
292 | 261 | upper-leg-weight lower-leg-weight foot-weight)
|
|
296 | 265 | (bl4 (make-default-robot-link (- lower-leg-length (/ leg-radius 2.0)) leg-radius :y (read-from-string (format nil "~A-link3" l/r))))
|
297 | 266 | (bl5 (make-default-robot-link 0 leg-radius :x (read-from-string (format nil "~A-link4" l/r))))
|
298 | 267 | (bl6b (make-cube foot-depth foot-width foot-thickness))
|
299 |
| - (bl6) |
300 |
| - (end-coords)) |
| 268 | + (bl6)) |
301 | 269 | (send bl3 :weight upper-leg-weight)
|
302 | 270 | (send bl4 :weight lower-leg-weight)
|
303 | 271 | (send bl6b :locate (float-vector foot-offset 0 (- ankle-length)))
|
|
306 | 274 | (send bl6 :weight foot-weight)
|
307 | 275 | (case l/r
|
308 | 276 | (:rleg
|
309 |
| - (setq end-coords (make-cascoords)) |
310 |
| - (send end-coords :locate (float-vector 0 0 (- (+ ankle-length (/ foot-thickness 2.0))))) |
311 |
| - (send bl6 :assoc end-coords)) |
| 277 | + (setq rleg-end-coords (make-cascoords)) |
| 278 | + (send rleg-end-coords :locate (float-vector 0 0 (- (+ ankle-length (/ foot-thickness 2.0))))) |
| 279 | + (send bl6 :assoc rleg-end-coords)) |
312 | 280 | (:lleg
|
313 |
| - (setq end-coords (make-cascoords)) |
314 |
| - (send end-coords :locate (float-vector 0 0 (- (+ ankle-length (/ foot-thickness 2.0))))) |
315 |
| - (send bl6 :assoc end-coords))) |
| 281 | + (setq lleg-end-coords (make-cascoords)) |
| 282 | + (send lleg-end-coords :locate (float-vector 0 0 (- (+ ankle-length (/ foot-thickness 2.0))))) |
| 283 | + (send bl6 :assoc lleg-end-coords))) |
316 | 284 | (send bl5 :assoc bl6)
|
317 | 285 | (send bl5 :translate (float-vector 0 0 (- lower-leg-length)) :world)
|
318 | 286 | (send bl4 :assoc bl5)
|
319 | 287 | (send bl4 :translate (float-vector 0 0 (- upper-leg-length)) :world)
|
320 | 288 | (send bl3 :assoc bl4)
|
321 | 289 | (send bl2 :assoc bl3)
|
322 | 290 | (send bl1 :assoc bl2)
|
323 |
| - (list (cons :links (list bl1 bl2 bl3 bl4 bl5 bl6)) |
324 |
| - (cons :root-link bl1) |
325 |
| - (cons :end-coords end-coords)))) |
| 291 | + (list bl1 bl2 bl3 bl4 bl5 bl6))) |
326 | 292 | (:reset-pose ()
|
327 | 293 | (send self :angle-vector #f(0.0 0.0 0.0 0.0 10.0 20.0 0.0 -20.0 10.0 0.0 0.0 10.0 20.0 0.0 -20.0 10.0 0.0 0.0 0.0 0.0 -15.0 30.0 -15.0 0.0 0.0 0.0 -15.0 30.0 -15.0 0.0)))
|
328 | 294 | )
|
|
0 commit comments