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

[collada2eus_urdfmodel.cpp] print links in the order of link names #252

Merged
merged 1 commit into from Apr 18, 2023

Conversation

Naoki-Hiraoka
Copy link
Contributor

#250 (comment) に対応したPull Requestです。

これまで、collada2eusのソースコードに変更を加える度に、生成されるeusモデルのリンクの宣言順が変わってしまって、生成されるeusモデルに大きなdiffが発生してしまい、collada2eusに加えた変更が妥当かどうかの検証がしづらい、という問題が有りました。

考えられる原因は、次のとおりです。

collada2eusは、

#if URDFDOM_1_0_0_API
for (map<LinkConstSharedPtr, Pose >::iterator it = m_link_coords.begin();
#else
for (map<boost::shared_ptr<const Link>, Pose >::iterator it = m_link_coords.begin();
#endif
#if URDFDOM_1_0_0_API
for(map <LinkConstSharedPtr, MapVisual >::iterator it = m_link_visual.begin();
#else
for(map <boost::shared_ptr<const Link>, MapVisual >::iterator it = m_link_visual.begin();
#endif
で、linkのshared_ptrをキーとするmapにlinkが格納されていて、mapのイテレータを回したときにどのような順番になっているかによって、linkの宣言順番が決まっています。mapのイテレータの順番は、デフォルトだと恐らくlinkのアドレス順になるので、linkのメモリを確保するときにどのアドレスに確保されたかに依存すると思われます。そのため、collada2eusのソースコードに変更を加えると、変更した部分で行うメモリ確保・開放がlinkのアドレスに何らかの影響を与えて、linkの宣言順番が変化してしまっているのではないかと思います。

このPull Reqeustは、mapのイテレータを回したときに、リンク名のアルファベット順で回るように変更することで、この問題を解決するものです。

@k-okada k-okada merged commit c44989a into jsk-ros-pkg:master Apr 18, 2023
1 check passed
@Naoki-Hiraoka Naoki-Hiraoka deleted the PR-linkorder branch April 18, 2023 04:32
@Naoki-Hiraoka Naoki-Hiraoka mentioned this pull request Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants