Skip to content
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

[irtgeo.l] enable :rotation-axis :xy :yz :zx :yx :zy :xz #568

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Naoki-Hiraoka
Copy link
Contributor

@Naoki-Hiraoka Naoki-Hiraoka commented May 24, 2020

I enabled :rotation-axis :xy :yz :zx :yx :zy :xz for :inverse-kinematics.

$ (setq *robot* (instance sample-robot :init))
$ (send *robot* :rarm :inverse-kinematics (make-coords :pos #F(300 -200 100)) :rotation-axis :xz)
$ (send *robot* :rarm :end-coords :difference-rotation (make-coords :pos #F(300 -200 100)))
#f(0.528315 0.000625 -0.138705) ;;only Y component is almost zero

irteus/irtgeo.l Outdated
@@ -69,7 +69,7 @@
dif-pos))
(:difference-rotation
(coords &key (rotation-axis t))
"return difference in rotation of given coords, rotation-axis can take (:x, :y, :z, :xx, :yy, :zz, :xm, :ym, :zm)"
"return difference in rotation of given coords, rotation-axis can take (:x, :y, :z, :xy, :yz, :zx, :xx, :yy, :zz, :xm, :ym, :zm)"
Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding :yx :zy :xz?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The documentation of :difference-position does not have :yx :zy :xz.
I made the documentation of :difference-rotation similar to :difference-position.

jskeus/irteus/irtgeo.l

Lines 56 to 58 in 8902642

(:difference-position
(coords &key (translation-axis t))
"return difference in position of given coords, translation-axis can take (:x, :y, :z, :xy, :yz, :zx)."

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.
But rotation-axis, the argument of :difference-rotation, can take :yx, :zy, :zx. This is clear from your commit. c3603fe#diff-23ea0c1757d7ef177d46886dd7b78a15R91

I think that good documentation supports other users. So how about changing the document of difference-position?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It ’s true. I fixed. 85c060d
Thank you!

irteus/irtgeo.l Outdated
@@ -88,6 +88,19 @@
(setq dif-rot
(transform (transpose (send self :worldrot))
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))
((:xy :yx :yz :zy :zx :xz)
(setq a0 (send self :axis (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
Copy link
Contributor

Choose a reason for hiding this comment

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

How about use 'let'. The following code is my suggestion.

((:xy :yx :yz :zy :zx :xz)
        (let ((ax1 (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
              (ax2 (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z))))
          (setq a0 (send self :axis ax1)
                a1 (send coords :axis ax1))
          (setq dif-rot
                (transform (transpose (send self :worldrot))
                           (scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1)))))
          (let ((self-coords (send (send self :copy-worldcoords) :rotate (norm dif-rot) dif-rot)))
            (setq a0 (send self-coords :axis ax2)
                  a1 (send coords :axis ax2))
            (setq dif-rot
                  (transform (transpose (send self-coords :worldrot))
                             (scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I fixed. 815f8b4

Copy link
Member

@k-okada k-okada left a comment

Choose a reason for hiding this comment

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

@k-okada
Copy link
Member

k-okada commented May 26, 2020

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

@Naoki-Hiraoka
Copy link
Contributor Author

Naoki-Hiraoka commented May 26, 2020

In 85d63f9 , I added documentation

jskeus/doc/irtmodel.tex

Lines 1608 to 1609 in 9a271ed

\verb|t|は三軸拘束,\verb|nil|は拘束なし,その他に\verb|:x|,
\verb|:y|, \verb|:z|を指定することができる.

jskeus/doc/irtmodel.tex

Lines 1608 to 1610 in 85d63f9

\verb|t|は三軸拘束,\verb|nil|は拘束なしを示し,その他に拘束なしの軸を
エンドエフェクタの座標系で\verb|:x|, \verb|:y|, \verb|:z|, \verb|:xy|,
\verb|:yz|, \verb|:zx|と指定することができる.

This PR cannot improve the example at
https://github.com/euslisp/jskeus/blob/master/doc/irtmodel.tex#L1903-L1921
because the goal condition of this example is that ''Z axis of target-coords is on XZ plane of move-target'', and rotation-axis is not enough to represent such a complicated condition.

@Naoki-Hiraoka Naoki-Hiraoka force-pushed the enable-dual-rotation-axis branch from a484bc1 to 85d63f9 Compare May 26, 2020 10:49
@k-okada
Copy link
Member

k-okada commented May 26, 2020

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

@Naoki-Hiraoka
Copy link
Contributor Author

There are few cases where this new feature is effective, but it certainly exists.
I heard this new feature is effective in @takayuki5168 's case.
@takayuki5168 Do you have good examples?

@takayuki5168
Copy link

Sorry to be late. I think this PR is partly effective when the robot grasps the cylinder.
Here is an example that PR2 grasps the cylinder using :yz.

(load "package://pr2eus/pr2-interface.l")
(pr2)

(setq *obj* (make-cylinder 30 300))
(send *obj* :move-to (make-coords :pos #f(500 -300 700) :rpy #f(1 2 3)))

(objects (list *pr2* *obj*))

(let ((target-coords (send (send *obj* :copy-worldcoords) :locate #f(0 0 150))))
  (send *pr2* :rarm :inverse-kinematics target-coords
        :rotation-axis :yz)
  )

@takayuki5168
Copy link

This picture shows the result when we execute above code, which means using yz.
pr2-cylinder-yz

The following figures are when using :y and :z respectively.
pr2-cylinder-y

pr2-cylinder-z

@Naoki-Hiraoka
Copy link
Contributor Author

Naoki-Hiraoka commented May 29, 2020

ありがとうございます.
こちらのケースも,
https://github.com/euslisp/jskeus/blob/master/doc/irtmodel.tex#L1903-L1921
のケースと同様に,①"target-coordsのZ軸をmove-targetのXZ平面上に位置させる"という問題です.
このような問題は多い気がします.
例えば,X軸方向に長い鉄パイプを把持しているときに,それを水平に持って運びたいという場合,②"move-targetのX軸を,target-coords(world系)のXY平面上に位置させる"という問題になります.

①②それぞれのケースを:rotation-axis的に表現すると,
①は"target-coords系Z軸まわりとmove-target系Y軸まわりの回転エラーを許容する"
②は"move-target系X軸まわりとtarget-coords系Z軸まわりの回転エラーを許容する"
となります.

したがって,これらのケースに対応するためには,今回のpull requestに加えて,
:rotation-axisの各軸ごとにどの座標系で評価するのかを指定できるようにする必要があると思いました.(現在の:inverse-kinematicsは全てmove-target座標系で評価しています)

@Naoki-Hiraoka
Copy link
Contributor Author

Naoki-Hiraoka commented May 29, 2020

:rotation-axis :z: 回転エラーの角軸ベクトルのZ軸以外の成分をゼロにする
:rotation-axis :yz: 回転エラーの角軸ベクトルのZ軸Y軸以外の成分をゼロにする
という解釈でこのpull requestを作りましたが,

:rotation-axis :z: move-targetのZ軸とtarget-coordsのZ軸を一致させる拘束を加える
:rotation-axis :yz: move-targetのY軸とtarget-coordsのZ軸を直交させる拘束を加える(:zy:yzは意味が異なる)(move-targetのZX平面とtarget-coordsのZ軸を一致させる拘束や,move-targetのY軸とtarget-coordsのXY平面を一致させる拘束と等価)
という解釈で作り直すべきかもしれません.

@takayuki5168
Copy link

なるほど,確かにmove-targetのY軸とtarget-coordsのZ軸が直交するのとmove-targetのZ軸とtarget-coordsのY軸が直交するのは違うね.

このPRの実装だと円柱の把持のIKができないという認識であってるよね?上記のPR2の例はたまたまよさげだけど.とすると,平岡くんの解釈でPRを作りなおすのが良い気がする.

@Naoki-Hiraoka
Copy link
Contributor Author

その通りです.
実用上のケースを考えると,
「回転エラーの角軸ベクトルのZ軸Y軸以外の成分をゼロにする」という解釈で役に立つことはまれなので,
円柱を掴む場合などに便利な「move-targetのY軸とtarget-coordsのZ軸を直交させる拘束」を意味するように作り直します.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants