2 #include "trajopt/common.hpp"
3 #include "utils/eigen_conversions.hpp"
8 OpenRAVE::KinBodyPtr m_body;
13 m_body(body), m_r(0, 0, 0), m_q(1,0,0,0) {
15 virtual void SetDOFValues(
const DblVec& dofs) {
17 T.trans = OR::Vector(dofs[0], dofs[1], dofs[2]);
18 m_r = OR::Vector(dofs[3],dofs[4], dofs[5]);
19 T.rot = OpenRAVE::geometry::quatMultiply(OpenRAVE::geometry::quatFromAxisAngle(m_r), m_q);
20 m_body->SetTransform(T);
22 virtual void GetDOFLimits(DblVec& lower, DblVec& upper)
const {
23 lower = DblVec(6, -INFINITY);
24 upper = DblVec(6, INFINITY);
26 virtual DblVec GetDOFValues() {
29 OpenRAVE::Transform T = m_body->GetTransform();
39 virtual int GetDOF()
const {
42 virtual OpenRAVE::EnvironmentBasePtr GetEnv() {
43 return m_body->GetEnv();
45 virtual DblMatrix PositionJacobian(
int link_ind,
const OR::Vector& pt)
const {
47 out.leftCols(3) = Matrix3d::Identity();
48 assert(link_ind == 0);
49 KinBody::LinkPtr link = m_body->GetLinks()[link_ind];
50 OpenRAVE::Vector dr = pt - link->GetTransform().trans;
51 double matdata[9] = { 0, dr[2], -dr[1], -dr[2], 0, dr[0], dr[1], -dr[0], 0 };
52 out.rightCols(3) = Eigen::Map<MatrixXd>(matdata, 3, 3);
55 virtual DblMatrix RotationJacobian(
int link_ind)
const {
56 PRINT_AND_THROW(
"not implemented");
58 virtual bool DoesAffect(
const KinBody::Link& link) {
59 const vector<KinBody::LinkPtr>& links = m_body->GetLinks();
60 for (
int i=0; i < links.size(); ++i) {
61 if (links[i].
get() == &link)
return true;
65 virtual std::vector<KinBody::LinkPtr> GetAffectedLinks() {
66 return m_body->GetLinks();
68 virtual void GetAffectedLinks(std::vector<KinBody::LinkPtr>& links,
69 bool only_with_geom, vector<int>& link_inds) {
70 links = GetAffectedLinks();
71 link_inds.resize(links.size());
72 for (
int i = 0; i < links.size(); ++i)
73 link_inds.push_back(links[i]->GetIndex());
75 virtual DblVec RandomDOFValues() {
76 return toDblVec(VectorXd::Random(6));
78 virtual vector<OpenRAVE::KinBodyPtr> GetBodies() {
79 return singleton(m_body);
82 typedef boost::shared_ptr<IncrementalRB> IncrementalRBPtr;