Skip to content

Commit

Permalink
Merge pull request #541 from Naoki-Hiraoka/fix-calc-static-balance-point
Browse files Browse the repository at this point in the history
Fix calc static balance point
  • Loading branch information
k-okada authored Jul 10, 2019
2 parents 10f292c + 5653165 commit 36d6866
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions irteus/irtrobot.l
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@
"Calculate static balance point which is equivalent to static extended ZMP.
The output is expressed by the world coordinates.
target-points are end-effector points on which force-list and moment-list apply.
force-list [N] and moment-list [Nm] are list of force and moment at target-points.
force-list [N] and moment-list [Nm] are list of force and moment that robot receives at target-points.
static-balance-point-height is height of static balance point [mm]."
(let* ((sbp (float-vector 0 0 static-balance-point-height))
(mg (* 1e-6 (send self :weight update-mass-properties) (elt *g-vec* 2))))
Expand All @@ -1049,7 +1049,7 @@
(+ nume
(- (* (- (elt tp 2) static-balance-point-height) (elt f idx))
(* (elt tp idx) (elt f 2)))
(case idx (0 (- (elt m 1))) (1 (elt m 0))))
(* 1e3 (case idx (0 (elt m 1)) (1 (- (elt m 0))))))
denom (- denom (elt f 2))))
force-list moment-list target-points)
(setf (elt sbp idx) (/ nume denom))
Expand Down
48 changes: 48 additions & 0 deletions irteus/test/test-irt-motion.l
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,50 @@
(send robot :calc-static-balance-point :force-list (list #f(10 20 0) #f(25 20 0))))))
))

;; test for static balance point
(defun fullbody-ik-with-forces-moments (robot &key (debug-view :no-message))
(send robot :newcoords (make-coords))
(send robot :reset-pose)
(send robot :fix-leg-to-coords (make-coords))
(send robot :legs :move-end-pos (float-vector 0 0 50))
(send robot :fix-leg-to-coords (make-coords))
(objects (list robot))
(let* ((centroid-thre 10)
(force-list '(#f(10 20 0) #f(25 20 0)))
(moment-list '(#f(20 -10 0) #f(10 -20 0)))
(result
(send robot :fullbody-inverse-kinematics
(list (send robot :rleg :end-coords :copy-worldcoords)
(send robot :lleg :end-coords :copy-worldcoords)
(make-coords :pos #f(150 -300 600))
(make-coords :pos #f(150 300 600)))
:move-target (mapcar #'(lambda (x)
(send robot x :end-coords))
(list :rleg :lleg :rarm :larm))
:link-list (mapcar #'(lambda (x)
(send robot :link-list (send robot x :end-coords :parent)))
(list :rleg :lleg :rarm :larm))
:centroid-thre centroid-thre
:centroid-offset-func #'(lambda () (send robot :calc-static-balance-point :force-list force-list :moment-list moment-list))
:debug-view debug-view)))
(and result
(> centroid-thre (distance (apply #'midpoint 0.5 (send robot :legs :end-coords :worldpos))
(send robot :calc-static-balance-point :force-list force-list :moment-list moment-list)))
;;check static balance
;;The sum of force and moment that robot receives at target-points, ZMP and centroid should be almost zero (except yaw moment).
(> 1.0
(norm (subseq (transform (send robot :calc-grasp-matrix
(append (mapcar #'(lambda (x) (send robot x :end-coords :worldpos)) (list :rarm :larm))
(list (send robot :centroid)
(send (send robot :foot-midcoords) :worldpos))))
(concatenate float-vector
(mapcan #'(lambda (f m) (concatenate cons f m))
force-list moment-list)
(v- (scale (* 1e-6 (send robot :weight)) *g-vec*)) #F(0 0 0)
(v- (scale (* 1e-6 (send robot :weight)) *g-vec*) (reduce #'v+ force-list)) #F(0 0 0)))
0 5))))
))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; unit tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -954,6 +998,10 @@
(assert
(fullbody-ik-with-forces *sample-robot*)))

(deftest test-fullbody-ik-with-forces-moments-samplerobot
(assert
(fullbody-ik-with-forces-moments *sample-robot*)))

(deftest test-fullbody-ik-draw-param-check-samplerobot
(dotimes (i 5) (send *sample-robot* :move-centroid-on-foot :both '(:rleg :lleg)))
(assert
Expand Down

1 comment on commit 36d6866

@k-okada
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing jskeus documentation

Please check latest documents before merging

PDF version of Japanese jmanual: jmanual.pdf
HTML version of Japanese manual: jmanual.html
Sphinx (ReST) version of Japanese manual: jmanual.rst

Please sign in to comment.