PoseInterpolator.h
Go to the documentation of this file.
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 
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 
96 
99 
101  std::shared_ptr<SurgSim::Framework::SceneElement> m_target;
102 
104  double m_duration;
105 
108 
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
SurgSim::Blocks::PoseInterpolator::m_currentTime
double m_currentTime
How far through the interpolation we are.
Definition: PoseInterpolator.h:107
SurgSim::Blocks::PoseInterpolator::m_target
std::shared_ptr< SurgSim::Framework::SceneElement > m_target
Target for the interpolated RigidTransform.
Definition: PoseInterpolator.h:101
SurgSim::Blocks::PoseInterpolator::m_optionalStartPose
SurgSim::DataStructures::OptionalValue< SurgSim::Math::RigidTransform3d > m_optionalStartPose
Optional value to take the from rigid transform.
Definition: PoseInterpolator.h:92
SurgSim::Blocks::PoseInterpolator::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: PoseInterpolator.cpp:75
SurgSim::Blocks::PoseInterpolator::setTarget
void setTarget(std::shared_ptr< SurgSim::Framework::SceneElement > target)
Set the target of the interpolation, this is where the interpolated transform will be applied to.
Definition: PoseInterpolator.cpp:54
SurgSim::Blocks::PoseInterpolator::m_endingPose
SurgSim::Math::RigidTransform3d m_endingPose
Start of the interpolation.
Definition: PoseInterpolator.h:98
SurgSim::DataStructures::OptionalValue< SurgSim::Math::RigidTransform3d >
SurgSim::Blocks::PoseInterpolator::update
void update(double dt) override
Update the behavior.
Definition: PoseInterpolator.cpp:100
SurgSim::Blocks::PoseInterpolator::m_duration
double m_duration
Duration of the interpolation.
Definition: PoseInterpolator.h:104
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:41
SurgSim::Blocks::PoseInterpolator::setPingPong
void setPingPong(bool val)
Sets the interpolation to ping pong back and forth between the starting and ending poses.
Definition: PoseInterpolator.cpp:143
OptionalValue.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Blocks::PoseInterpolator::m_loop
bool m_loop
Whether to loop.
Definition: PoseInterpolator.h:113
SurgSim::Blocks::PoseInterpolator::PoseInterpolator
PoseInterpolator(const std::string &name)
Constructor.
Definition: PoseInterpolator.cpp:28
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
SurgSim::Blocks::PoseInterpolator::m_startingPose
SurgSim::Math::RigidTransform3d m_startingPose
Target of the interpolation.
Definition: PoseInterpolator.h:95
SurgSim::Blocks::PoseInterpolator::isPingPong
bool isPingPong() const
Definition: PoseInterpolator.cpp:152
SurgSim::Blocks::PoseInterpolator::isLoop
bool isLoop() const
Definition: PoseInterpolator.cpp:138
SurgSim::Blocks::PoseInterpolator::doRetire
void doRetire() override
Interface to be implemented by derived classes Has a default implementation, does nothing.
Definition: PoseInterpolator.cpp:80
SurgSim::Blocks::PoseInterpolator::setLoop
void setLoop(bool val)
Sets the interpolation to looping, pingpong and loop cannot be used together.
Definition: PoseInterpolator.cpp:129
SurgSim::Blocks::PoseInterpolator
Perform linear interpolation on two poses.
Definition: PoseInterpolator.h:42
SurgSim::Blocks::PoseInterpolator::setStartingPose
void setStartingPose(const SurgSim::Math::RigidTransform3d &transform)
Set the starting pose.
Definition: PoseInterpolator.cpp:38
SurgSim::Blocks::PoseInterpolator::m_pingpong
bool m_pingpong
Whether to pingpong.
Definition: PoseInterpolator.h:110
SurgSim::Blocks::PoseInterpolator::setEndingPose
void setEndingPose(const SurgSim::Math::RigidTransform3d &transform)
Set the end pose.
Definition: PoseInterpolator.cpp:46
SurgSim::Blocks::PoseInterpolator::getDuration
double getDuration() const
Get the duration.
Definition: PoseInterpolator.cpp:70
SurgSim::Blocks::PoseInterpolator::setDuration
void setDuration(double t)
Set the duration of the interpolation.
Definition: PoseInterpolator.cpp:62
SurgSim::Blocks::PoseInterpolator::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: PoseInterpolator.cpp:85
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
Behavior.h