opensurgsim
PoseInterpolator.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_BLOCKS_POSEINTERPOLATOR_H
17 #define SURGSIM_BLOCKS_POSEINTERPOLATOR_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/DataStructures/OptionalValue.h"
23 #include "SurgSim/Framework/Behavior.h"
25 
26 
27 namespace SurgSim
28 {
29 namespace Framework
30 {
31 class SceneElement;
32 }
33 }
34 
35 namespace SurgSim
36 {
37 namespace Blocks
38 {
39 
42 {
43 public:
44 
46  explicit PoseInterpolator(const std::string& name);
47 
51  void setStartingPose(const SurgSim::Math::RigidTransform3d& transform);
52 
55  void setEndingPose(const SurgSim::Math::RigidTransform3d& transform);
56 
62  void setTarget(std::shared_ptr<SurgSim::Framework::SceneElement> target);
63 
66  void setDuration(double t);
67 
70  double getDuration() const;
71 
74  void setLoop(bool val);
75 
77  bool isLoop() const;
78 
82  void setPingPong(bool val);
83 
85  bool isPingPong() const;
86 
87  void update(double dt) override;
88 
89 private:
90 
93 
95  SurgSim::Math::RigidTransform3d m_startingPose;
96 
99 
101  std::shared_ptr<SurgSim::Framework::SceneElement> m_target;
102 
104  double m_duration;
105 
107  double m_currentTime;
108 
110  bool m_pingpong;
111 
113  bool m_loop;
114 
115  bool doWakeUp() override;
116 
117  bool doInitialize() override;
118 
119  void doRetire() override;
120 };
121 
122 
123 }; // Blocks
124 }; // Surgsim
125 
126 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
Behaviors perform actions.
Definition: Behavior.h:40
Perform linear interpolation on two poses.
Definition: PoseInterpolator.h:41