|
1 | | -(defun nextage-collision-check () |
2 | | - (let ((ret (send *nextage* :self-collision-check))) |
3 | | - (when ret |
4 | | - (setq ret (remove-if #'(lambda (l) |
5 | | - (or (and (eq (car l) (send *nextage* :link "CHEST_JOINT0_Link")) |
6 | | - (eq (cdr l) (send *nextage* :link "HEAD_JOINT1_Link"))) |
7 | | - (and (eq (cdr l) (send *nextage* :link "CHEST_JOINT0_Link")) |
8 | | - (eq (car l) (send *nextage* :link "HEAD_JOINT1_Link"))) |
9 | | - (and (eq (car l) (send *nextage* :link "LARM_JOINT4_Link")) |
10 | | - (eq (cdr l) (send *nextage* :link "LARM_JOINT5_Link"))) |
11 | | - (and (eq (cdr l) (send *nextage* :link "LARM_JOINT4_Link")) |
12 | | - (eq (car l) (send *nextage* :link "LARM_JOINT5_Link"))) |
13 | | - (and (eq (car l) (send *nextage* :link "RARM_JOINT4_Link")) |
14 | | - (eq (cdr l) (send *nextage* :link "RARM_JOINT5_Link"))) |
15 | | - (and (eq (cdr l) (send *nextage* :link "RARM_JOINT4_Link")) |
16 | | - (eq (car l) (send *nextage* :link "RARM_JOINT5_Link"))))) |
17 | | - ret))) |
18 | | - ret)) |
| 1 | +(require "package://nextage_tutorials/nextage.l") |
| 2 | +(require "package://nextage_tutorials/euslisp/nextage-interface.l") |
| 3 | + |
| 4 | +(defmethod NextageOpen-robot |
| 5 | + (:inverse-kinematics |
| 6 | + (target-coords &rest args &key (avoid-collision-distance 5) &allow-other-keys) |
| 7 | + (let ((r) (original-av (send self :angle-vector))) |
| 8 | + (setq r (send-super* :inverse-kinematics target-coords :avoid-collision-distance avoid-collision-distance :warnp nil :dump-command nil args)) |
| 9 | + (unless r |
| 10 | + (format *error-output* "; failed for normal ik, try to start from ik-friendly position~%") |
| 11 | + (let* ((move-joints (send-all (cadr (memq :link-list args)) :joint)) |
| 12 | + (av-after-first-ik (send self :angle-vector))) |
| 13 | + (send self :angle-vector original-av) |
| 14 | + (send self :reset-pose) |
| 15 | + (send self :head :angle-vector #f(0 60)) |
| 16 | + (send self :larm :move-end-pos #f(0 0 50)) |
| 17 | + (send self :rarm :move-end-pos #f(0 0 50)) |
| 18 | + (mapcar #'(lambda (j a) |
| 19 | + (if (not (memq j move-joints)) |
| 20 | + (send j :joint-angle a))) |
| 21 | + (send self :joint-list) original-av) |
| 22 | + (setq r (send-super* :inverse-kinematics target-coords :avoid-collision-distance avoid-collision-distance :warnp nil :dump-command nil args)) |
| 23 | + (unless r |
| 24 | + (if (and (memq :revert-if-fail args) (null (cadr (memq :revert-if-fail args)))) |
| 25 | + (send self :angle-vector original-av) |
| 26 | + (send self :angle-vector av-after-first-ik))))) |
| 27 | + r)) |
| 28 | + (:l/r-reverse |
| 29 | + (av) |
| 30 | + (let ((av-tmp (copy-list av))) |
| 31 | + (setf (elt av-tmp 0) (- (elt av-tmp 0))) |
| 32 | + (setf (elt av-tmp 3) (- (elt av-tmp 3))) |
| 33 | + (setf (elt av-tmp 5) (- (elt av-tmp 5))) |
| 34 | + av-tmp)) |
| 35 | + (:self-collision-check (&rest args) |
| 36 | + (let ((ret (send-super* :self-collision-check args))) |
| 37 | + (when ret |
| 38 | + (setq ret (remove-if #'(lambda (l) |
| 39 | + (or (and (eq (car l) (send self :link "CHEST_JOINT0_Link")) |
| 40 | + (eq (cdr l) (send self :link "HEAD_JOINT1_Link"))) |
| 41 | + (and (eq (cdr l) (send self :link "CHEST_JOINT0_Link")) |
| 42 | + (eq (car l) (send self :link "HEAD_JOINT1_Link"))) |
| 43 | + (and (eq (car l) (send self :link "LARM_JOINT4_Link")) |
| 44 | + (eq (cdr l) (send self :link "LARM_JOINT5_Link"))) |
| 45 | + (and (eq (cdr l) (send self :link "LARM_JOINT4_Link")) |
| 46 | + (eq (car l) (send self :link "LARM_JOINT5_Link"))) |
| 47 | + (and (eq (car l) (send self :link "RARM_JOINT4_Link")) |
| 48 | + (eq (cdr l) (send self :link "RARM_JOINT5_Link"))) |
| 49 | + (and (eq (cdr l) (send self :link "RARM_JOINT4_Link")) |
| 50 | + (eq (car l) (send self :link "RARM_JOINT5_Link"))))) |
| 51 | + ret))) |
| 52 | + ret))) |
0 commit comments