-
Notifications
You must be signed in to change notification settings - Fork 30
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
Feature/kinbodyparser #102
Conversation
Reviewed 2 of 3 files at r1, 1 of 1 files at r2. aikido/include/aikido/util/KinBodyParser.h, line 8 [r1] (raw file):
Move this comment into the docstring of aikido/include/aikido/util/KinBodyParser.h, line 14 [r1] (raw file):
The aikido/include/aikido/util/KinBodyParser.h, line 18 [r1] (raw file):
aikido/src/util/KinBodyParser.cpp, line 159 [r1] (raw file):
Typo: "the element" should be "the root element"? aikido/src/util/KinBodyParser.cpp, line 178 [r1] (raw file):
Handle this by returning aikido/src/util/KinBodyParser.cpp, line 185 [r1] (raw file):
What happens if there is no aikido/src/util/KinBodyParser.cpp, line 209 [r1] (raw file):
What is the point of creating this temporary aikido/src/util/KinBodyParser.cpp, line 235 [r1] (raw file):
Handle this gracefully instead of triggering an aikido/src/util/KinBodyParser.cpp, line 241 [r1] (raw file):
What happens if there is no aikido/src/util/KinBodyParser.cpp, line 308 [r2] (raw file):
Can you add a comment explaining the logic in here? I am not sure what this is trying to accomplish. aikido/src/util/KinBodyParser.cpp, line 413 [r2] (raw file):
What is the purpose of this? Please add a comment. aikido/src/util/KinBodyParser.cpp, line 416 [r2] (raw file):
Shouldn't we read the scale from the file, if it is specified? Comments from Reviewable |
|
@Shushman What is the current status of this? Do you intend to address the remaining comments so we can merge this into While I think this is a great addition, I am also fine with dropping support if you think we are at a point where we no longer need to regularly load |
Conflicts: aikido/src/util/CMakeLists.txt
I'm completing this PR as @Shushman almost finished. My little concern is that there are some discrepancies between the spec and kinbody files in our repo. For example, the spec has |
Replied in the each comment. Review status: 0 of 10 files reviewed at latest revision, 12 unresolved discussions. src/util/KinBodyParser.cpp, line 159 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
done. src/util/KinBodyParser.cpp, line 178 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
The src/util/KinBodyParser.cpp, line 185 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
src/util/KinBodyParser.cpp, line 209 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
Removed the indirection. src/util/KinBodyParser.cpp, line 235 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
Added comment. src/util/KinBodyParser.cpp, line 241 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
An empty string will be returned. We prints error message because an empty-named BodyNode causes problems in parsing (especially for parsing ). If src/util/KinBodyParser.cpp, line 308 at r2 (raw file): Previously, mkoval (Michael Koval) wrote…
The logic is modified with some reasonable comments. src/util/KinBodyParser.cpp, line 413 at r2 (raw file): Previously, mkoval (Michael Koval) wrote…
I believe the original code is to parse and that contains the mesh file name and optionally the mesh scale. Added comment. src/util/KinBodyParser.cpp, line 416 at r2 (raw file): Previously, mkoval (Michael Koval) wrote…
Done. aikido/include/aikido/util/KinBodyParser.h, line 8 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
Done. aikido/include/aikido/util/KinBodyParser.h, line 14 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
Done. The parser doesn't require any optional dependency. aikido/include/aikido/util/KinBodyParser.h, line 18 at r1 (raw file): Previously, mkoval (Michael Koval) wrote…
Done. Comments from Reviewable |
Can you compile a list of those discrepancies as you encounter them? Sadly, the spec for |
The bolded part is incorrect. The
The easiest way to understand this is realize that each
This is correct. However, note that the
It may have both and they have different meanings.
These are treated as equivalent in
This is not correct. From the above description, it is impossible to create visual geometry without any associated collision geometry. There is a I hope this helps. TL;DR: Your best bet is to mimic |
Thank you for helping me to understand the mysterious visualization logic of I believe the parser now correctly reads KinBody files; it could read the files in |
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.
I left a bunch of comments, but the only critical ones are:
- Report an error if there is more than one
Body
in theKinBody
, since that is not currently supported. - Fix handling of
extents
for boxes. - Handle three-element
scale
vectors for meshes.
Great work @jslee02! 🎉
/// kinbody - attributes: name | ||
/// body - attributes: name | ||
/// geom - attributes: name, type* (none, box, sphere, trimesh, cylinder), render | ||
/// data* (or collision) - file* scale (e.g., /path/to/mesh/file_collision.stl 0.5) [for trimesh] |
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.
Note that scale
may be a single float or three
float`s, for (respectively) the x, y, and z-axes. This is implemented in OpenRAVE in this cryptic snippet:
_ss >> _pgeom->_filenamerender;
_ss >> _pgeom->_vRenderScale.x; _pgeom->_vRenderScale.y = _pgeom->_vRenderScale.z = _pgeom->_vRenderScale.x;
_ss >> _pgeom->_vRenderScale.y >> _pgeom->_vRenderScale.z;
/// extents* - 3 float [for box] | ||
/// height* - float [for cylinder] | ||
/// radius* - float [for cylinder and sphere] | ||
/// render - file* scale (e.g., /path/to/mesh/file_render.stl 0.5) |
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.
See my note above about scale
. The same applies here (see this snippet).
/// Elements marked with `*` are required ones. | ||
/// | ||
/// The detail of the format can be found at: | ||
/// http://openrave.programmingvision.com/wiki/index.php/Format:XML). |
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.
Extra ).
at the end of this line.
/// http://openrave.programmingvision.com/wiki/index.php/Format:XML). | ||
/// | ||
/// \param[in] kinBodyString The Kinbody XML string. | ||
/// \param[in] baseUri The base URI of the mesh files in the KinBody XML string. |
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.
What does the default value of baseUri
do?
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.
The default value of baseUri
is empty. An empty base URI means that the URIs for mesh files should be absolute URIs or absolute paths. Added this to the docstring.
/// The detail of the format can be found at: | ||
/// http://openrave.programmingvision.com/wiki/index.php/Format:XML). | ||
/// | ||
/// \param[in] kinBodyFileUri The file URI ("file://...") of the KinBody file. |
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.
Why must this be a file://
URI?
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.
It shouldn't need to be. Updated the comment: "The URI to a KinBody file. If the URI scheme is not file (i.e., file://), a relevant ResourceRetriever should be passed to retrieve the KinBody file."
src/util/KinBodyParser.cpp
Outdated
} | ||
else if (typeAttr == "box") | ||
{ | ||
auto extents = dart::utils::getValueVector3d(geomEle, "extents"); |
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.
Check for non-positive extents
.
src/util/KinBodyParser.cpp
Outdated
dterr << "[KinBodyParser] <Geom> element doesn't contain neither of " | ||
<< "<Collision> and <Data> as the child element. Ignoring this " | ||
<< "<Geom>.\n"; | ||
return; |
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.
return
ing here also bypasses creation of visual geometry.
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.
I thought we don't want to create visual geometry for invalid geom type but changed not to so (create visual geometry) because, technically, we still can create one as long as (wrong card)<Render>
element is provided.
src/util/KinBodyParser.cpp
Outdated
{ | ||
dterr << "[KinBodyParser] Attempts to parse unsupported geom type '" | ||
<< typeAttr << "'. Ignoring this <Geom>.\n"; | ||
return; |
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.
return
ing here also bypasses creation of visual geometry.
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.
I thought we don't want to create visual geometry for invalid geom type but changed not to so (create visual geometry) because, technically, we still can create one as long as <Render>
element is provided.
src/util/KinBodyParser.cpp
Outdated
|
||
if (typeAttr == "trimesh" | ||
&& fileNameOfCollision == fileNameOfRender | ||
&& uniScaleOfCollision == uniScaleOfRender) |
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.
Very nice! 👍
src/util/KinBodyParser.cpp
Outdated
|
||
//============================================================================== | ||
std::vector<std::string> split( | ||
const std::string& str, const std::string& delimiters) |
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.
Nice helper function. I would be open to moving this to util
, since it may be useful elsewhere.
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.
I left a few nitpicks, but this otherwise looks good.
/// This function only parses a subset of the format assuming only one body node | ||
/// in a kinbody file. | ||
/// | ||
/// Followings are the available fields that this parser can read. |
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.
Nit: Followings
-> The following
.
/// radius* - float [for cylinder and sphere] | ||
/// render - file* scale (see below for the detail) | ||
/// \endcode | ||
/// Elements marked with `*` are required ones. |
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.
Nit: "are required ones" -> "are required".
/// | ||
/// <render>, <data>, or <collision> contains the relative path to a mesh file | ||
/// and optionally a single float (for the uni-scale) or three float's (for the | ||
/// x, y, and z-axes) for the scale. |
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.
Nits:
- "contains" -> "contain"
- "uni-scale" -> "for all three axes" (I thought the term uni-scale was a bit confusing, but it's fine to keep this if you
/// | ||
/// Example forms: | ||
/// <Render>my/mesh/file.stl<Render> | ||
/// <Render>my/mesh/file.stl 0.25<Render> <!--Unscale> |
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.
Nits:
Unscale
typo? Also, see my comment above.- Incorrect closing comment
-->
include/aikido/util/string.hpp
Outdated
/// \endcode | ||
/// | ||
/// \param[in] string Input string to be splitted. | ||
/// \param[in] delimiters Delimiters. |
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.
Add a note that any character this string is considered a delimiter, i.e. the string is interpreted as a set of delimiter characters, not as a single multi-character delimiter.
include/aikido/util/string.hpp
Outdated
/// \param[in] delimiters Delimiters. | ||
/// \return The splitted substrings. | ||
std::vector<std::string> split( | ||
const std::string& string, const std::string& delimiters = " "); |
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.
Add \t
as a default delimiter as well?
<KinBody name="bowl"> | ||
<Body type="static" name="bowl"> | ||
<Geom type="trimesh"> | ||
<!--<Data>bowl.iv</Data>--> |
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.
Nit: Remove comment.
<Geom type="trimesh" modifiable="false" render="false"> | ||
<Data>kinova_tool.stl 0.1</Data> | ||
</Geom> | ||
<!-- TODO: Add a sphere approximation. --> |
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.
Nit: Remove comment.
<radius>0.013</radius> | ||
</Geom> | ||
</Body> | ||
</KinBody> |
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.
Nit: Change this file to use the same spacing as the other .kinbody.xml
files.
A first pass at a Kinbody Parser under
aikido::util
. Points to note:KinBody
has oneBody
element with 1 or 2Geom
elements, andRender
andData
both defined, and refer to some file.SkelParser
dart::dynamics::MeshShap::loadMesh
) upon trying to load say the Pop tarts or kinbody. The error message is:Sometimes, even without the error message, the Pop tarts looks like:
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)