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

fix node name bug, when it attributes a namespace (and also fix #142) #149

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

pojiro
Copy link
Contributor

@pojiro pojiro commented Jul 13, 2022

This commit fixes below, so closes #142

>>> [rcutils|error_handling.c:108] rcutils_set_error_state()
This error state is being overwritten:

  'node name must not contain characters other than alphanumerics or '_', at /tmp/binarydeb/ros-foxy-rcl-1.1.13/src/rcl/node.c:164'

with this new error message:

  'subscription's implementation is invalid, at /tmp/binarydeb/ros-foxy-rcl-1.1.13/src/rcl/subscription.c:462'

rcutils_reset_error() should be called after error handling to avoid this.
<<<

本修正方法だと、ノード名に namespace を含まなくなります。
それが rclex の方針と異なるようであれば、修正案をご指示いただきたいです。
※ただし、rclのリソースとしてはnamespeceを保持する点は維持しています。

修正前: "#{namespace}/#{node_id}"
修正後: "#{node_id}"

@pojiro pojiro requested a review from s-hosoai July 13, 2022 00:14
@pojiro pojiro marked this pull request as ready for review July 13, 2022 00:19
@pojiro pojiro requested a review from takasehideki July 13, 2022 00:21
@takasehideki
Copy link
Member

代案はありそうなのでちょっと調査時間をください.今日中には結論出します.

@takasehideki
Copy link
Member

takasehideki commented Jul 13, 2022

あれっ,,, もしかして _with_namespace といってるけどちゃんと実装されていないということ??

https://github.com/rclex/rclex/blob/main/lib/rclex/resource_server.ex#L30-L38

https://github.com/rclex/rclex/blob/main/lib/rclex/resource_server.ex#L65-L69

@s-hosoai これがYesであれば,このようにしたいです.

  • このPRはこのままmerge
  • _with_namespace をちゃんと実装する的なIssueを立てる

@s-hosoai
Copy link
Contributor

@takasehideki @pojiro
コード確認してきました。すみません、私の実装ミスでした。
resource_server.ex:198,211あたりでnode_identifierとしてns+node_name+IDとしちゃってますが、ここはnode_nameで回すべきですね。別Issueにして貰えればこちらで修正します。

@s-hosoai
Copy link
Contributor

本PR、まだ動作確認していないため、確認+レビュー後にマージしてしまいますね。

@takasehideki
Copy link
Member

ん?念のため確認ですが,

resource_server.ex:198,211あたりでnode_identifierとしてns+node_name+IDとしちゃってますが、ここはnode_nameで回すべきですね。

これは本PRで直してもらっているのでは?
https://github.com/rclex/rclex/pull/149/files#diff-a5818b6cb433a1fbc21187b43abed14c40d0cd4441609535ba056beb2fda11b9

@s-hosoai
Copy link
Contributor

あ、、ほんまですね・・。ちゃんと現状把握してからコメントしないとだめですね。。少々お待ちを。

@s-hosoai
Copy link
Contributor

かんぜんにはあくしました。
201行目の同名ノードはじきの所の挙動をどうするかってところがネックですね。name_space違いの同名node_nameを許容するか否かですが、個人的には折角name_spaceで分けているのだから別のものとしたいです。(@takasehideki 判断お願いします)
node_identifierとして使っているのはここと返り値ですが、返り値も呼び出し元でnamespaceは分かっているので、node_name+IDのリストを返すだけでよさそうですし、201の中でだけns+nameとして判断するようにすればよいかと。
ついでに、変数名identifierは外してもいいかもです。(ns+nameでシステム内の一意な名前の意図でつけてました。)

@takasehideki
Copy link
Member

とりあえず本質的な問題が洗い出せたと認識しています.

@s-hosoai まずはこのPRの扱いをどうしましょうか?

  1. これはPR名通りの対応がされたものとしてmergeする(conflict解消も必要ですが,,,
  2. 本質的な問題の解決にはなっていないので,closeして新しくPRで対応する
  3. PR名を変更し,このまま続ける("fix node name bug, when it attributes a namespace" など)

@pojiro いずれにせよ本件はこちらで引き取ります.問題を明らかにしていただきありがとうございます!!

@takasehideki
Copy link
Member

とりあえずここで回答を続けますが,

201行目の同名ノードはじきの所の挙動をどうするかってところがネックですね。name_space違いの同名node_nameを許容するか否かですが、個人的には折角name_spaceで分けているのだから別のものとしたいです。(@takasehideki 判断お願いします)

はい,別のものとすべきです.

node_identifierとして使っているのはここと返り値ですが、返り値も呼び出し元でnamespaceは分かっているので、node_name+IDのリストを返すだけでよさそうですし、201の中でだけns+nameとして判断するようにすればよいかと。
ついでに、変数名identifierは外してもいいかもです。(ns+nameでシステム内の一意な名前の意図でつけてました。)

node_identifier は複数ノード生成の create_nodes 等で用いられるものかと.引数で与えられた node_name に prefix を付けて生成するやつですね.本質的には create_node の場合は prefix を付けないなど対応が必要かと思います.

@takasehideki
Copy link
Member

あとROS 2におけるnamespaceの関係資料です.topic,serviceに関するものですが,ノードについても同じ概念で名前空間を分けています.
https://design.ros2.org/articles/topic_and_service_names.html#namespaces

@s-hosoai
Copy link
Contributor

@takasehideki node_nameの重複確認は本件の範疇内だと思うので、このPR内で修正してしまう方が妥当な気がします。
よく見たら、今までの作成済みのnamespace+node_nameはstateとして持たせなきゃ比較できないっすね。となるとやっぱり返り値で返さにゃならんか・・。とりあえずこちらで修正してみます。

@takasehideki takasehideki changed the title fix node name bug, node name must not contain '/' fix node name bug, when it attributes a namespace (and also fixes #142) Jul 13, 2022
@takasehideki takasehideki changed the title fix node name bug, when it attributes a namespace (and also fixes #142) fix node name bug, when it attributes a namespace (and also fix #142) Jul 13, 2022
In Nif, namespace and node_name are handled separately, but Rclex uses "namespace/node_name" format because unique ID is required for GenServer ID and Map key.
@s-hosoai
Copy link
Contributor

@takasehideki @pojiro
MapのキーやGenServerのIDにするのに一意なキーが必要なので、結局Rclexとして保持するIDは#{namespace}/#{node_name}に戻しました。今のところ、create_nodesで作ったIDのリストを持ちまわして使っているので特に不便はないですが、追々finishやstopにnameとnamespaceを引数に取るAPIも追加した方がいいかもしれません。

@takasehideki
Copy link
Member

これだと #142 が再燃しませんか?

@s-hosoai
Copy link
Contributor

あ、NIF側ではしっかり分けてるのでissueのやつには引っかからないです。NIF側とrclex側のIDの扱いがごっちゃになってたのが要因なので、そのあたりは解決できたと思います。

@takasehideki
Copy link
Member

それは失礼しました,,, あとでちゃんと動作確認してからmergeします!

Copy link
Member

@takasehideki takasehideki left a comment

Choose a reason for hiding this comment

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

問題ないことを確認しました.mergeします!

@takasehideki takasehideki merged commit 64533cb into main Jul 13, 2022
@takasehideki takasehideki deleted the fix-node_name_bug-pojiro branch July 13, 2022 08:33
takasehideki added a commit that referenced this pull request Sep 21, 2022
**Full Changelog**: v0.7.0...v0.7.1

* New Contributors: @pojiro 🎉
* New features:
  * Improve unit test environment on local dev machine by @pojiro in #131
* Code Improvements/Fixes:
  * Enrich doc and specs with the awesome contributions by @pojiro (e.g., in #121)
  * Enrich unit tests with the awesome contributions by @pojiro (e.g., in #136)
  * Improve credo config, .credo.exs by @pojiro in #120
  * exclude auto-generated files format by @pojiro in #135
  * refactor Rclex.ResourceServer.call_nifs_rcl_node_init/5 by @pojiro in #147
  * fix node name bug, when it attributes a namespace (and also fix #142) by @pojiro in #149
  * Remove KeepSub module which is unused (also fix dialyzer error) by @s-hosoai in #164
  * Improve README by @takasehideki in #171
* Bumps:
  * `credo` from 1.6.4 to 1.6.5 in #162
* Known issues to be addressed in the near future:
  * Lock `git_hooks` to 0.6.5 due to its issue in #138
  * Bump to Humble Hawksbill in #114
  * Release rcl nif resources when GerServer terminates in #160
* Note in this release:
  * After long consideration, we have decided to end the support for Dashing as the target environment 6ae367d
@takasehideki takasehideki mentioned this pull request Sep 21, 2022
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.

Fix namespace naming rule
3 participants