PoseInterpolator.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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>
24 
25 namespace SurgSim
26 {
27 namespace Framework
28 {
29  class SceneElement;
30 }
31 }
32 
33 namespace SurgSim
34 {
35 namespace Blocks
36 {
37 
40 {
41 public:
42 
44  explicit PoseInterpolator(const std::string& name);
45 
49  void setStartingPose(const SurgSim::Math::RigidTransform3d& transform);
50 
53  void setEndingPose(const SurgSim::Math::RigidTransform3d& transform);
54 
60  void setTarget(std::shared_ptr<SurgSim::Framework::SceneElement> target);
61 
64  void setDuration(double t);
65 
68  double getDuration() const;
69 
72  void setLoop(bool val);
73 
75  bool isLoop() const;
76 
80  void setPingPong(bool val);
81 
83  bool isPingPong() const;
84 
86  virtual void update(double dt) override;
87 
88 private:
89 
92 
95 
98 
100  std::shared_ptr<SurgSim::Framework::SceneElement> m_target;
101 
103  double m_duration;
104 
107 
110 
112  bool m_loop;
113 
115  virtual bool doWakeUp() override;
116 
118  virtual bool doInitialize() override;
119 };
120 
121 
122 }; // Blocks
123 }; // Surgsim
124 
125 #endif
Definition: DriveElementFromInputBehavior.cpp:27
bool m_loop
Whether to loop.
Definition: PoseInterpolator.h:112
SurgSim::DataStructures::OptionalValue< SurgSim::Math::RigidTransform3d > m_optionalStartPose
Optional value to take the from rigid transform.
Definition: PoseInterpolator.h:91
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
SurgSim::Math::RigidTransform3d m_startingPose
Target of the interpolation.
Definition: PoseInterpolator.h:94
bool m_pingpong
Whether to pingpong.
Definition: PoseInterpolator.h:109
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
std::shared_ptr< SurgSim::Framework::SceneElement > m_target
Target for the interpolated RigidTransform.
Definition: PoseInterpolator.h:100
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Math::RigidTransform3d m_endingPose
Start of the interpolation.
Definition: PoseInterpolator.h:97
Behaviors perform actions.
Definition: Behavior.h:40
Perform linear interpolation on two poses.
Definition: PoseInterpolator.h:39
double m_duration
Duration of the interpolation.
Definition: PoseInterpolator.h:103
double m_currentTime
How far through the interpolation we are.
Definition: PoseInterpolator.h:106