robot_joint.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2013, 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_JOINT_H
00031 #define RVIZ_ROBOT_JOINT_H
00032 
00033 #include <string>
00034 #include <map>
00035 
00036 #include <QObject>
00037 
00038 #ifndef Q_MOC_RUN
00039 #include <OgreVector3.h>
00040 #include <OgreQuaternion.h>
00041 #include <OgreAny.h>
00042 #include <OgreMaterial.h>
00043 
00044 #include <urdf/model.h>
00045 #include <urdf_model/pose.h>
00046 #endif
00047 
00048 #include "rviz/ogre_helpers/object.h"
00049 #include "rviz/selection/forwards.h"
00050 
00051 namespace Ogre
00052 {
00053 class SceneManager;
00054 class Entity;
00055 class SubEntity;
00056 class SceneNode;
00057 class Vector3;
00058 class Quaternion;
00059 class Any;
00060 class RibbonTrail;
00061 }
00062 
00063 namespace rviz
00064 {
00065 class Shape;
00066 class Axes;
00067 class DisplayContext;
00068 class FloatProperty;
00069 class Property;
00070 class BoolProperty;
00071 class QuaternionProperty;
00072 class Robot;
00073 class RobotLinkSelectionHandler;
00074 class VectorProperty;
00075 class RobotJoint;
00076 
00077 
00082 class RobotJoint: public QObject
00083 {
00084 Q_OBJECT
00085 public:
00086   RobotJoint( Robot* robot, const urdf::JointConstSharedPtr& joint );
00087   virtual ~RobotJoint();
00088 
00089 
00090   void setTransforms(const Ogre::Vector3& parent_link_position,
00091                      const Ogre::Quaternion& parent_link_orientation);
00092 
00093   const std::string& getName() const { return name_; }
00094   const std::string& getParentLinkName() const { return parent_link_name_; }
00095   const std::string& getChildLinkName() const { return child_link_name_; }
00096   const Property* getJointProperty() const { return joint_property_; }
00097   Property* getJointProperty() { return joint_property_; }
00098   RobotJoint* getParentJoint();
00099   void hideSubProperties(bool hide);
00100 
00101   // Remove joint_property_ from its old parent and add to new_parent.  If new_parent==NULL then leav unparented.
00102   void setParentProperty(Property* new_parent);
00103 
00104   Ogre::Vector3 getPosition();
00105   Ogre::Quaternion getOrientation();
00106 
00107   void setRobotAlpha(float a) {}
00108 
00109   bool hasDescendentLinksWithGeometry() const { return has_decendent_links_with_geometry_; }
00110 
00111   // place subproperties as children of details_ or joint_property_
00112   void useDetailProperty(bool use_detail);
00113 
00114   // expand all sub properties
00115   void expandDetails(bool expand);
00116 
00117   // Set the description for the joint.
00118   // Also sets the checkbox.
00119   // Also sets has_decendent_links_with_geometry_.
00120   // Called when the link_tree style changes.
00121   void setJointPropertyDescription();
00122 
00123   // set checkboxes based on state of descendent link enables
00124   // Should only be called by Robot::calculateJointCheckboxes()
00125   void calculateJointCheckboxesRecursive(
00126       int& links_with_geom,             // returns # of children with geometry
00127       int& links_with_geom_checked,     // returns # of enabled children with geometry
00128       int& links_with_geom_unchecked);  // returns # of disabled children with geometry
00129 
00130 
00131 private Q_SLOTS:
00132   void updateAxes();
00133   void updateChildVisibility();
00134 
00135 private:
00136   bool getEnabled() const;
00137 
00138   // true if displaying in a tree style.  False if list style.
00139   bool styleIsTree() const;
00140 
00141   // determine the state of child link(s)
00142   void getChildLinkState(
00143       int& links_with_geom,             // returns # of children with geometry
00144       int& links_with_geom_checked,     // returns # of enabled children with geometry
00145       int& links_with_geom_unchecked,   // returns # of disabled children with geometry
00146       bool recursive) const;            // True: all descendant links.  False: just single child link.
00147 
00148   // set the value of the enable checkbox without touching child joints/links
00149   void setJointCheckbox(QVariant val);
00150 
00151 
00152 protected:
00153   Robot* robot_;
00154   std::string name_;                          
00155   std::string parent_link_name_;
00156   std::string child_link_name_;
00157 
00158   // properties
00159   Property* joint_property_;
00160   Property* details_;
00161   VectorProperty* position_property_;
00162   QuaternionProperty* orientation_property_;
00163   Property* axes_property_;
00164 
00165 private:
00166   Ogre::Vector3 joint_origin_pos_;
00167   Ogre::Quaternion joint_origin_rot_;
00168   bool has_decendent_links_with_geometry_;
00169 
00170   bool doing_set_checkbox_;   // prevents updateChildVisibility() from  touching children
00171 
00172   Axes* axes_;
00173 };
00174 
00175 } // namespace rviz
00176 
00177 #endif // RVIZ_ROBOT_LINK_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:31