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 skeletonics 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 00053 #ifndef DARTNODE_H 00054 #define DARTNODE_H 00055 00056 // DART includes 00057 #include <dart/dynamics/Skeleton.h> 00058 #include <dart/dynamics/Joint.h> 00059 #include <dart/dynamics/BodyNode.h> 00060 #include <dart/simulation/World.h> 00061 00062 // OpenSceneGraph includes 00063 #include <osg/Geode> 00064 #include <osg/Matrix> 00065 #include <osg/MatrixTransform> 00066 00067 // osgDart includes 00068 #include "SkeletonNode.h" 00069 #include "WorldVisuals.h" 00070 00076 namespace osgDart { 00077 00079 typedef std::map<const dart::dynamics::Skeleton*, osg::ref_ptr<SkeletonNode> > SkeletonNodeMap; 00080 00081 00089 class DartNode : public osg::Group 00090 { 00091 public: 00092 00093 //--------------------------------------------------------------- 00094 // PUBLIC FUNCTIONS 00095 //--------------------------------------------------------------- 00096 00100 DartNode(bool debug=false); 00101 00106 void _updateContactForces(); 00107 00113 void setContactForcesVisible(bool makeVisible); 00114 00121 dart::dynamics::Skeleton* parseSkeletonUrdf(std::string urdfFile); 00122 00129 dart::simulation::World* parseWorldSdf(std::string sdfFile); 00130 00137 dart::simulation::World* parseWorldUrdf(std::string urdfFile); 00138 00145 int addWorldFromUrdf(std::string urdfFile); 00146 00153 size_t addWorldFromSdf(std::string sdfFile); 00154 00160 size_t addWorld(std::string file); 00161 00168 size_t addSkeleton(std::string urdfFile); 00169 00175 size_t addSkeleton(dart::dynamics::Skeleton &skeleton); 00176 00185 size_t addWorld(dart::simulation::World* world); 00186 00192 dart::dynamics::Skeleton* getSkeleton(size_t skeletonIndex=0); 00193 00200 int removeSkeleton(const dart::dynamics::Skeleton* skeletonToRemove); 00201 00208 int removeSkeleton(size_t skeletonIndex=0); 00209 00215 void reset(); 00216 00221 dart::simulation::World* getWorld(); 00222 00227 size_t getNumSkeletons(); 00228 00234 void printInfo(); 00235 00241 void update(); 00242 00250 void setSkeletonTransparency(const dart::dynamics::Skeleton& skel, float transparencyValue); 00251 00259 void setBodyNodeTransparency(const dart::dynamics::BodyNode& node, float transparencyValue); 00260 00268 void setJointAxesVisible(bool makeVisible=false); 00269 00277 void setBodyNodeAxesVisible(bool makeVisible=false); 00278 00284 void setSkeletonCoMVisible(bool makeVisible=false); 00285 00292 void setSkeletonCoMProjectedVisible(bool makeVisible=false); 00293 00299 void setSkeletonCollisionMeshOn(bool enable=true); 00300 00306 void setSkeletonWireFrameOn(bool enable=true); 00307 00313 void hideSkeleton(int i); 00314 00315 protected: 00316 00317 //--------------------------------------------------------------- 00318 // PROTECTED FUNCTIONS 00319 //--------------------------------------------------------------- 00320 00327 int skeletonIndexIsValid(size_t skeletonIndex); 00328 00329 00330 //--------------------------------------------------------------- 00331 // PROTECTED VARIABLES 00332 //--------------------------------------------------------------- 00333 00335 dart::simulation::World* _world; 00336 00338 std::vector<dart::dynamics::Skeleton*> _skeletons; 00339 00341 std::vector<osg::ref_ptr<SkeletonNode> > _skeletonNodes; 00342 00344 SkeletonNodeMap _skelNodeMap; 00345 00347 std::vector<osg::ref_ptr<osgDart::ContactForceVisual> > _contactForceArrows; 00348 00350 const bool _debug; 00352 bool _showContactForces; 00353 00354 }; // end class DartNode 00355 00356 } // end namespace osgDart 00357 00358 #endif // DARTNODE_H