-
Notifications
You must be signed in to change notification settings - Fork 4
逆運動学ライブラリとX7のサンプルを追加 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビューして動作確認しました。解の収束性に関わるコメントをいくつかしました。ただそれらを変更してもコメントアウト部分は通るようになっていませんが、現状のテストはそのまま通って実機でも動作することを確認しています。
error = kinematics_utils::calc_error(target_p, target_R, calc_links[target_id]); | ||
|
||
// 誤差が小さければ終了 | ||
if (error.norm() < 1.0E-6) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
epsilon = 1.0E-6とかでhpp側に定義してもよさそう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
どこまでの値をライブラリ外部から調整できるようにするか悩ましいところですが、
今回は全パラメータ変更できないようにしたいです(今の実装がそうなってます)。
ただ、数字を直接書くと意味が伝わりにくいので、変数にします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be4bedb
にて、定数error_toleranceとして定義しました。
|
||
// 減衰因子の計算 | ||
auto E = 0.5 * error.transpose() * We * error; | ||
double omega = 0.001; // 0.1 ~ 0.001 * 代表リンク長の2乗 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代表リンク長l=0.1としたときに、0.1*l^2の値を使っているので、0.1 ~ 0.001の端の値(0.1側)と考えると数値の安定性としてはもしかしたら不安定よりかもしれない。安定性の高い手法とはいえ、安定性が理論的に保証されているわけではなく(文献中、大域的収束性云々のところ)、経験則的に0.1 ~ 0.001の範囲で十分というようなパラメータなので、0.1 ~ 0.001の間の0.01くらいを選択してもいいかもしれない。それでもテストのコメントアウト部分は通るようになりませんでしたが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます。
0.01に変更します。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7434dab
にて0.01に変更しました。
samples/samples02/README.md
Outdated
`kinematics::inverse_kinematics_LM()`には、 | ||
[杉原 知道. | ||
Levenberg-Marquardt法による可解性を問わない逆運動学. | ||
日本ロボット学会誌 Vol.29, 2011]( | ||
https://www.jstage.jst.go.jp/article/jrsj/29/3/29_3_269/_pdf) | ||
に記載されたアルゴリズムを実装しています。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実装について検証しきれてないという判断であれば、ここは一旦明記せずに保留してもいいかもしれません。
例えば注意書きとして、下記のようなものを書くなど。
kinematics::inverse_kinematics_LM()
には数値解法による逆運動学の計算アルゴリズムが実装されています。任意の位置姿勢に対してロボットを動かしたい場合は、ロボットを動かす前に逆運動学の解が発散しないか等十分に検証して使用してください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
承知しました。文言を変更します。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9b0890c
にて対応しました。
|
||
// qを0にリセットする | ||
for (auto q_i = q_list.begin(); q_i != q_list.end(); ++q_i) { | ||
q_i->second = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q_i->second = 0; | |
q_i->second = -M_PI/4; // 特異点でない可動範囲内の適当な関節角 |
初期値0が特異姿勢なので数値解法の初期値としてあまり良くないため、これを適当な特異姿勢でない値に変更するのはありだと思います。数値解法として比較的安定した手法といっても、かなり不利な条件のスタートだと思います。
この値でも現状のテストは通りました。コメントアウト部分は通りませんでした。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかに、不利な状況から始める理由は無いですね。初期値を変更します。
Co-authored-by: kenjiinukai <36922159+kenjiinukai@users.noreply.github.com>
Co-authored-by: kenjiinukai <36922159+kenjiinukai@users.noreply.github.com>
Co-authored-by: kenjiinukai <36922159+kenjiinukai@users.noreply.github.com>
Co-authored-by: kenjiinukai <36922159+kenjiinukai@users.noreply.github.com>
初期値については私の確認ミスでした。動作確認したのでマージします。 |
What does this implement/fix?
kinematics
ライブラリに逆運動学を解く関数inverse_kinematics_LM()
を追加します。この関数には、 杉原 知道. Levenberg-Marquardt法による可解性を問わない逆運動学. 日本ロボット学会誌 Vol.29, 2011 に記載されたアルゴリズムを実装しています。
また、この関数を用いたCRANE-X7用のサンプル(x7_inverse_kinematics)を追加しています。
逆運動学関数とサンプルを追加するために、下記の変更を実施しています。
hardware関係
get_min_position_limit()
、get_max_position_limit()
kinematics
inverse_kinematics_LM()
を追加しますkinematics_utils
rotation_to_omega()
:回転行列から等価各軸ベクトルへ変換するfind_route()
:目標リンクから根本リンク(ベースリンクは除く)までの経路をを抽出するget_q_list()
:リンク構成から指定されたIDの関節位置qを抽出するset_q_list()
:指定されたIDの関節位置qをリンク構成に書き込むcalc_error_R()
:回転行列の差を求めるcalc_error_p()
:位置の差を求めるcalc_error()
:目標位置・姿勢と、リンクの位置・姿勢の差を求めるcalc_basic_jacobian()
:基礎ヤコビ行列を求めるparse_link_config_file()
でリンクパラメータファイルからDynamixelのIDを取得しdxl_id
にセットしますlinkクラス
dxl_id
を追加しますmin_q
とmax_q
を追加しますテスト関連
test_kinematics.cpp
を追加しますtest_links.csv
を使用しますkinematics_utils
に追加した関数のテストを追加しますサンプル関連
x7_inverse_kinematics
サンプルを追加しますDoes this close any currently open issues?
いいえ
How has this been tested?
Lintチェック、ユニットテストが通ることをGitHub Actionsで確認しています。
https://github.com/rt-net/rt_manipulators_cpp/actions/runs/1591540120
Ubuntu 20.04 環境で、x7_inverse_kinematicsサンプルが動作することを確認しています。
Any other comments?
Sciurus17のサンプルは、このPRがマージされたあとに作成します。
Sciurus17のハードウェアに対応するため(例、腰軸を除いてIKを解く)、
IK関数や、関連する関数を加工する可能性があります。どう実装するかは検討中です。
Checklists