DART 6.12.2
Loading...
Searching...
No Matches
SupportPolygonVisual.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_GUI_OSG_SUPPORTPOLYGONVISUAL_HPP_
34#define DART_GUI_OSG_SUPPORTPOLYGONVISUAL_HPP_
35
36#include <osg/Geode>
37
41
42namespace dart {
43namespace gui {
44namespace osg {
45
49{
50public:
53 const dart::dynamics::SkeletonPtr& skeleton = nullptr,
54 double elevation = 0.02);
55
58 const dart::dynamics::SkeletonPtr& skeleton,
59 std::size_t treeIndex,
60 double elevation = 0.02);
61
63 void setSkeleton(const dart::dynamics::SkeletonPtr& skeleton);
64
67
70
72 void visualizeTree(std::size_t treeIndex);
73
75 void setDisplayElevation(double elevation);
76
78 double getDisplayElevation() const;
79
81 void displayPolygon(bool display);
82
84 bool isPolygonDisplayed() const;
85
87 void setPolygonColor(const Eigen::Vector4d& color);
88
90 Eigen::Vector4d getPolygonColor() const;
91
93 void displayCentroid(bool display);
94
96 bool isCentroidDisplayed() const;
97
99 void setCentroidRadius(double radius);
100
102 double getCentroidRadius() const;
103
105 void displayCenterOfMass(bool display);
106
108 bool isCenterOfMassDisplayed() const;
109
111 void setCenterOfMassRadius(double radius);
112
114 double getCenterOfMassRadius() const;
115
118 void setValidCOMColor(const Eigen::Vector4d& color);
119
122 const Eigen::Vector4d& getValidCOMColor() const;
123
126 void setInvalidCOMColor(const Eigen::Vector4d& color);
127
130 const Eigen::Vector4d& getInvalidCOMColor() const;
131
133 void refresh() override final;
134
135protected:
137 void initialize();
138
140 dart::dynamics::WeakSkeletonPtr mSkeleton;
141
144
147
150
153
155 dart::dynamics::SimpleFramePtr mCentroid;
156
159
162
164 dart::dynamics::SimpleFramePtr mCom;
165
168
171
174
176 ::osg::ref_ptr<::osg::Vec4Array> mPolygonColor;
177
179 ::osg::ref_ptr<::osg::Geode> mPolygonGeode;
180
182 ::osg::ref_ptr<::osg::Geometry> mPolygonGeom;
183
185 ::osg::ref_ptr<::osg::Vec3Array> mVertices;
186
188 ::osg::ref_ptr<::osg::DrawElementsUShort> mFaces;
189
192
194 ::osg::ref_ptr<ShapeFrameNode> mComNode;
195};
196
197} // namespace osg
198} // namespace gui
199} // namespace dart
200
201#endif // DART_GUI_OSG_SUPPORTPOLYGONVISUAL_HPP_
Definition ShapeFrameNode.hpp:61
Attach this to a Viewer in order to visualize the support polygon of a Skeleton.
Definition SupportPolygonVisual.hpp:49
void initialize()
Initialize the memory used by this visual.
Definition SupportPolygonVisual.cpp:346
dart::dynamics::SimpleFramePtr mCom
SimpleFrame for the center of mass.
Definition SupportPolygonVisual.hpp:164
::osg::ref_ptr<::osg::Vec4Array > mPolygonColor
Color for the polygon.
Definition SupportPolygonVisual.hpp:176
double mCentroidRadius
Radius to be used by the centroid.
Definition SupportPolygonVisual.hpp:158
const Eigen::Vector4d & getInvalidCOMColor() const
Get the color that will be used for the center of mass if its projection is NOT on the support polygo...
Definition SupportPolygonVisual.cpp:227
::osg::ref_ptr<::osg::Geometry > mPolygonGeom
Geometry to describe the polygon.
Definition SupportPolygonVisual.hpp:182
::osg::ref_ptr< ShapeFrameNode > mComNode
Node to render the COM.
Definition SupportPolygonVisual.hpp:194
bool mDisplayCOM
Whether to display the center of mass.
Definition SupportPolygonVisual.hpp:161
double mComRadius
Radius to be used by the center of mass.
Definition SupportPolygonVisual.hpp:167
bool mDisplayPolygon
Whether to display the polygon.
Definition SupportPolygonVisual.hpp:149
void setCentroidRadius(double radius)
Set the radius of the centroid visualization.
Definition SupportPolygonVisual.cpp:151
dart::dynamics::SimpleFramePtr mCentroid
SimpleFrame for the centroid.
Definition SupportPolygonVisual.hpp:155
void refresh() override final
Update the support polygon visual.
Definition SupportPolygonVisual.cpp:233
const Eigen::Vector4d & getValidCOMColor() const
Get the color that will be used for the center of mass if its projection is on the support polygon.
Definition SupportPolygonVisual.cpp:215
dart::dynamics::SkeletonPtr getSkeleton() const
Get the Skeleton associated with this visual.
Definition SupportPolygonVisual.cpp:73
void visualizeWholeSkeleton()
Visualize the entire Skeleton.
Definition SupportPolygonVisual.cpp:79
void displayCentroid(bool display)
Display the centroid.
Definition SupportPolygonVisual.cpp:131
double getCentroidRadius() const
Get the radius of the centroid visualization.
Definition SupportPolygonVisual.cpp:164
::osg::ref_ptr<::osg::DrawElementsUShort > mFaces
Faces of the polygon.
Definition SupportPolygonVisual.hpp:188
void visualizeTree(std::size_t treeIndex)
Visualize a specific tree in the Skeleton.
Definition SupportPolygonVisual.cpp:85
void setCenterOfMassRadius(double radius)
Set the radius of the center of mass visualization.
Definition SupportPolygonVisual.cpp:190
std::size_t mTreeIndex
Tree index for this visual.
Definition SupportPolygonVisual.hpp:143
Eigen::Vector4d mInvalidColor
Color to be used when COM is invalid.
Definition SupportPolygonVisual.hpp:173
void setPolygonColor(const Eigen::Vector4d &color)
Set the color of the support polygon.
Definition SupportPolygonVisual.cpp:117
void setSkeleton(const dart::dynamics::SkeletonPtr &skeleton)
Change the Skeleton that is being visualized.
Definition SupportPolygonVisual.cpp:66
bool mDisplayCentroid
Whether to display the centroid.
Definition SupportPolygonVisual.hpp:152
bool isCentroidDisplayed() const
Returns true if the centroid is being displayed.
Definition SupportPolygonVisual.cpp:145
void setDisplayElevation(double elevation)
Change the elevation height at which the polygon is displayed.
Definition SupportPolygonVisual.cpp:91
void displayCenterOfMass(bool display)
Display the center of mass.
Definition SupportPolygonVisual.cpp:170
double getDisplayElevation() const
Get the elevation of display for the support polygon.
Definition SupportPolygonVisual.cpp:97
void setInvalidCOMColor(const Eigen::Vector4d &color)
Set the color that will be used for the center of mass if its projection is NOT on the support polygo...
Definition SupportPolygonVisual.cpp:221
Eigen::Vector4d getPolygonColor() const
Get the color of the support polygon.
Definition SupportPolygonVisual.cpp:124
bool isPolygonDisplayed() const
Returns true if the support polygon is being displayed.
double getCenterOfMassRadius() const
Get the radius of the center of mass visualization.
Definition SupportPolygonVisual.cpp:203
::osg::ref_ptr<::osg::Vec3Array > mVertices
Vertices of the polygon.
Definition SupportPolygonVisual.hpp:185
dart::dynamics::WeakSkeletonPtr mSkeleton
Skeleton for this visual.
Definition SupportPolygonVisual.hpp:140
void setValidCOMColor(const Eigen::Vector4d &color)
Set the color that will be used for the center of mass if its projection is on the support polygon.
Definition SupportPolygonVisual.cpp:209
void displayPolygon(bool display)
Display the support polygon.
Definition SupportPolygonVisual.cpp:103
Eigen::Vector4d mValidColor
Color to be used when COM is valid.
Definition SupportPolygonVisual.hpp:170
bool isCenterOfMassDisplayed() const
Returns true if the center of mass is being displayed.
Definition SupportPolygonVisual.cpp:184
::osg::ref_ptr< ShapeFrameNode > mCentroidNode
Node to render the centroid.
Definition SupportPolygonVisual.hpp:191
double mElevation
Elevation that this visual should use.
Definition SupportPolygonVisual.hpp:146
::osg::ref_ptr<::osg::Geode > mPolygonGeode
Geode to hold the polygon.
Definition SupportPolygonVisual.hpp:179
Definition Viewer.hpp:76
Definition Random-impl.hpp:92
std::shared_ptr< Skeleton > SkeletonPtr
Definition SmartPointer.hpp:60
Definition BulletCollisionDetector.cpp:60
Definition SharedLibraryManager.hpp:46