|
871 | 871 | (send robot :calc-static-balance-point :force-list (list #f(10 20 0) #f(25 20 0)))))) |
872 | 872 | )) |
873 | 873 |
|
| 874 | +;; test for static balance point |
| 875 | +(defun fullbody-ik-with-forces-moments (robot &key (debug-view :no-message)) |
| 876 | + (send robot :newcoords (make-coords)) |
| 877 | + (send robot :reset-pose) |
| 878 | + (send robot :fix-leg-to-coords (make-coords)) |
| 879 | + (send robot :legs :move-end-pos (float-vector 0 0 50)) |
| 880 | + (send robot :fix-leg-to-coords (make-coords)) |
| 881 | + (objects (list robot)) |
| 882 | + (let* ((centroid-thre 10) |
| 883 | + (force-list '(#f(10 20 0) #f(25 20 0))) |
| 884 | + (moment-list '(#f(20 -10 0) #f(10 -20 0))) |
| 885 | + (result |
| 886 | + (send robot :fullbody-inverse-kinematics |
| 887 | + (list (send robot :rleg :end-coords :copy-worldcoords) |
| 888 | + (send robot :lleg :end-coords :copy-worldcoords) |
| 889 | + (make-coords :pos #f(150 -300 600)) |
| 890 | + (make-coords :pos #f(150 300 600))) |
| 891 | + :move-target (mapcar #'(lambda (x) |
| 892 | + (send robot x :end-coords)) |
| 893 | + (list :rleg :lleg :rarm :larm)) |
| 894 | + :link-list (mapcar #'(lambda (x) |
| 895 | + (send robot :link-list (send robot x :end-coords :parent))) |
| 896 | + (list :rleg :lleg :rarm :larm)) |
| 897 | + :centroid-thre centroid-thre |
| 898 | + :centroid-offset-func #'(lambda () (send robot :calc-static-balance-point :force-list force-list :moment-list moment-list)) |
| 899 | + :debug-view debug-view))) |
| 900 | + (and result |
| 901 | + (> centroid-thre (distance (apply #'midpoint 0.5 (send robot :legs :end-coords :worldpos)) |
| 902 | + (send robot :calc-static-balance-point :force-list force-list :moment-list moment-list))) |
| 903 | + ;;check static balance |
| 904 | + ;;The sum of force and moment that robot receives at target-points, ZMP and centroid should be almost zero (except yaw moment). |
| 905 | + (> 1.0 |
| 906 | + (norm (subseq (transform (send robot :calc-grasp-matrix |
| 907 | + (append (mapcar #'(lambda (x) (send robot x :end-coords :worldpos)) (list :rarm :larm)) |
| 908 | + (list (send robot :centroid) |
| 909 | + (send (send robot :foot-midcoords) :worldpos)))) |
| 910 | + (concatenate float-vector |
| 911 | + (mapcan #'(lambda (f m) (concatenate cons f m)) |
| 912 | + force-list moment-list) |
| 913 | + (v- (scale (* 1e-6 (send robot :weight)) *g-vec*)) #F(0 0 0) |
| 914 | + (v- (scale (* 1e-6 (send robot :weight)) *g-vec*) (reduce #'v+ force-list)) #F(0 0 0))) |
| 915 | + 0 5)))) |
| 916 | + )) |
| 917 | + |
874 | 918 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
875 | 919 | ;; unit tests |
876 | 920 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
954 | 998 | (assert |
955 | 999 | (fullbody-ik-with-forces *sample-robot*))) |
956 | 1000 |
|
| 1001 | +(deftest test-fullbody-ik-with-forces-moments-samplerobot |
| 1002 | + (assert |
| 1003 | + (fullbody-ik-with-forces-moments *sample-robot*))) |
| 1004 | + |
957 | 1005 | (deftest test-fullbody-ik-draw-param-check-samplerobot |
958 | 1006 | (dotimes (i 5) (send *sample-robot* :move-centroid-on-foot :both '(:rleg :lleg))) |
959 | 1007 | (assert |
|
0 commit comments