-
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
Initial implementation of kinematic World #243
Conversation
src/planner/World.cpp
Outdated
} | ||
|
||
//============================================================================== | ||
const std::string& World::setName(const std::string& newName) |
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 don't think we need to return the name. The reason we did this in DART was that the given name and the actual name can be different to manage all the names to be unique. If the given name was taken then the actual name would be the given name + "(1)" (the number will increase until the name becomes unique). However, I don't think we want the names of the kinematic world to be unique.
src/planner/World.cpp
Outdated
dart::dynamics::SkeletonPtr World::getSkeleton(const std::string& name) const | ||
{ | ||
for (const auto& skeleton : mSkeletons) | ||
if (skeleton->getName() == name) |
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: The convention is using curly parentheses if the for-state (or other control statements) is multiple-line.
src/planner/World.cpp
Outdated
//============================================================================== | ||
std::string World::addSkeleton(const dart::dynamics::SkeletonPtr& skeleton) | ||
{ | ||
std::lock_guard<std::mutex> lock(mMutex); |
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: It also looks safe even we lock after the below nullity check because it refers only the parameter.
include/aikido/planner/World.hpp
Outdated
virtual ~World() = default; | ||
|
||
/// Create a clone of this World. All Skeletons will be copied over. | ||
std::shared_ptr<World> clone(const std::string& name) const; |
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: Need docstring for the parameter.
Also, I like you used newName
in the source file for this parameter. It would be good to use the same name here too.
src/planner/World.cpp
Outdated
//============================================================================== | ||
void World::removeSkeleton(const dart::dynamics::SkeletonPtr& skeleton) | ||
{ | ||
std::lock_guard<std::mutex> lock(mMutex); |
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: It also looks safe even we lock after the below nullity check because it refers only the parameter.
Codecov Report
@@ Coverage Diff @@
## master #243 +/- ##
=======================================
Coverage 70.78% 70.78%
=======================================
Files 172 172
Lines 5055 5055
Branches 802 802
=======================================
Hits 3578 3578
Misses 993 993
Partials 484 484 |
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, this seems like a straightforward little class.
include/aikido/planner/World.hpp
Outdated
{ | ||
public: | ||
/// Construct a kinematic World. | ||
World(const std::string& name); |
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.
If we are creating or cloning worlds inside of an optimizer or something, does it really make sense to need to generate names for all of them? I think DART has some mechanisms for autogenerating IDs if names are not set, something like that might make sense here if this is just for semantic purposes.
tests/planner/test_World.cpp
Outdated
, skel2{dart::dynamics::Skeleton::create("skel2")} | ||
, skel3{dart::dynamics::Skeleton::create("skel3")} | ||
{ | ||
mWorld = std::make_shared<aikido::planner::World>("test"); |
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.
Should World
have a similar create()
helper to the above one that Skeleton
has?
Oops, posted PR review with wrong account 🤷♀️ |
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 think the create()
should return std::unique_ptr
for the reason mentioned below. Other than that, it looks good to go!
include/aikido/planner/World.hpp
Outdated
mutable std::mutex mMutex; | ||
|
||
/// NameManager for keeping track of Worlds | ||
static dart::common::NameManager<World*> worldNameManager; |
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 believe our convention is mStaticVariable
even for static member variables.
include/aikido/planner/World.hpp
Outdated
dart::common::NameManager<dart::dynamics::SkeletonPtr> mSkeletonNameManager; | ||
}; | ||
|
||
typedef std::shared_ptr<World> WorldPtr; |
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: Let's use C++11 style of type aliasing: using WorldPtr = std::shared_ptr<World>()
.
include/aikido/planner/World.hpp
Outdated
std::shared_ptr<World> clone(const std::string& newName = "") const; | ||
|
||
/// Create a new World inside of a shared_ptr | ||
static std::shared_ptr<World> create(const std::string& name = ""); |
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.
In case we provide one creator function, then it should be returning std::unique_ptr
because we can convert std::unique_ptr
to std::shared_ptr
but the opposite is not allowed.
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.
Sure. I mostly copied this from DART 😅
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.
Yeah, DART also needs to be tweaked. 😞 There is (or was) ongoing discussion: dartsim/dart#845
This is a first attempt at a kinematic version of
dart::simulation::World
. Using a DARTWorld
as our default environment representation forces users to instantiate a dynamics engine, which is unnecessary overhead for many of our tasks. We'll add more functionality in future PRs.Before creating a pull request
make format
Before merging a pull request
CHANGELOG.md