Grip-Reloaded
Grip version visualizaiton interface for DART (DynamicAnimationandRoboticsToolkits)
|
00001 /* 00002 * Copyright (c) 2014, Georgia Tech Research Corporation 00003 * All rights reserved. 00004 * 00005 * Author: Pete Vieira <pete.vieira@gatech.edu> 00006 * Date: Feb 2014 00007 * 00008 * Humanoid Robotics Lab Georgia Institute of Technology 00009 * Director: Mike Stilman http://www.golems.org 00010 * 00011 * 00012 * This file is provided under the following "BSD-style" License: 00013 * Redistribution and use in source and binary forms, with or 00014 * without modification, are permitted provided that the following 00015 * conditions are met: 00016 * 00017 * * Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * 00020 * * Redistributions in binary form must reproduce the above 00021 * copyright notice, this list of conditions and the following 00022 * disclaimer in the documentation and/or other materials provided 00023 * with the distribution. 00024 * 00025 * * Neither the name of the Humanoid Robotics Lab nor the names of 00026 * its contributors may be used to endorse or promote products 00027 * derived from this software without specific prior written 00028 * permission 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00031 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00032 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00033 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00034 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00035 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00036 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00037 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00038 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00039 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00041 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00042 * POSSIBILITY OF SUCH DAMAGE. 00043 */ 00044 00050 #ifndef SKELETONNODE_H 00051 #define SKELETONNODE_H 00052 00053 // Grip includes 00054 #include "../osgGolems/Axes.h" 00055 #include "BodyNodeVisuals.h" 00056 #include "SkeletonVisuals.h" 00057 00058 // Dart includes 00059 #include <dart/dynamics/Skeleton.h> 00060 #include <dart/dynamics/BodyNode.h> 00061 #include <dart/dynamics/Joint.h> 00062 00063 // OpenSceneGraph includes 00064 #include <osg/Geode> 00065 #include <osg/Matrix> 00066 #include <osg/MatrixTransform> 00067 #include <osg/CullFace> 00068 00069 namespace osgDart { 00070 00072 typedef std::map<const dart::dynamics::BodyNode*, osg::ref_ptr<osg::MatrixTransform> > BodyNodeMatrixMap; 00073 00075 typedef std::map<const dart::dynamics::BodyNode*, osg::ref_ptr<osg::Group> > BodyNodeGroupMap; 00076 00078 typedef std::map<const dart::dynamics::BodyNode*, osg::ref_ptr<osgDart::BodyNodeVisuals> > BodyNodeVisualsMap; 00079 00084 typedef enum { 00085 RENDER_VISUAL_MESH, 00086 RENDER_COLLISION_MESH, 00087 RENDER_WIREFRAME_ON, 00088 RENDER_WIREFRAME_OFF 00089 } renderMode_t; 00090 00095 class SkeletonNode : public osg::Group 00096 { 00097 public: 00098 00099 //--------------------------------------------------------------- 00100 // PUBLIC FUNCTIONS 00101 //--------------------------------------------------------------- 00102 00109 SkeletonNode(const dart::dynamics::Skeleton& skeleton, bool debug=false); 00110 00114 ~SkeletonNode(); 00115 00121 void update(); 00122 00130 void setJointAxesVisible(bool makeVisible=false); 00131 00139 void setBodyNodeAxesVisible(bool makeVisible=false); 00140 00147 void setBodyNodeCoMVisible(bool makeVisible=false); 00148 00154 void setSkeletonCoMVisible(bool makeVisible=false); 00155 00162 void setSkeletonCoMProjectedVisible(bool makeVisible=false); 00163 00169 void setSkeletonRenderMode(renderMode_t renderMode); 00170 00177 void setBodyNodeTransparency(const dart::dynamics::BodyNode& node, float transparencyValue); 00178 00183 const dart::dynamics::BodyNode& getRootBodyNode(); 00184 00185 protected: 00186 00187 //--------------------------------------------------------------- 00188 // PROTECTED FUNCTIONS 00189 //--------------------------------------------------------------- 00197 void _createSkeleton(); 00198 00204 void _addSkeletonVisuals(); 00205 00215 void _addSkeletonObjectsRecursivley(const dart::dynamics::BodyNode& bodyNode); 00216 00225 osg::Group* _makeBodyNodeGroup(const dart::dynamics::BodyNode& node); 00226 00235 osg::Group* _makeBodyNodeCollisionMeshGroup(const dart::dynamics::BodyNode& node); 00236 00244 osgDart::BodyNodeVisuals* _makeBodyNodeVisuals(const dart::dynamics::BodyNode& node); 00245 00251 void _addVisualizationShapesFromBodyNode(const dart::dynamics::BodyNode& node); 00252 00258 void _addCollisionShapesFromBodyNode(const dart::dynamics::BodyNode& node); 00259 00267 void _updateRecursively(const dart::dynamics::BodyNode& bodyNode); 00268 00273 void _updateSkeletonVisuals(); 00274 00275 //--------------------------------------------------------------- 00276 // PROTECTED VARIABLES 00277 //--------------------------------------------------------------- 00278 00280 const dart::dynamics::BodyNode& _rootBodyNode; 00281 00283 std::vector<osg::ref_ptr<osg::Group> > _bodyNodeGroups; 00284 00286 std::vector<osg::ref_ptr<osgDart::BodyNodeVisuals> > _bodyNodeVisuals; 00287 00289 osg::ref_ptr<osgDart::SkeletonVisuals> _skeletonVisuals; 00290 00292 std::vector<osg::ref_ptr<osg::Group> > _bodyNodeCollisionMeshGroups; 00293 00295 BodyNodeMatrixMap _bodyNodeMatrixMap; 00296 00298 BodyNodeGroupMap _bodyNodeGroupMap; 00299 00301 BodyNodeGroupMap _bodyNodeCollsionMeshGroupMap; 00302 00304 BodyNodeVisualsMap _bodyNodeVisualsMap; 00305 00307 const bool _debug; 00308 00309 }; // end class SkeletonNode 00310 00311 } // end osgDart namespace 00312 00313 #endif // SKELETONNODE_H