Skip to content

Commit 9c5bf4d

Browse files
committed
add detail documentation of inverse-kinematics
1 parent e574c8c commit 9c5bf4d

File tree

2 files changed

+136
-36
lines changed

2 files changed

+136
-36
lines changed

irteus/irtmodel.l

Lines changed: 116 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@
11171117
(tmp-v3b (instantiate float-vector 3))
11181118
(tmp-m33 (make-matrix 3 3))
11191119
&allow-other-keys)
1120-
"Calculate jacobian matrix from link-list and move-target. Unit system is [m] or [rad], not [mm] or [deg]."
1121-
"Joint order for this jacobian matrix follows link-list order. Joint torque[Nm] order is also the same.
1120+
"Calculate jacobian matrix from link-list and move-target. Jacobian is represented in :transform-coords. Unit system is [m] or [rad], not [mm] or [deg].
1121+
Joint order for this jacobian matrix follows link-list order. Joint torque[Nm] order is also the same.
11221122
Ex1. One-Arm
11231123
(setq *rarm-link-list* (send *robot* :link-list (send *robot* :rarm :end-coords :parent)))
11241124
(send-all *rarm-link-list* :joint)
@@ -1729,7 +1729,41 @@
17291729
(tmp-mcc (make-matrix fik-len fik-len))
17301730
(tmp-mcc2 (make-matrix fik-len fik-len))
17311731
(debug-view) (jacobi)
1732-
&allow-other-keys)
1732+
&allow-other-keys)
1733+
":move-joints-avoidance is called in :inverse-kinematics-loop. In this method, calculation of joint position difference are executed and joint positon are moved.
1734+
Optional arguments:
1735+
~ :weight
1736+
~~ float-vector of inverse weight of velocity of each joint or a function which returns the float-vector or a list which returns the float-vector. Length of the float-vector should be same as the number of columns of the jacobian. If :weight is a function or a list, it is called in each IK loop as (funcall weight union-link-list) or (eval weight). :weight is used in calculation of weighted norm of joint velocity for sr-inverse. Default is the float-vector filled with 1.
1737+
~ :null-space
1738+
~~ float-vector of joint velocity or a function which returns the float-vector or a list which returns the float-vector. Length of the float-vector should be same as the number of columns of the jacobian. If :null-space is a function or a list, it is called in each IK loop as (funcall null-space) or (eval null-space). This joint velocity is applied in null space of main task in each IK loop. Default is nil.
1739+
~ :avoid-nspace-gain
1740+
~ gain of joint velocity to avoid joint limit applied in null space of main task in each IK loop. The avoiding velocity is calculated as $(((t_max + t_min)/2 - t) / ((t_max - t_min)/2))^2$. Default is 0.01.
1741+
~ :avoid-weight-gain
1742+
~~ gain of dH/dt in calcuration of avoiding joint limits weight. :weight is devided by this avoiding joint limits weight. Default is 1.0.
1743+
~~ If :avoid-nspace-gain is 0, :weight is multipled by :weight instead.
1744+
~ :avoid-collision-distance
1745+
~~ yellow zone. 0.1avoid-collision-distance is regarded as orange zone.
1746+
~~ If :avoid-collision-joint-gain is smaller than or equal to 0.0, yellow zone and orange zone become inactive. Default is 200[mm].
1747+
~ :avoid-collision-null-gain
1748+
~~ $k_{null}$. Default is 1.0.
1749+
~ :avoid-collision-joint-gain
1750+
~~ $k_{joint}$. Default is 1.0.
1751+
~ :collision-avoidance-link-pair
1752+
~~ (list (list link1 link2) (list link3 link4) ...) with any length. Collision between paired links is cared. Default is (send self :collision-avoidance-link-pair-from-link-list link-list :obstacles (cadr (memq :obstacles args))).
1753+
~ :additional-weight-list
1754+
~~ (list (list target-link1 additional-weight1) (list target-link2 additional-weight2) ...) with any length. The component of :weight corresponding to the parent joint of target-link is scaled by additional-weight. additional-weight should be float (if 1 dof), float-vector with length of the joint dof, or a function which returns the float or float-vector. if additional-weight is a function, it is called in each IK loop as (funcall additional-weight). Default is nil.
1755+
~ :additional-nspace-list
1756+
~~ (list (list target-link1 var1) (list target-link2 var2) ...) with any length. In each IK loop, the parent joint of target-link is moved by the amount of var in null space of main task. var should be float (if 1dof), float-vector with the same length of the target joint dof, or a function which returns the float or float-vector.If var is float-vector, it is called in each IK loop as (funcall var). Default is nil.
1757+
~ other-keys
1758+
~~ :manipulability-limit
1759+
~~~ If manipulability of jacobian is smaller than manipulability-limit, diagonal matrix is added in calculation of sr-inverse. Default is 0.1.
1760+
~ :manipulability-gain
1761+
~~ Weight of diagonal matrix in calculation of sr-inverse. Weight is calculated as (* manipulability-gain (expt (- 1.0 (/ manipulability manipulability-limit)) 2)). Default is 0.001.
1762+
~~ :collision-distance-limit
1763+
~~~ Threshold for collision detection. If collision is detected, the distance between the colliding links is considered to be :collision-distance-limit instead of actual distance. Default is 10[mm].
1764+
~~ :move-joints-hook
1765+
~~~ A function which is called right after joints are moved in each IK loop as (funcall move-joints-hook). Default is nil.
1766+
"
17331767
(let* (joint-angle-limit-nspace
17341768
dav dtheta
17351769
null-space-collision-avoidance
@@ -2005,17 +2039,31 @@
20052039
":inverse-kinematics-loop is one loop calculation for :inverse-kinematics.
20062040
In this method, joint position difference satisfying workspace difference (dif-pos, dif-rot) are calculated and euslisp model joint angles are updated.
20072041
Optional arguments:
2008-
:additional-check
2009-
This argument is to add optional best-effort convergence conditions.
2010-
:additional-check should be function or lambda.
2011-
best-effort => In :inverse-kinematics-loop, 'success' is overwritten by '(and success additional-check)'
2012-
In :inverse-kinematics, 'success is not overwritten.
2013-
So, :inverse-kinematics-loop wait until ':additional-check' becomes 't' as possible,
2014-
but ':additional-check' is neglected in the final :inverse-kinematics return.
2015-
:min-loop
2016-
Minimam loop count (nil by default).
2017-
If integer is specified, :inverse-kinematics-loop does returns :ik-continues and continueing solving IK.
2018-
If min-loop is nil, do not consider loop counting for IK convergence.
2042+
~ :dif-pos-ratio
2043+
~~ Ratio of spacial velocity used in calculation of joint position difference to workspace difference (after :p-limit applied). Default is 1.0.
2044+
~ :dif-rot-ratio
2045+
~~ Ratio of angular velocity used in calculation of joint position difference to workspace difference (after :r-limit applied). Default is 1.0.
2046+
~ :jacobi
2047+
~~ A jacobian of all move-target or a function that returns the jacobian. When a function is given, It is called in every IK loop as (funcall jacobi link-list move-target translation-axis rotation-axis). Default is (send* self :calc-jacobian-from-link-list link-list :translation-axis translation-axis :rotation-axis rotation-axis :move-target move-target method-args).
2048+
~ :additional-check
2049+
~~ This argument is to add optional best-effort convergence conditions. Default is nil (no additional check). :additional-check should be function or lambda.
2050+
~~ best-effort =>
2051+
~~~ In :inverse-kinematics-loop, 'success' is overwritten by '(and success additional-check)'
2052+
~~~ In :inverse-kinematics, 'success is not overwritten.
2053+
~~~ So, :inverse-kinematics-loop wait until ':additional-check' becomes 't' as possible,
2054+
~~~ but ':additional-check' is neglected in the final :inverse-kinematics return.
2055+
~ :cog-gain
2056+
~~ Ratio of centroid velocity used in calculation of joint position difference to centroid position difference. max 1.0. Default is 1.0.
2057+
~ :min-loop
2058+
~~ Minimam loop count. Defalt (/ stop 10).
2059+
~~ If integer is specified, :inverse-kinematics-loop does returns :ik-continues and continueing solving IK.
2060+
~~ If min-loop is nil, do not consider loop counting for IK convergence.
2061+
~ other-keys
2062+
~~ :move-joints-avoidance is internally called and args are passed to it. See the explanation of :move-joints-avoidance.
2063+
~~ :p-limit
2064+
~~~ Maximum spacial velocity of each move-target in one IK loop. Default is 100.0[mm].
2065+
~~ :r-limit
2066+
~~~ Maximum angular velocity of each move-target in one IK loop. Default is 0.5[rad].
20192067
"
20202068
(if target-centroid-pos (send self :update-mass-properties))
20212069
;; dif-pos, dif-rot, move-target, rotation-axis, translation-axis, link-list
@@ -2219,27 +2267,62 @@
22192267
(additional-jacobi) (additional-vel)
22202268
&allow-other-keys)
22212269
"Move move-target to target-coords.
2270+
;; target-coords, link-list and move-target need to be given.
22222271
;; target-coords, move-target, rotation-axis, translation-axis, link-list
22232272
;; -> both list and atom OK.
2224-
target-coords : The coordinate of the target, or a function that returns coordinates. Use a list of targets to solve the IK relative to multiple end links simultaneously.
2225-
link-list : List of links to control. When the target-coords is list, this should be a list of lists.
2226-
move-target : Specify end-effector coordinate. When the target-coords is list, this should be list too.
2227-
stop : Maximum number for IK iteration. Default is 50.
2228-
debug-view : Set t to show debug message and visualization. Use :no-message to just show the irtview image. Default is nil.
2229-
warnp : Set nil to not display debug message when the IK failed. Default is t.
2230-
revert-if-fail : Set nil to keep the angle posture of IK solve iteration. Default is t, which return to original position when IK fails.
2231-
rotation-axis : Use nil for position only IK. :x, :y, :z for the constraint around axis with plus direction, :-x :-y :-z for axis with minus direction. :zz :yy :zz for direction free axis. :xm :ym :zm for allowing rotation with respect to mirror direction. When the target-coords is list, this should be list too. Default is t.
2232-
translation-axis : :x :y :z for constraint along the x, y, z axis. :xy :yz :zx for plane. Default is t.
2233-
thre : Threshold for position error to terminate IK iteration. Default is 1 [mm].
2234-
rthre : Threshold for rotation error to terminate IK iteration. Default is 0.017453 [rad] (1 deg).
2235-
check-collision : Set t to return false when self collision occurs at found IK solution. Default is nil. To avoid collision within IK loop, use set links to collision-avoidance-links slot of cascaded-link.
2236-
dump-command : should be t, nil, :always, :fail-only, :always-with-debug-log, or :fail-only-with-debug-log.
2237-
Log are success/fail log and ik debug information log.
2238-
t or :always : dump log both in success and fail (for success/fail log).
2239-
:always-with-debug-log : dump log both in success and fail (for success/fail log and ik debug information log).
2240-
:fail-only : dump log only in fail (for success/fail log).
2241-
:always-with-debug-log : dump log only in fail (for success/fail log and ik debug information log).
2242-
nil : do not dump log."
2273+
:target-coords
2274+
~ The coordinate of the target, or a function that returns coordinates. When a function is given, it is called in every IK loop as (funcall target-coords). Use a list of targets to solve the IK relative to multiple end links simultaneously.
2275+
:stop
2276+
~ Maximum number for IK iteration. Default is 50.
2277+
:link-list
2278+
~ List of links to control. When the target-coords is list, this should be a list of lists.
2279+
:move-target
2280+
~ Specify end-effector coordinate. When the target-coords is list, this should be list too.
2281+
:debug-view
2282+
~ Set t to show debug message and visualization. Use :no-message to just show the irtview image. Default is nil.
2283+
:warnp
2284+
~ Set nil to not display debug message when the IK failed. Default is t.
2285+
:revert-if-fail
2286+
~ Set nil to keep the angle posture of IK solve iteration. Default is t, which return to original position when IK fails.
2287+
:rotation-axis
2288+
~ Use nil for position only IK. :x, :y, :z for the constraint around axis with plus direction, :-x :-y :-z for axis with minus direction. :zz :yy :zz for direction free axis. :xm :ym :zm for allowing rotation with respect to mirror direction. When the target-coords is list, this should be list too. Default is t.
2289+
:translation-axis
2290+
~ :x :y :z for constraint along the x, y, z axis. :xy :yz :zx for plane. Default is t.
2291+
:joint-args
2292+
~ Arguments passed to joint as (send* joint :joint-angle angle :relative t joint-args). Default nil.
2293+
:thre
2294+
~ Threshold for position error to terminate IK iteration. Default is 1 [mm].
2295+
:rthre
2296+
~ Threshold for rotation error to terminate IK iteration. Default is 0.017453 [rad] (1 deg).
2297+
:union-link-list
2298+
~ a function that returns union of link-list called as (funcall union-link-list link-list). Default is (send self :calc-union-link-list link-list).
2299+
:centroid-thre
2300+
~ Threshold for centroid position error to terminate IK iteration. Default is 1 [mm].
2301+
:target-centroid-pos
2302+
~ The float-vector of the target centroid position. Default is nil.
2303+
:centroid-offset-func
2304+
~ A function that returns centroid position. This function is called in each IK loop as (funcall centroid-offset-func). Default is (send self :centroid).
2305+
:cog-translation-axis
2306+
~ :x :y :z for constraint along the x, y, z axis. :xy :yz :zx for plane. t for point. Default is :z.
2307+
:cog-null-space
2308+
~ t: centroid position task is solved in null space of the main task. Default is nil.
2309+
:dump-command
2310+
~should be t, nil, :always, :fail-only, :always-with-debug-log, or :fail-only-with-debug-log. Log are success/fail log and ik debug information log.
2311+
~~ t or :always : dump log both in success and fail (for success/fail log).
2312+
~~ :always-with-debug-log : dump log both in success and fail (for success/fail log and ik debug information log).
2313+
~~ :fail-only : dump log only in fail (for success/fail log).
2314+
~~ :always-with-debug-log : dump log only in fail (for success/fail log and ik debug information log).
2315+
~~ nil : do not dump log.
2316+
:periodic-time
2317+
~ The amount of joint angle modification in each IK loop is scaled not to violate joint velocity limit \times :periodic-time. Default is 0.5[s].
2318+
:check-collision
2319+
~ Set t to return false when self collision occurs at found IK solution. Default is nil. To avoid collision within IK loop, use set links to collision-avoidance-links slot of cascaded-link.
2320+
:additional-jacobi
2321+
~ The jacobian of the additional main task, or a function that returns the jacobian. When a function is given, it is called in every IK loop as (funcall additional-jacobi link-list). Use a list of additional-jacobi to solve the IK for multiple additional task. Default is nil.
2322+
:additional-vel
2323+
~ The velocity of additional main task, or a function that returns the velocity. When a function is given, it is called in every IK loop as (funcall additional-vel link-list). The velocity should be expressed in the same coordinates as corresponding additional-jacobi. When the additional-jacobi is list, this should be a list of same length. Default is nil.
2324+
other-keys
2325+
~ function :inverse-kinematics-loop is internally called and args are passed to it. See the explanation of :inverse-kinematics-loop."
22432326
(if (or (atom target-coords) (functionp target-coords)) (setq target-coords (list target-coords)))
22442327
(let* ((loop 0)
22452328
(union-link-list (if (functionp union-link-list) (funcall union-link-list link-list) (send self :calc-union-link-list link-list)))

irteus/irtrobot.l

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,12 @@
331331
(mapcar #'(lambda (mt) (send self :link-list (send mt :parent))) move-target)))
332332
&allow-other-keys)
333333
"solve inverse kinematics, move move-target to target-coords
334-
look-at-target suppots t, nil, float-vector, coords, list of float-vector, list of coords
335-
link-list is set by default based on move-target -> root link link-list"
334+
target-coords and move-target should be given.
335+
link-list is set by default based on move-target -> root link link-list
336+
:look-at-target
337+
~ target head looks at. This task is best-effort and only head joints are used. :look-at-target supports t, nil, float-vector, coords, list of float-vector, list of coords.
338+
other-keys
339+
~ :inverse-kinematics internally calls :inverse-kinematics of cascaded-cords class and args are passed to it. See the explanation of :inverse-kinematics of cascaded-cords class."
336340
(if (or (atom target-coords) (functionp target-coords)) (setq target-coords (list target-coords)))
337341
(when (null (every #'(lambda (x) (or (coordinates-p x) (functionp x))) target-coords))
338342
(warn ";; error: all target-coords should be Coordinates or functions, but get ~A~%" target-coords)
@@ -461,7 +465,20 @@
461465
&allow-other-keys)
462466
"fullbody inverse kinematics for legged robot.
463467
necessary args : target-coords, move-target, and link-list must include legs' (or leg's) parameters
464-
ex. (send *robot* :fullbody-inverse-kinematics (list rarm-tc rleg-tc lleg-tc) :move-target (list rarm-mt rleg-mt lleg-mt) :link-list (list rarm-ll rleg-ll lleg-ll))"
468+
ex. (send *robot* :fullbody-inverse-kinematics (list rarm-tc rleg-tc lleg-tc) :move-target (list rarm-mt rleg-mt lleg-mt) :link-list (list rarm-ll rleg-ll lleg-ll))
469+
:min
470+
~ lower position limit of root link virtual joint (x y z roll pitch yaw). Default is #f(-500[mm] -500[mm] -500[mm] -20[deg] -20[deg] -10[deg]).
471+
:max
472+
~ upper position limit of root link virtual joint (x y z roll pitch yaw). Default is #f(500[mm] 500[mm] 25[mm] 20[deg] 20[deg] 10[deg]).
473+
:root-link-virtual-joint-weight
474+
~ float-vector of inverse weight of velocity of root link virtual joint or a function which returns the float-vector (x y z roll pitch yaw). This works in the same way as :additional-weight-list in cascaded-coords::inverse-kinematics. Default is #f(0.1 0.1 0.1 0.1 0.5 0.5).
475+
:joint-args
476+
~ list of other arguments passed to :init function of root link virtual joint (6dof-joint class).
477+
~~ :max-joint-velocity
478+
~~~ limit of velocity of root link virtual joint (x y z roll pitch yaw). Default is #f((/ 0.08 0.05)[m/s] (/ 0.08 0.05)[m/s] (/ 0.08 0.05)[m/s] (/ pi 4)[rad/s] (/ pi 4)[rad/s] (/ pi 4)[rad/s]))
479+
other-keys
480+
~ :fullbody-inverse-kinematics internally calls :inverse-kinematics and args are passed to it. See the explanation of :inverse-kinematics.
481+
"
465482
(with-append-root-joint ;; inverse-kinematics with root-link
466483
(link-list-with-robot-6dof self link-list
467484
:joint-class 6dof-joint

0 commit comments

Comments
 (0)