DART  6.10.1
RealTimeWorldNode.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_REALTIMEWORLDNODE_HPP_
34 #define DART_GUI_OSG_REALTIMEWORLDNODE_HPP_
35 
36 #include <osg/Timer>
37 
39 
40 namespace dart {
41 namespace gui {
42 namespace osg {
43 
45 {
46 public:
68  const std::shared_ptr<dart::simulation::World>& world = nullptr,
69  const ::osg::ref_ptr<osgShadow::ShadowTechnique>& shadower = nullptr,
70  double targetFrequency = 60.0,
71  double targetRealTimeFactor = 1.0);
72 
74  void setTargetFrequency(double targetFrequency);
75 
77  double getTargetFrequency() const;
78 
80  void setTargetRealTimeFactor(double targetRTF);
81 
83  double getTargetRealTimeFactor() const;
84 
88  double getLastRealTimeFactor() const;
89 
91  double getLowestRealTimeFactor() const;
92 
94  double getHighestRealTimeFactor() const;
95 
96  // Documentation inherited
97  void refresh() override;
98 
99 protected:
102 
104  ::osg::Timer mRefreshTimer;
105 
108 
111 
114 
117 
120 };
121 
122 } // namespace osg
123 } // namespace gui
124 } // namespace dart
125 
126 #endif // DART_GUI_OSG_REALTIMEWORLDNODE_HPP_
Definition: RealTimeWorldNode.hpp:45
double mTargetSimTimeLapse
The target for how much simulation time should elapse between refreshes.
Definition: RealTimeWorldNode.hpp:110
double getLastRealTimeFactor() const
Get the real time factor that was achieved in the last refresh cycle.
Definition: RealTimeWorldNode.cpp:85
double getLowestRealTimeFactor() const
Get the lowest real time factor that has been hit during the simulation.
Definition: RealTimeWorldNode.cpp:91
void setTargetRealTimeFactor(double targetRTF)
Set the target real time factor.
Definition: RealTimeWorldNode.cpp:73
RealTimeWorldNode(const std::shared_ptr< dart::simulation::World > &world=nullptr, const ::osg::ref_ptr< osgShadow::ShadowTechnique > &shadower=nullptr, double targetFrequency=60.0, double targetRealTimeFactor=1.0)
Construct a world node that will attempt to run a simulation with close to real-time playback.
Definition: RealTimeWorldNode.cpp:42
double mLastRealTimeFactor
The RTF that was achieved in the last refresh cycle.
Definition: RealTimeWorldNode.hpp:113
double getHighestRealTimeFactor() const
Get the highest real time factor that has been hit during the simulation.
Definition: RealTimeWorldNode.cpp:97
double getTargetRealTimeFactor() const
Get the target real time factor.
Definition: RealTimeWorldNode.cpp:79
double mTargetRealTimeLapse
The target for how much time should elapse between refreshes.
Definition: RealTimeWorldNode.hpp:107
double mLowestRealTimeFactor
The lowest RTF that has been achieved.
Definition: RealTimeWorldNode.hpp:116
double getTargetFrequency() const
Get the target refresh rate frequency.
Definition: RealTimeWorldNode.cpp:67
void setTargetFrequency(double targetFrequency)
Set the target refresh rate frequency.
Definition: RealTimeWorldNode.cpp:59
bool mFirstRefresh
Reset each time the simulation is paused.
Definition: RealTimeWorldNode.hpp:101
void refresh() override
This function is called at the beginning of each rendering cycle.
Definition: RealTimeWorldNode.cpp:103
::osg::Timer mRefreshTimer
Keeps track of the time between refreshes.
Definition: RealTimeWorldNode.hpp:104
double mHighestRealTimeFactor
The highest RTF that has been achieved.
Definition: RealTimeWorldNode.hpp:119
WorldNode class encapsulates a World to be displayed in OpenSceneGraph.
Definition: WorldNode.hpp:65
Definition: BulletCollisionDetector.cpp:65