11 bool success =
loadURDF(description_param, model);
15 std::unique_ptr<hebi::robot_model::RobotModel> robot_model =
parseURDF(model);
19 models.emplace(name, std::move(robot_model));
29 if (
models.count(model_name) == 0)
31 return &
models.at(model_name);
40 if (!model.
initParam(description_param)) {
52 message_(
"Structures of type " + structure_type +
" not yet supported.") {
54 const char*
what() const noexcept
override {
55 return message_.c_str();
64 message_(
"Joints of type " + joint_type +
" not yet supported.") {
66 const char*
what() const noexcept
override {
67 return message_.c_str();
74 Eigen::Matrix4d res = Eigen::Matrix4d::Identity();
77 res(0, 3) = pose.position.x;
78 res(1, 3) = pose.position.y;
79 res(2, 3) = pose.position.z;
84 Eigen::Matrix4d com = Eigen::Matrix4d::Identity();
85 Eigen::VectorXd inertia;
87 inertia << 0, 0, 0, 0, 0, 0;
91 auto& inertial = link.inertial;
95 inertial->ixx, inertial->iyy, inertial->izz,
96 inertial->ixy, inertial->ixz, inertial->iyz;
97 mass = inertial->mass;
100 auto& child_links = link.child_links;
104 if (child_links.size() > 1)
107 if (child_links.size() == 0) {
109 Eigen::Matrix4d output = Eigen::Matrix4d::Identity();
117 auto& child_link = child_links[0];
118 auto& child_joint = child_link->parent_joint;
119 Eigen::Matrix4d output =
128 for (
auto& child_link : child_links) {
129 auto& child_joint = child_link->parent_joint;
132 if (child_joint->type == urdf::Joint::REVOLUTE | child_joint->type == urdf::Joint::CONTINUOUS) {
133 if (child_joint->axis.x != 0) {
134 if (child_joint->axis.y != 0 && child_joint->axis.z != 0) {
138 }
else if (child_joint->axis.y != 0) {
139 if (child_joint->axis.z != 0) {
143 }
else if (child_joint->axis.z != 0) {
147 }
else if (child_joint->type == urdf::Joint::PRISMATIC) {
148 if (child_joint->axis.x != 0) {
149 if (child_joint->axis.y != 0 && child_joint->axis.z != 0) {
153 }
else if (child_joint->axis.y != 0) {
154 if (child_joint->axis.z != 0) {
158 }
else if (child_joint->axis.z != 0) {
162 }
else if (child_joint->type == urdf::Joint::FIXED) {
175 const urdf::Link*
root = model.getRoot().get();
181 auto& children = root->child_links;
182 if (children.size() != 1) {
185 auto& child = children[0];
186 if (child->parent_joint->type != urdf::Joint::FIXED) {
194 }
catch (
const std::exception& e) {
UnsupportedStructureException(const std::string &structure_type)
void parseInner(const urdf::Link &link, hebi::robot_model::RobotModel &model)
UnsupportedJointException(const std::string &joint_type)
bool addJoint(HebiJointType joint_type, bool combine)
Adds a degree of freedom about the specified axis.
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const
Represents a chain or tree of robot elements (rigid bodies and joints).
HebirosModel(std::unique_ptr< hebi::robot_model::RobotModel > model_)
static std::map< std::string, HebirosModel > models
EIGEN_DEVICE_FUNC const Scalar & q
static bool loadURDF(const std::string &description_param, urdf::Model &model)
bool addRigidBody(const Eigen::Matrix4d &com, const Eigen::VectorXd &inertia, double mass, const Eigen::Matrix4d &output, bool combine)
Adds a rigid body with the specified properties to the robot model.
Eigen::MatrixXd ROSPoseToEigenMatrix(const urdf::Pose &pose)
URDF_EXPORT bool initParam(const std::string ¶m)
#define ROS_WARN_STREAM(args)
hebi::robot_model::RobotModel & getModel()
#define ROS_INFO_STREAM(args)
The quaternion class used to represent 3D orientations and rotations.
static bool load(const std::string &name, const std::string &description_param)
const char * what() const noexceptoverride
std::unique_ptr< hebi::robot_model::RobotModel > model
#define ROS_ERROR_STREAM(args)
const char * what() const noexceptoverride
static std::unique_ptr< hebi::robot_model::RobotModel > parseURDF(const urdf::Model &model)