All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Representation.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_PHYSICS_REPRESENTATION_H
17 #define SURGSIM_PHYSICS_REPRESENTATION_H
18 
19 #include <string>
20 
22 #include "SurgSim/Math/Vector.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace DataStructures
28 {
29 struct Location;
30 }
31 
32 namespace Collision
33 {
34 class Representation;
35 }
36 
37 namespace Physics
38 {
39 
40 class Localization;
41 
43 {
53 };
54 
57 {
58 public:
61  explicit Representation(const std::string& name);
62 
64  virtual ~Representation();
65 
68  virtual RepresentationType getType() const = 0;
69 
71  virtual void resetState();
72 
74  virtual void resetParameters();
75 
78  size_t getNumDof() const;
79 
83 
86  bool isGravityEnabled() const;
87 
92 
97 
101  virtual void beforeUpdate(double dt);
102 
105  virtual void update(double dt);
106 
110  virtual void afterUpdate(double dt);
111 
115  virtual std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location& location);
116 
124  virtual void applyCorrection(double dt, const Eigen::VectorBlock<SurgSim::Math::Vector>& deltaVelocity);
125 
127  std::shared_ptr<SurgSim::Collision::Representation> getCollisionRepresentation() const;
128 
132  virtual void setCollisionRepresentation(std::shared_ptr<SurgSim::Collision::Representation> representation);
133 
134 protected:
139  void setNumDof(size_t numDof);
140 
143  const SurgSim::Math::Vector3d& getGravity() const;
144 
146  std::shared_ptr<SurgSim::Collision::Representation> m_collisionRepresentation;
147 
152 
153 private:
156 
159 
162 
164  size_t m_numDof;
165 
168 
171 
172 };
173 
174 }; // namespace Physics
175 
176 }; // namespace SurgSim
177 
178 #endif // SURGSIM_PHYSICS_REPRESENTATION_H
Definition: Representation.h:46
Representation(const std::string &name)
Constructor.
Definition: Representation.cpp:28
RepresentationType
Definition: Representation.h:42
bool m_isGravityEnabled
Gravity enabled flag.
Definition: Representation.h:167
std::shared_ptr< SurgSim::Collision::Representation > m_collisionRepresentation
This entity's collision representation, these are usually very specific to the physics representation...
Definition: Representation.h:146
Definition: Representation.h:45
The Representation class defines the base class for all physics objects.
Definition: Representation.h:56
Definition: Location.h:31
size_t m_numDof
Number of degrees of freedom for this representation.
Definition: Representation.h:164
void driveSceneElementPose(const SurgSim::Math::RigidTransform3d &pose)
This conditionally updates that pose for the scenelement to the given pose The update gets exectuded ...
Definition: Representation.cpp:120
bool isGravityEnabled() const
Get the gravity enable flag.
Definition: Representation.cpp:64
virtual ~Representation()
Destructor.
Definition: Representation.cpp:42
virtual void resetParameters()
Reset the representation parameters to their initial/default values.
Definition: Representation.cpp:50
size_t getNumDof() const
Query the object number of degrees of freedom.
Definition: Representation.cpp:54
Definition: Representation.h:51
Definition: Representation.h:49
const SurgSim::Math::Vector3d & getGravity() const
Get the gravity used by this Representation.
Definition: Representation.cpp:105
virtual std::shared_ptr< Localization > createLocalization(const SurgSim::DataStructures::Location &location)
Computes a localized coordinate w.r.t this representation, given a Location object.
Definition: Representation.cpp:91
void setNumDof(size_t numDof)
Set the number of degrees of freedom.
Definition: Representation.cpp:100
virtual void afterUpdate(double dt)
Postprocessing done after the update call This needs to be called from the outside usually from a Com...
Definition: Representation.cpp:87
bool m_isDrivingSceneElementPose
Is this representation driving the sceneElement pose.
Definition: Representation.h:170
virtual void resetState()
Reset the representation to its initial/default state.
Definition: Representation.cpp:46
void setIsGravityEnabled(bool isGravityEnabled)
Set the gravity enable flag.
Definition: Representation.cpp:59
virtual void setCollisionRepresentation(std::shared_ptr< SurgSim::Collision::Representation > representation)
Set the collision representation for this physics representation, when the collision object is involv...
Definition: Representation.cpp:115
std::shared_ptr< SurgSim::Collision::Representation > getCollisionRepresentation() const
Definition: Representation.cpp:110
Definition: Representation.h:44
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
virtual void beforeUpdate(double dt)
Preprocessing done before the update call This needs to be called from the outside usually from a Com...
Definition: Representation.cpp:79
Definitions of small fixed-size vector types.
Representation & operator=(const Representation &)
NO assignment operator.
const SurgSim::Math::Vector3d m_gravity
Gravity vector.
Definition: Representation.h:161
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
virtual RepresentationType getType() const =0
Query the representation type.
Definition: Representation.h:52
virtual void update(double dt)
Update the representation state to the current time step.
Definition: Representation.cpp:83
Definition: Representation.h:50
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
void setIsDrivingSceneElementPose(bool isDrivingSceneElementPose)
Set whether this Representation is controlling the pose of the SceneElement that it is part of...
Definition: Representation.cpp:69
bool isDrivingSceneElementPose()
Query if this Representation is controlling the pose of the SceneElement that it is part of...
Definition: Representation.cpp:74
virtual void applyCorrection(double dt, const Eigen::VectorBlock< SurgSim::Math::Vector > &deltaVelocity)
Update the Representation's current position and velocity using a time interval, dt, and change in velocity, deltaVelocity.
Definition: Representation.cpp:96