Skip to content

Commit

Permalink
Merge pull request #832 from dartsim/get_root_joint
Browse files Browse the repository at this point in the history
Add Skeleton::getRootJoint()
  • Loading branch information
jslee02 committed Jan 13, 2017
2 parents 4ce3447 + 95c84b6 commit f7842c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

* Misc

* Added Skeleton::getRootJoint(): [#832](https://github.com/dartsim/dart/pull/832)
* Added CMake targets for code formatting using clang-format: [#811](https://github.com/dartsim/dart/pull/811), [#817](https://github.com/dartsim/dart/pull/817)

### DART 6.1.2 (2016-XX-XX)
Expand Down
17 changes: 17 additions & 0 deletions dart/dynamics/Skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,23 @@ const BodyNode* Skeleton::getRootBodyNode(std::size_t _treeIdx) const
return const_cast<Skeleton*>(this)->getRootBodyNode(_treeIdx);
}

//==============================================================================
Joint* Skeleton::getRootJoint(std::size_t treeIdx)
{
auto rootBodyNode = getRootBodyNode(treeIdx);

if (rootBodyNode)
return rootBodyNode->getParentJoint();

return nullptr;
}

//==============================================================================
const Joint* Skeleton::getRootJoint(std::size_t treeIdx) const
{
return const_cast<Skeleton*>(this)->getRootJoint(treeIdx);
}

//==============================================================================
BodyNode* Skeleton::getBodyNode(std::size_t _idx)
{
Expand Down
7 changes: 7 additions & 0 deletions dart/dynamics/Skeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ class Skeleton :
/// _treeIdx
const BodyNode* getRootBodyNode(std::size_t _treeIdx = 0) const;

/// Get the root Joint of the tree whose index in this Skeleton is treeIdx
Joint* getRootJoint(std::size_t treeIdx = 0u);

/// Get the const root Joint of the tree whose index in this Skeleton is
/// treeIdx
const Joint* getRootJoint(std::size_t treeIdx = 0u) const;

// Documentation inherited
BodyNode* getBodyNode(std::size_t _idx) override;

Expand Down

0 comments on commit f7842c7

Please sign in to comment.