Skip to content

Commit

Permalink
pydart: Add JacobianNode and operational space controller example (#1323
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jslee02 authored May 19, 2019
1 parent 10ad8e2 commit 57cbef1
Show file tree
Hide file tree
Showing 17 changed files with 1,139 additions and 196 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* Added grid visual: [#1318](https://github.com/dartsim/dart/pull/1318)
* Added ReferentialSkeleton, Linkage, and Chain: [#1321](https://github.com/dartsim/dart/pull/1321)
* Enabled WorldNode classes to overload virtual functions in Python: [#1322](https://github.com/dartsim/dart/pull/1322)
* Added JacobianNode and operational space controller example: [#1323](https://github.com/dartsim/dart/pull/1323)

### [DART 6.8.4 (2019-05-03)](https://github.com/dartsim/dart/milestone/56?closed=1)

Expand Down
4 changes: 2 additions & 2 deletions python/dartpy/common/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
namespace dart {
namespace python {

// void Subject(pybind11::module& sm);
void Subject(pybind11::module& sm);
void Uri(pybind11::module& sm);

void dart_common(pybind11::module& m)
{
auto sm = m.def_submodule("common");

// Subject(sm);
Subject(sm);
Uri(sm);
}

Expand Down
224 changes: 213 additions & 11 deletions python/dartpy/dynamics/BodyNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,215 @@
#include "eigen_geometry_pybind.h"
#include "eigen_pybind.h"

PYBIND11_DECLARE_HOLDER_TYPE(T, dart::dynamics::TemplateBodyNodePtr<T>, true);

namespace dart {
namespace python {

void BodyNode(pybind11::module& m)
{
::pybind11::class_<dart::dynamics::BodyNode, dart::dynamics::Frame>(
m, "BodyNode")
::pybind11::class_<
dart::dynamics::TemplatedJacobianNode<dart::dynamics::BodyNode>,
dart::dynamics::JacobianNode,
std::shared_ptr<
dart::dynamics::TemplatedJacobianNode<dart::dynamics::BodyNode>>>(
m, "TemplatedJacobianBodyNode")
.def(
"getJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobian(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::Jacobian {
return self->getJacobian(_offset);
},
::pybind11::arg("_offset"))
.def(
"getJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobian(_offset, _inCoordinatesOf);
},
::pybind11::arg("_offset"),
::pybind11::arg("_inCoordinatesOf"))
.def(
"getWorldJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::Jacobian {
return self->getWorldJacobian(_offset);
},
::pybind11::arg("_offset"))
.def(
"getLinearJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self) -> dart::math::LinearJacobian {
return self->getLinearJacobian();
})
.def(
"getLinearJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::LinearJacobian {
return self->getLinearJacobian(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getLinearJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::LinearJacobian {
return self->getLinearJacobian(_offset);
},
::pybind11::arg("_offset"))
.def(
"getLinearJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::LinearJacobian {
return self->getLinearJacobian(_offset, _inCoordinatesOf);
},
::pybind11::arg("_offset"),
::pybind11::arg("_inCoordinatesOf"))
.def(
"getAngularJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self) -> dart::math::AngularJacobian {
return self->getAngularJacobian();
})
.def(
"getAngularJacobian",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::AngularJacobian {
return self->getAngularJacobian(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getJacobianSpatialDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobianSpatialDeriv(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getJacobianSpatialDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::Jacobian {
return self->getJacobianSpatialDeriv(_offset);
},
::pybind11::arg("_offset"))
.def(
"getJacobianSpatialDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobianSpatialDeriv(_offset, _inCoordinatesOf);
},
::pybind11::arg("_offset"),
::pybind11::arg("_inCoordinatesOf"))
.def(
"getJacobianClassicDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobianClassicDeriv(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getJacobianClassicDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::Jacobian {
return self->getJacobianClassicDeriv(_offset);
},
::pybind11::arg("_offset"))
.def(
"getJacobianClassicDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::Jacobian {
return self->getJacobianClassicDeriv(_offset, _inCoordinatesOf);
},
::pybind11::arg("_offset"),
::pybind11::arg("_inCoordinatesOf"))
.def(
"getLinearJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self) -> dart::math::LinearJacobian {
return self->getLinearJacobianDeriv();
})
.def(
"getLinearJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::LinearJacobian {
return self->getLinearJacobianDeriv(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"))
.def(
"getLinearJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset) -> dart::math::LinearJacobian {
return self->getLinearJacobianDeriv(_offset);
},
::pybind11::arg("_offset"))
.def(
"getLinearJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const Eigen::Vector3d& _offset,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::LinearJacobian {
return self->getLinearJacobianDeriv(_offset, _inCoordinatesOf);
},
::pybind11::arg("_offset"),
::pybind11::arg("_inCoordinatesOf"))
.def(
"getAngularJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self) -> dart::math::AngularJacobian {
return self->getAngularJacobianDeriv();
})
.def(
"getAngularJacobianDeriv",
+[](const dart::dynamics::TemplatedJacobianNode<
dart::dynamics::BodyNode>* self,
const dart::dynamics::Frame* _inCoordinatesOf)
-> dart::math::AngularJacobian {
return self->getAngularJacobianDeriv(_inCoordinatesOf);
},
::pybind11::arg("_inCoordinatesOf"));

::pybind11::class_<
dart::dynamics::BodyNode,
dart::dynamics::TemplatedJacobianNode<dart::dynamics::BodyNode>,
dart::dynamics::Frame,
dart::dynamics::BodyNodePtr>(m, "BodyNode")
.def(
"setAllNodeStates",
+[](dart::dynamics::BodyNode* self,
Expand Down Expand Up @@ -102,14 +304,14 @@ void BodyNode(pybind11::module& m)
dart::dynamics::Node::State,
std::default_delete<
dart::dynamics::Node::
State> > >,
State>>>,
std::default_delete<
dart::common::CloneableVector<
std::unique_ptr<
dart::dynamics::Node::State,
std::default_delete<
dart::dynamics::Node::
State> > > > >,
State>>>>>,
std::less<std::type_index>,
std::allocator<std::pair<
const std::type_index,
Expand All @@ -119,15 +321,15 @@ void BodyNode(pybind11::module& m)
dart::dynamics::Node::State,
std::default_delete<
dart::dynamics::Node::
State> > >,
State>>>,
std::default_delete<
dart::common::CloneableVector<
std::unique_ptr<
dart::dynamics::Node::
State,
std::default_delete<
dart::dynamics::Node::
State> > > > > > > > >,
State>>>>>>>>>,
&dart::dynamics::detail::setAllNodeStates,
&dart::dynamics::detail::getAllNodeStates>,
dart::common::ProxyCloneable<
Expand All @@ -141,15 +343,15 @@ void BodyNode(pybind11::module& m)
dart::dynamics::Node::Properties,
std::default_delete<
dart::dynamics::Node::
Properties> > >,
Properties>>>,
std::default_delete<
dart::common::CloneableVector<
std::unique_ptr<
dart::dynamics::Node::
Properties,
std::default_delete<
dart::dynamics::Node::
Properties> > > > >,
Properties>>>>>,
std::less<std::type_index>,
std::allocator<std::pair<
const std::type_index,
Expand All @@ -160,18 +362,18 @@ void BodyNode(pybind11::module& m)
Properties,
std::default_delete<
dart::dynamics::Node::
Properties> > >,
Properties>>>,
std::default_delete<
dart::common::CloneableVector<
std::unique_ptr<
dart::dynamics::Node::
Properties,
std::default_delete<
dart::dynamics::Node::
Properties> > > > > > > > >,
Properties>>>>>>>>>,
&dart::dynamics::detail::setAllNodeProperties,
&dart::dynamics::detail::
getAllNodeProperties> > > >::AspectState&
getAllNodeProperties>>>>::AspectState&
state) { self->setAspectState(state); },
::pybind11::arg("state"))
.def(
Expand Down
Loading

0 comments on commit 57cbef1

Please sign in to comment.