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_H_ 00031 #define RVIZ_ROBOT_H_ 00032 00033 #include "link_updater.h" 00034 00035 #include <string> 00036 #include <map> 00037 00038 #include <OGRE/OgreVector3.h> 00039 #include <OGRE/OgreQuaternion.h> 00040 #include <OGRE/OgreAny.h> 00041 00042 namespace Ogre 00043 { 00044 class SceneManager; 00045 class Entity; 00046 class SceneNode; 00047 class Vector3; 00048 class Quaternion; 00049 class Any; 00050 class RibbonTrail; 00051 } 00052 00053 namespace rviz 00054 { 00055 class Object; 00056 class Axes; 00057 } 00058 00059 namespace planning_models 00060 { 00061 class KinematicModel; 00062 } 00063 00064 namespace tf 00065 { 00066 class TransformListener; 00067 } 00068 00069 namespace urdf 00070 { 00071 class Model; 00072 } 00073 00074 class TiXmlElement; 00075 00076 namespace rviz 00077 { 00078 00079 class Property; 00080 class Robot; 00081 class RobotLink; 00082 class DisplayContext; 00083 00090 class Robot 00091 { 00092 public: 00093 Robot( DisplayContext* context, const std::string& name, Property* parent_property ); 00094 ~Robot(); 00095 00103 void load( TiXmlElement* root_element, urdf::Model &descr, bool visual = true, bool collision = true ); 00104 00108 void clear(); 00109 00110 void update(const LinkUpdater& updater); 00111 00116 void setVisible( bool visible ); 00117 00122 void setVisualVisible( bool visible ); 00123 00128 void setCollisionVisible( bool visible ); 00129 00133 bool isVisualVisible(); 00137 bool isCollisionVisible(); 00138 00139 void setAlpha(float a); 00140 float getAlpha() { return alpha_; } 00141 00142 RobotLink* getLink( const std::string& name ); 00143 00144 const std::string& getName() { return name_; } 00145 00146 Ogre::SceneNode* getVisualNode() { return root_visual_node_; } 00147 Ogre::SceneNode* getCollisionNode() { return root_collision_node_; } 00148 Ogre::SceneNode* getOtherNode() { return root_other_node_; } 00149 00150 virtual void setPosition( const Ogre::Vector3& position ); 00151 virtual void setOrientation( const Ogre::Quaternion& orientation ); 00152 virtual void setScale( const Ogre::Vector3& scale ); 00153 virtual const Ogre::Vector3& getPosition(); 00154 virtual const Ogre::Quaternion& getOrientation(); 00155 00156 protected: 00158 void updateLinkVisibilities(); 00159 00160 Ogre::SceneManager* scene_manager_; 00161 00162 typedef std::map< std::string, RobotLink* > M_NameToLink; 00163 M_NameToLink links_; 00164 00165 Ogre::SceneNode* root_visual_node_; 00166 Ogre::SceneNode* root_collision_node_; 00167 Ogre::SceneNode* root_other_node_; 00168 00169 bool visual_visible_; 00170 bool collision_visible_; 00171 00172 DisplayContext* context_; 00173 Property* links_category_; 00174 00175 std::string name_; 00176 float alpha_; 00177 }; 00178 00179 } // namespace rviz 00180 00181 #endif /* RVIZ_ROBOT_H_ */