00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2012, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 /* Author: Ioan Sucan */ 00036 00037 #ifndef MOVEIT_ROBOT_STATE_LINK_STATE_ 00038 #define MOVEIT_ROBOT_STATE_LINK_STATE_ 00039 00040 #include <moveit/robot_model/link_model.h> 00041 #include <eigen_stl_containers/eigen_stl_containers.h> 00042 00043 namespace robot_state 00044 { 00045 00046 class RobotState; 00047 class JointState; 00048 class AttachedBody; 00049 00051 class LinkState 00052 { 00053 friend class RobotState; 00054 public: 00055 00056 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00057 00059 LinkState(RobotState *state, const robot_model::LinkModel *lm); 00060 00061 ~LinkState(); 00062 00064 const std::string& getName() const 00065 { 00066 return link_model_->getName(); 00067 } 00068 00070 const RobotState *getRobotState() const 00071 { 00072 return robot_state_; 00073 } 00074 00076 RobotState *getRobotState() 00077 { 00078 return robot_state_; 00079 } 00080 00082 void computeTransform(); 00083 00084 void computeTransformForward(const Eigen::Affine3d& transform); 00085 void computeTransformBackward(const Eigen::Affine3d& transform); 00086 00087 void computeGeometryTransforms(); 00088 00090 void updateAttachedBodies(); 00091 00093 const robot_model::LinkModel* getLinkModel() const 00094 { 00095 return link_model_; 00096 } 00097 00099 const JointState* getParentJointState() const 00100 { 00101 return parent_joint_state_; 00102 } 00103 00105 const LinkState* getParentLinkState() const 00106 { 00107 return parent_link_state_; 00108 } 00109 00111 void getAttachedBodies(std::vector<const AttachedBody*> &attached_bodies) const; 00112 00114 const AttachedBody* getAttachedBody(const std::string &id) const; 00115 00117 bool hasAttachedBody(const std::string &id) const; 00118 00120 const Eigen::Affine3d& getGlobalLinkTransform() const 00121 { 00122 return global_link_transform_; 00123 } 00124 00126 const Eigen::Affine3d& getGlobalCollisionBodyTransform() const 00127 { 00128 return global_collision_body_transform_; 00129 } 00130 00131 private: 00132 00133 void computeTransformForward(const LinkState *parent_link); 00134 void computeTransformBackward(const LinkState *child_link); 00135 00137 RobotState *robot_state_; 00138 00139 const robot_model::LinkModel *link_model_; 00140 00141 JointState *parent_joint_state_; 00142 00143 LinkState *parent_link_state_; 00144 00145 std::map<std::string, AttachedBody*> attached_body_map_; 00146 00148 Eigen::Affine3d global_link_transform_; 00149 00151 Eigen::Affine3d global_collision_body_transform_; 00152 }; 00153 } 00154 00155 #endif