18 #ifndef __tsid_python_robot_wrapper_hpp__ 19 #define __tsid_python_robot_wrapper_hpp__ 29 template <
typename Robot>
31 :
public boost::python::def_visitor<RobotPythonVisitor<Robot> > {
33 typedef Eigen::Matrix<double, 3, Eigen::Dynamic>
Matrix3x;
35 template <
class PyClass>
39 .def(bp::init<std::string, std_vec, bool>(
40 (bp::arg(
"filename"), bp::arg(
"package_dir"), bp::arg(
"verbose")),
41 "Default constructor without RootJoint."))
43 bool>((bp::arg(
"filename"), bp::arg(
"package_dir"),
44 bp::arg(
"roottype"), bp::arg(
"verbose")),
45 "Default constructor with RootJoint."))
46 .def(bp::init<pinocchio::Model, bool>(
47 (bp::arg(
"Pinocchio Model"), bp::arg(
"verbose")),
48 "Default constructor from pinocchio model without RootJoint."))
51 (bp::arg(
"Pinocchio Model"), bp::arg(
"rootJoint"),
53 "Default constructor from pinocchio model with RootJoint."))
56 .add_property(
"nq", &Robot::nq)
59 .add_property(
"nq_actuated", &Robot::nq_actuated)
60 .add_property(
"is_fixed_base", &Robot::is_fixed_base)
68 bp::arg(
"inertia vector"))
70 bp::arg(
"gear ratio vector"))
73 bp::args(
"data",
"q",
"v"),
"compute all dynamics")
82 bp::args(
"data",
"index"))
84 bp::args(
"data",
"index"))
86 bp::args(
"data",
"index"))
89 bp::args(
"data",
"index"))
91 bp::args(
"data",
"index"))
93 bp::args(
"data",
"index"))
94 .def(
"frameClassicAcceleration",
96 bp::args(
"data",
"index"))
97 .def(
"frameVelocityWorldOriented",
99 bp::args(
"data",
"index"))
100 .def(
"frameAccelerationWorldOriented",
102 bp::args(
"data",
"index"))
103 .def(
"frameClassicAccelerationWorldOriented",
105 bp::args(
"data",
"index"))
106 .def(
"angularMomentumTimeVariation",
112 const std::string &
filename,
const std::vector<std::string> &stdvec,
113 bp::object &bpObject,
bool verbose) {
115 bp::extract<pinocchio::JointModelFreeFlyer>(bpObject)();
116 boost::shared_ptr<Robot>
p(
127 return self.rotor_inertias();
130 return self.gear_ratios();
133 return self.rotor_inertias(rotor_inertias);
136 return self.gear_ratios(gear_ratios);
140 return self.com(data);
142 static Eigen::Vector3d
com_vel(
const Robot &
self,
144 return self.com_vel(data);
146 static Eigen::Vector3d
com_acc(
const Robot &
self,
148 return self.com_acc(data);
151 return self.Jcom(data);
154 const Eigen::VectorXd &
q,
155 const Eigen::VectorXd &
v) {
156 self.computeAllTerms(data, q, v);
159 return self.mass(data);
163 return self.nonLinearEffects(data);
167 return self.position(data, index);
172 return self.velocity(data, index);
177 return self.acceleration(data, index);
182 return self.framePosition(data, index);
187 return self.frameVelocity(data, index);
192 return self.frameAcceleration(data, index);
197 return self.frameClassicAcceleration(data, index);
202 return self.frameVelocityWorldOriented(data, index);
207 return self.frameAccelerationWorldOriented(data, index);
212 return self.frameClassicAccelerationWorldOriented(data, index);
216 return self.angularMomentumTimeVariation(data);
219 return self.setGravity(gravity);
221 static void expose(
const std::string &class_name) {
222 std::string doc =
"Robot Wrapper info.";
223 bp::class_<Robot>(class_name.c_str(), doc.c_str(), bp::no_init)
226 bp::enum_<robots::RobotWrapper::RootJointType>(
"RootJointType")
228 .value(
"FLOATING_BASE_SYSTEM",
236 #endif // ifndef __tsid_python_robot_wrapper_hpp__ static Eigen::VectorXd rotor_inertias(const Robot &self)
enum tsid::robots::RobotWrapper::e_RootJointType RootJointType
static Eigen::Vector3d com_vel(const Robot &self, const pinocchio::Data &data)
static pinocchio::SE3 position(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::JointIndex &index)
void visit(PyClass &cl) const
void def(const char *name, Func func)
static Eigen::VectorXd gear_ratios(const Robot &self)
static pinocchio::Motion velocity(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::JointIndex &index)
Eigen::Matrix< double, 3, Eigen::Dynamic > Matrix3x
pinocchio::FrameIndex FrameIndex
static Eigen::Vector3d angularMomentumTimeVariation(const Robot &self, const pinocchio::Data &data)
static bool set_gear_ratios(Robot &self, Eigen::VectorXd &gear_ratios)
static Matrix3x Jcom(const Robot &self, const pinocchio::Data &data)
static void computeAllTerms(const Robot &self, pinocchio::Data &data, const Eigen::VectorXd &q, const Eigen::VectorXd &v)
pinocchio::JointIndex JointIndex
static pinocchio::Data data(const Robot &self)
static boost::shared_ptr< Robot > makeClass(const std::string &filename, const std::vector< std::string > &stdvec, bp::object &bpObject, bool verbose)
static Eigen::Vector3d com(const Robot &self, const pinocchio::Data &data)
static Eigen::Vector3d com_acc(const Robot &self, const pinocchio::Data &data)
static pinocchio::Motion frameClassicAcceleration(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
static pinocchio::Model model(const Robot &self)
void init(bool compute_local_aabb=true)
static pinocchio::Motion frameClassicAccelerationWorldOriented(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
Wrapper for a robot based on pinocchio.
static Eigen::VectorXd nonLinearEffects(const Robot &self, const pinocchio::Data &data)
static pinocchio::Motion frameAccelerationWorldOriented(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
static Eigen::MatrixXd mass(Robot &self, pinocchio::Data &data)
JointCollectionDefault::JointModelVariant JointModelVariant
static void setGravity(Robot &self, const pinocchio::Motion &gravity)
static pinocchio::Motion frameVelocityWorldOriented(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
static void expose(const std::string &class_name)
static pinocchio::Motion acceleration(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::JointIndex &index)
static bool set_rotor_inertias(Robot &self, Eigen::VectorXd &rotor_inertias)
std::vector< std::string > std_vec
static pinocchio::Motion frameAcceleration(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
static pinocchio::SE3 framePosition(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)
static pinocchio::Motion frameVelocity(const Robot &self, const pinocchio::Data &data, const pinocchio::Model::FrameIndex &index)