-
Notifications
You must be signed in to change notification settings - Fork 20
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
Improved WM element (ID) handling #90
base: master
Are you sure you want to change the base?
Conversation
Previously this function could return strings, which caused an instance check in rdflib to fail with "must be an rdflib term".
Previously obtaining the ID of URI's like: "http://www.inf.ufrgs.br/phi-group/ontologies/cora.owl#Robot-186" Failed, because it was assumed that "-" only appears once in the URI. Now it searches only after the hash "#" if one exists
wrong mention @frvd |
@@ -150,9 +150,13 @@ def getIdNumber(self): | |||
""" | |||
@brief Return the element id number as integer | |||
""" | |||
if self._id.find('-') < 0: | |||
hash_pos = self._id.find('#') |
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.
@matthias-mayr I think it would be just easier to replace find with rfind :)
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.
rfind for the "-" or the "#"? Assume the former since the latter does not seem to make any sense to me
However just using rfind for the "-" does not necessarily yield to the expected result.
Example:
A malformed URI like http://www.inf.ufrgs.br/phi-group/ontologies/cora.owl#Robot
that does not have an ID should lead to a return value of "-1" according to the previous/other code.
That's why I wanted to search explicitly after the hash if there's one
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.
Right, what about the following?
hash_pos = self._id.rfind('#')
dash_pos = self._id.rfind("-")
return -1 if dash_pos == -1 or dash_pos < hash_pos else int(self._id.split('-')[1])
When testing, I ran into two issues that are addressed in this PR.
lightstring2uri
method could return a string instead of an rdflibURIRef
. This caused errors of this kind:Since we have URIs like
http://www.inf.ufrgs.br/phi-group/ontologies/cora.owl#Robot-1
, this could lead to errors like:This two commits address both. However, I am not sure if they would cause side effects.
@frovida: If you have sth to comment, please do so.
I will merge them into the ROS 2 branch, so they would get some sort of testing.
This also came up when "reviving" the skiros2_test_lib. Once it's fully up, we can also make changes with some more confidence.