link_model.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
41 
42 moveit::core::LinkModel::LinkModel(const std::string& name)
43  : name_(name)
44  , parent_joint_model_(NULL)
45  , parent_link_model_(NULL)
46  , is_parent_joint_fixed_(false)
47  , joint_origin_transform_is_identity_(true)
48  , first_collision_body_transform_index_(-1)
49  , link_index_(-1)
50 {
51  joint_origin_transform_.setIdentity();
52 }
53 
55 {
56 }
57 
58 void moveit::core::LinkModel::setJointOriginTransform(const Eigen::Affine3d& transform)
59 {
60  joint_origin_transform_ = transform;
62  joint_origin_transform_.rotation().isIdentity() &&
63  joint_origin_transform_.translation().norm() < std::numeric_limits<double>::epsilon();
64 }
65 
67 {
68  parent_joint_model_ = joint;
70 }
71 
72 void moveit::core::LinkModel::setGeometry(const std::vector<shapes::ShapeConstPtr>& shapes,
73  const EigenSTL::vector_Affine3d& origins)
74 {
75  shapes_ = shapes;
78 
79  core::AABB aabb;
80 
81  for (std::size_t i = 0; i < shapes_.size(); ++i)
82  {
84  (collision_origin_transform_[i].rotation().isIdentity() &&
85  collision_origin_transform_[i].translation().norm() < std::numeric_limits<double>::epsilon()) ?
86  1 :
87  0;
88  Eigen::Affine3d transform = collision_origin_transform_[i];
89 
90  if (shapes_[i]->type != shapes::MESH)
91  {
92  Eigen::Vector3d extents = shapes::computeShapeExtents(shapes_[i].get());
93  aabb.extendWithTransformedBox(transform, extents);
94  }
95  else
96  {
97  // we cannot use shapes::computeShapeExtents() for meshes, since that method does not provide information about
98  // the offset of the mesh origin
99  const shapes::Mesh* mesh = dynamic_cast<const shapes::Mesh*>(shapes_[i].get());
100  for (unsigned int j = 0; j < mesh->vertex_count; ++j)
101  {
102  aabb.extend(transform * Eigen::Map<Eigen::Vector3d>(&mesh->vertices[3 * j]));
103  }
104  }
105  }
106 
107  centered_bounding_box_offset_ = aabb.center();
108  shape_extents_ = aabb.sizes();
109 }
110 
111 void moveit::core::LinkModel::setVisualMesh(const std::string& visual_mesh, const Eigen::Affine3d& origin,
112  const Eigen::Vector3d& scale)
113 {
114  visual_mesh_filename_ = visual_mesh;
115  visual_mesh_origin_ = origin;
116  visual_mesh_scale_ = scale;
117 }
std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > vector_Affine3d
void setJointOriginTransform(const Eigen::Affine3d &transform)
Definition: link_model.cpp:58
Eigen::Vector3d visual_mesh_scale_
Scale factor associated with the visual geometry mesh of this link.
Definition: link_model.h:275
const JointModel * parent_joint_model_
JointModel that connects this link to the parent link.
Definition: link_model.h:232
std::vector< int > collision_origin_transform_is_identity_
Flag indicating if the constant transform applied to the collision geometry of the link (local) is id...
Definition: link_model.h:254
unsigned int vertex_count
double * vertices
void extendWithTransformedBox(const Eigen::Affine3d &transform, const Eigen::Vector3d &box)
Extend with a box transformed by the given transform.
Definition: aabb.cpp:39
Eigen::Affine3d visual_mesh_origin_
The additional origin transform for the mesh.
Definition: link_model.h:272
A joint from the robot. Models the transform that this joint applies in the kinematic chain...
Definition: joint_model.h:108
Eigen::Vector3d shape_extents_
The extents of shape (dimensions of axis aligned bounding box when shape is at origin).
Definition: link_model.h:263
bool joint_origin_transform_is_identity_
True of the joint origin transform is identity.
Definition: link_model.h:244
void setGeometry(const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Affine3d &origins)
Definition: link_model.cpp:72
Eigen::Vector3d centered_bounding_box_offset_
Center of the axis aligned bounding box with size shape_extents_ (zero if symmetric along all axes)...
Definition: link_model.h:266
std::string visual_mesh_filename_
Filename associated with the visual geometry mesh of this link. If empty, no mesh was used...
Definition: link_model.h:269
Eigen::Affine3d joint_origin_transform_
The constant transform applied to the link (local)
Definition: link_model.h:247
EigenSTL::vector_Affine3d collision_origin_transform_
The constant transform applied to the collision geometry of the link (local)
Definition: link_model.h:250
void setParentJointModel(const JointModel *joint)
Definition: link_model.cpp:66
Eigen::Vector3d computeShapeExtents(const ShapeMsg &shape_msg)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW LinkModel(const std::string &name)
Definition: link_model.cpp:42
JointType getType() const
Get the type of joint.
Definition: joint_model.h:137
void setVisualMesh(const std::string &visual_mesh, const Eigen::Affine3d &origin, const Eigen::Vector3d &scale)
Definition: link_model.cpp:111
std::vector< shapes::ShapeConstPtr > shapes_
The collision geometry of the link.
Definition: link_model.h:260
Represents an axis-aligned bounding box.
Definition: aabb.h:47
bool is_parent_joint_fixed_
True if the parent joint of this link is fixed.
Definition: link_model.h:241


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Mon Jan 15 2018 03:50:44