robot_link.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_ROBOT_LINK_H
00031 #define RVIZ_ROBOT_LINK_H
00032 
00033 #include "properties/forwards.h"
00034 #include "selection/forwards.h"
00035 
00036 #include <ogre_helpers/object.h>
00037 
00038 #include <string>
00039 #include <map>
00040 
00041 #include <OGRE/OgreVector3.h>
00042 #include <OGRE/OgreQuaternion.h>
00043 #include <OGRE/OgreAny.h>
00044 #include <OGRE/OgreMaterial.h>
00045 
00046 namespace Ogre
00047 {
00048 class SceneManager;
00049 class Entity;
00050 class SubEntity;
00051 class SceneNode;
00052 class Vector3;
00053 class Quaternion;
00054 class Any;
00055 class RibbonTrail;
00056 }
00057 
00058 namespace rviz
00059 {
00060 class Shape;
00061 class Axes;
00062 }
00063 
00064 namespace urdf
00065 {
00066 class Model;
00067 class Link;
00068 typedef boost::shared_ptr<const Link> LinkConstPtr;
00069 class Geometry;
00070 typedef boost::shared_ptr<const Geometry> GeometryConstPtr;
00071 class Pose;
00072 }
00073 
00074 class TiXmlElement;
00075 
00076 namespace rviz
00077 {
00078 
00079 class PropertyManager;
00080 class Robot;
00081 class VisualizationManager;
00082 class RobotLinkSelectionHandler;
00083 typedef boost::shared_ptr<RobotLinkSelectionHandler> RobotLinkSelectionHandlerPtr;
00084 
00089 class RobotLink
00090 {
00091 public:
00092   RobotLink(Robot* parent, VisualizationManager* manager);
00093   ~RobotLink();
00094 
00095   void load(TiXmlElement* root_element, urdf::Model& descr, const urdf::LinkConstPtr& link, bool visual, bool collision);
00096 
00097   void setAlpha(float a);
00098 
00099   bool getShowTrail();
00100   void setShowTrail( bool show );
00101 
00102   bool getShowAxes();
00103   void setShowAxes( bool show );
00104 
00105   void setTransforms(const Ogre::Vector3& visual_position, const Ogre::Quaternion& visual_orientation,
00106                      const Ogre::Vector3& collision_position, const Ogre::Quaternion& collision_orientation, bool applyOffsetTransforms);
00107 
00108   Ogre::Vector3 getPositionInRobotFrame();
00109   Ogre::Quaternion getOrientationInRobotFrame();
00110 
00111   const std::string& getName() { return name_; }
00112 
00113   void setToErrorMaterial();
00114   void setToNormalMaterial();
00115 
00116   void setPropertyManager(PropertyManager* property_manager);
00117   void createProperties();
00118 
00119   bool isValid();
00120 
00121   void setLinkAlpha( float a );
00122   float getLinkAlpha();
00123 
00124   void setLinkEnabled( bool enabled );
00125   bool getLinkEnabled() { return enabled_; }
00126 
00131   void updateVisibility();
00132 
00133 protected:
00134 
00135   void createEntityForGeometryElement(TiXmlElement* root_element, const urdf::LinkConstPtr& link, const urdf::Geometry& geom, const urdf::Pose& origin, Ogre::SceneNode* parent_node, Ogre::Entity*& entity, Ogre::SceneNode*& scene_node, Ogre::SceneNode*& offset_node);
00136 
00137   void createVisual(TiXmlElement* root_element, const urdf::LinkConstPtr& link);
00138   void createCollision(TiXmlElement* root_element, const urdf::LinkConstPtr& link);
00139   void createSelection(const urdf::Model& descr, const urdf::LinkConstPtr& link);
00140   Ogre::MaterialPtr getMaterialForLink( TiXmlElement* root_element, const urdf::LinkConstPtr& link );
00141   void updateAlpha();
00142 
00143   Robot* parent_;
00144   Ogre::SceneManager* scene_manager_;
00145   PropertyManager* property_manager_;
00146   VisualizationManager* vis_manager_;
00147 
00148   std::string name_;                          
00149 
00150   bool enabled_; 
00151 
00152   typedef std::map<Ogre::SubEntity*, Ogre::MaterialPtr> M_SubEntityToMaterial;
00153   M_SubEntityToMaterial materials_;
00154   Ogre::MaterialPtr default_material_;
00155   std::string default_material_name_;
00156 
00157   Ogre::Entity* visual_mesh_;                 
00158   Ogre::Entity* collision_mesh_;              
00159 
00160   Ogre::SceneNode* visual_node_;              
00161   Ogre::SceneNode* visual_offset_node_;
00162   Ogre::SceneNode* collision_node_;           
00163   Ogre::SceneNode* collision_offset_node_;
00164 
00165   Ogre::Vector3 position_;
00166   Ogre::Quaternion orientation_;
00167 
00168   Ogre::RibbonTrail* trail_;
00169 
00170   Axes* axes_;
00171 
00172   float material_alpha_; 
00173   float link_alpha_; 
00174   float robot_alpha_; 
00175 
00176   // joint stuff
00177   std::string joint_name_;
00178 
00179   CollObjectHandle selection_object_;
00180   RobotLinkSelectionHandlerPtr selection_handler_;
00181 
00182   // properties
00183   CategoryPropertyWPtr link_property_;
00184   Vector3PropertyWPtr position_property_;
00185   QuaternionPropertyWPtr orientation_property_;
00186   BoolPropertyWPtr trail_property_;
00187   BoolPropertyWPtr axes_property_;
00188   FloatPropertyWPtr alpha_property_;
00189 
00190   friend class RobotLinkSelectionHandler;
00191 };
00192 
00193 } // namespace rviz
00194 
00195 #endif // RVIZ_ROBOT_LINK_H


rviz
Author(s): Dave Hershberger, Josh Faust
autogenerated on Mon Jan 6 2014 11:54:32