Newer
Older
andreadelprete
committed
//
// Copyright (c) 2017 CNRS
//
// This file is part of PinInvDyn
// pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
// PinInvDyn is distributed in the hope that it will be
andreadelprete
committed
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// PinInvDyn If not, see
andreadelprete
committed
// <http://www.gnu.org/licenses/>.
//
#ifndef __invdyn_robot_wrapper_hpp__
#define __invdyn_robot_wrapper_hpp__
andreadelprete
committed
#include "pininvdyn/math/fwd.hpp"
#include <pinocchio/multibody/model.hpp>
#include <pinocchio/parsers/urdf.hpp>
#include <pinocchio/algorithm/center-of-mass.hpp>
#include <pinocchio/algorithm/compute-all-terms.hpp>
#include <pinocchio/algorithm/jacobian.hpp>
#include <pinocchio/algorithm/frames.hpp>
#include <pinocchio/spatial/skew.hpp>
andreadelprete
committed
#include <string>
andreadelprete
committed
namespace pininvdyn
{
///
/// \brief Wrapper for a robot based on pinocchio
///
class RobotWrapper
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
andreadelprete
committed
typedef se3::Model Model;
typedef se3::Data Data;
typedef se3::Motion Motion;
typedef se3::Frame Frame;
typedef se3::SE3 SE3;
andreadelprete
committed
typedef pininvdyn::math::Vector Vector;
typedef pininvdyn::math::Vector3 Vector3;
typedef pininvdyn::math::Vector6 Vector6;
typedef pininvdyn::math::Matrix Matrix;
typedef pininvdyn::math::Matrix3x Matrix3x;
andreadelprete
committed
typedef pininvdyn::math::RefVector RefVector;
andreadelprete
committed
typedef pininvdyn::math::ConstRefVector ConstRefVector;
andreadelprete
committed
RobotWrapper(const std::string & filename,
const std::vector<std::string> & package_dirs,
bool verbose=false);
andreadelprete
committed
RobotWrapper(const std::string & filename,
const std::vector<std::string> & package_dirs,
const se3::JointModelVariant & rootJoint,
bool verbose=false);
andreadelprete
committed
virtual int nq() const;
virtual int nv() const;
andreadelprete
committed
///
/// \brief Accessor to model.
///
/// \returns a const reference on the model.
///
const Model & model() const;
void computeAllTerms(Data & data, const Vector & q, const Vector & v) const;
andreadelprete
committed
const Vector & rotor_inertias() const;
const Vector & gear_ratios() const;
bool rotor_inertias(ConstRefVector rotor_inertias);
bool gear_ratios(ConstRefVector gear_ratios);
void com(const Data & data,
RefVector com_pos,
RefVector com_vel,
RefVector com_acc) const;
andreadelprete
committed
const Vector3 & com(const Data & data) const;
const Vector3 & com_vel(const Data & data) const;
const Vector3 & com_acc(const Data & data) const;
const Matrix3x & Jcom(const Data & data) const;
andreadelprete
committed
const Matrix & mass(const Data & data);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const Vector & nonLinearEffects(const Data & data) const;
const SE3 & position(const Data & data,
const Model::JointIndex index) const;
const Motion & velocity(const Data & data,
const Model::JointIndex index) const;
const Motion & acceleration(const Data & data,
const Model::JointIndex index) const;
void jacobianWorld(const Data & data,
const Model::JointIndex index,
Data::Matrix6x & J) const;
void jacobianLocal(const Data & data,
const Model::JointIndex index,
Data::Matrix6x & J) const;
SE3 framePosition(const Data & data,
const Model::FrameIndex index) const;
void framePosition(const Data & data,
const Model::FrameIndex index,
SE3 & framePosition) const;
Motion frameVelocity(const Data & data,
const Model::FrameIndex index) const;
void frameVelocity(const Data & data,
const Model::FrameIndex index,
Motion & frameVelocity) const;
Motion frameAcceleration(const Data & data,
const Model::FrameIndex index) const;
void frameAcceleration(const Data & data,
const Model::FrameIndex index,
Motion & frameAcceleration) const;
Motion frameClassicAcceleration(const Data & data,
const Model::FrameIndex index) const;
void frameClassicAcceleration(const Data & data,
andreadelprete
committed
const Model::FrameIndex index,
Motion & frameAcceleration) const;
void frameJacobianWorld(const Data & data,
const Model::FrameIndex index,
Data::Matrix6x & J) const;
void frameJacobianLocal(const Data & data,
const Model::FrameIndex index,
Data::Matrix6x & J) const;
andreadelprete
committed
protected:
andreadelprete
committed
void updateMd();
andreadelprete
committed
/// \brief Robot model.
Model m_model;
std::string m_model_filename;
bool m_verbose;
andreadelprete
committed
Vector m_rotor_inertias;
Vector m_gear_ratios;
Vector m_Md; /// diagonal part of inertia matrix due to rotor inertias
Matrix m_M; /// inertia matrix including rotor inertias
andreadelprete
committed
};
}
#endif // ifndef __invdyn_robot_wrapper_hpp__