-
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
Herbathon: add makeBodyFromUrdf convenience function #388
Changes from 2 commits
36b9188
0a06686
07249d7
50bce40
75c2e71
826e75d
0120aa9
e0154b1
f0608da
6739c03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "io/CatkinResourceRetriever.hpp" | ||
#include "io/KinBodyParser.hpp" | ||
#include "io/yaml.hpp" | ||
#include "io/util.hpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef AIKIDO_IO_UTIL_HPP_ | ||
#define AIKIDO_IO_UTIL_HPP_ | ||
|
||
#include <aikido/io/CatkinResourceRetriever.hpp> | ||
#include <dart/dart.hpp> | ||
#include <dart/utils/urdf/DartLoader.hpp> | ||
|
||
using dart::dynamics::SkeletonPtr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should avoid |
||
|
||
namespace aikido { | ||
namespace io { | ||
|
||
const SkeletonPtr makeBodyFromURDF( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Returning by const value is generally unnecessary. Let's just return |
||
const std::shared_ptr<aikido::io::CatkinResourceRetriever> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this can be a |
||
resourceRetriever, | ||
const std::string& uri, | ||
const Eigen::Isometry3d& transform); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can make this an optional argument by setting its default value to identity. |
||
|
||
} // namespace io | ||
} // namespace aikido | ||
|
||
#endif // AIKIDO_IO_UTIL_HPP_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "aikido/io/util.hpp" | ||
|
||
namespace aikido { | ||
namespace io { | ||
|
||
const SkeletonPtr makeBodyFromURDF( | ||
const std::shared_ptr<aikido::io::CatkinResourceRetriever> | ||
resourceRetriever, | ||
const std::string& uri, | ||
const Eigen::Isometry3d& transform) | ||
{ | ||
dart::utils::DartLoader urdfLoader; | ||
const SkeletonPtr skeleton = urdfLoader.parseSkeleton(uri, resourceRetriever); | ||
|
||
if (!skeleton) | ||
throw std::runtime_error("unable to load '" + uri + "'"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
|
||
dynamic_cast<dart::dynamics::FreeJoint*>(skeleton->getJoint(0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can also make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! Also, we should check whether |
||
->setTransform(transform); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need nullity check after dynamic casting. |
||
return skeleton; | ||
} | ||
|
||
} // namespace io | ||
} // namespace aikido |
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: Our convention is to:
(1) use
"..."
for including AIKIDO headers(2) include headers in order (in header file): (a) system headers (i.e., STL), (2) 3rd party libraries, (3) AIKIDO headers.
So this should be:
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'll change it but could you tell me if there is a specific reason for the header include order? Does it have an advantage to do it this way?
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.
This header ordering generally follows the Google C++ style convention:
https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes