00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RVIZ_ROBOT_LINK_H
00031 #define RVIZ_ROBOT_LINK_H
00032
00033 #include <QObject>
00034
00035 #include "selection/forwards.h"
00036
00037 #include <ogre_helpers/object.h>
00038
00039 #include <string>
00040 #include <map>
00041
00042 #include <OGRE/OgreVector3.h>
00043 #include <OGRE/OgreQuaternion.h>
00044 #include <OGRE/OgreAny.h>
00045 #include <OGRE/OgreMaterial.h>
00046
00047 namespace Ogre
00048 {
00049 class SceneManager;
00050 class Entity;
00051 class SubEntity;
00052 class SceneNode;
00053 class Vector3;
00054 class Quaternion;
00055 class Any;
00056 class RibbonTrail;
00057 }
00058
00059 namespace rviz
00060 {
00061 class Shape;
00062 class Axes;
00063 }
00064
00065 namespace urdf
00066 {
00067 class Model;
00068 class Link;
00069 typedef boost::shared_ptr<const Link> LinkConstPtr;
00070 class Geometry;
00071 typedef boost::shared_ptr<const Geometry> GeometryConstPtr;
00072 class Pose;
00073 }
00074
00075 class TiXmlElement;
00076
00077 namespace rviz
00078 {
00079
00080 class DisplayContext;
00081 class FloatProperty;
00082 class Property;
00083 class QuaternionProperty;
00084 class Robot;
00085 class RobotLinkSelectionHandler;
00086 class VectorProperty;
00087 typedef boost::shared_ptr<RobotLinkSelectionHandler> RobotLinkSelectionHandlerPtr;
00088
00093 class RobotLink: public QObject
00094 {
00095 Q_OBJECT
00096 public:
00097 RobotLink( Robot* parent, DisplayContext* context, Property* parent_property );
00098 ~RobotLink();
00099
00100 void load( TiXmlElement* root_element, urdf::Model& descr, const urdf::LinkConstPtr& link, bool visual, bool collision );
00101
00102 void setRobotAlpha(float a);
00103
00104 void setTransforms(const Ogre::Vector3& visual_position, const Ogre::Quaternion& visual_orientation,
00105 const Ogre::Vector3& collision_position, const Ogre::Quaternion& collision_orientation, bool applyOffsetTransforms);
00106
00107 const std::string& getName() { return name_; }
00108
00109 void setToErrorMaterial();
00110 void setToNormalMaterial();
00111
00112 Ogre::Vector3 getPosition();
00113 Ogre::Quaternion getOrientation();
00114
00115 bool isValid();
00116
00117 public Q_SLOTS:
00122 void updateVisibility();
00123
00124 private Q_SLOTS:
00125 void updateAlpha();
00126 void updateTrail();
00127 void updateAxes();
00128
00129 private:
00130 bool getEnabled() const;
00131 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);
00132
00133 void createVisual(TiXmlElement* root_element, const urdf::LinkConstPtr& link);
00134 void createCollision(TiXmlElement* root_element, const urdf::LinkConstPtr& link);
00135 void createSelection(const urdf::Model& descr, const urdf::LinkConstPtr& link);
00136 Ogre::MaterialPtr getMaterialForLink( TiXmlElement* root_element, const urdf::LinkConstPtr& link );
00137
00138 Robot* parent_;
00139 Ogre::SceneManager* scene_manager_;
00140 DisplayContext* context_;
00141
00142 std::string name_;
00143
00144 bool enabled_;
00145
00146 typedef std::map<Ogre::SubEntity*, Ogre::MaterialPtr> M_SubEntityToMaterial;
00147 M_SubEntityToMaterial materials_;
00148 Ogre::MaterialPtr default_material_;
00149 std::string default_material_name_;
00150
00151 Ogre::Entity* visual_mesh_;
00152 Ogre::Entity* collision_mesh_;
00153
00154 Ogre::SceneNode* visual_node_;
00155 Ogre::SceneNode* visual_offset_node_;
00156 Ogre::SceneNode* collision_node_;
00157 Ogre::SceneNode* collision_offset_node_;
00158
00159 Ogre::RibbonTrail* trail_;
00160
00161 Axes* axes_;
00162
00163 float material_alpha_;
00164 float robot_alpha_;
00165
00166
00167 std::string joint_name_;
00168
00169 CollObjectHandle selection_object_;
00170 RobotLinkSelectionHandlerPtr selection_handler_;
00171
00172
00173 Property* link_property_;
00174 VectorProperty* position_property_;
00175 QuaternionProperty* orientation_property_;
00176 Property* trail_property_;
00177 Property* axes_property_;
00178 FloatProperty* alpha_property_;
00179
00180 friend class RobotLinkSelectionHandler;
00181 };
00182
00183 }
00184
00185 #endif // RVIZ_ROBOT_LINK_H