RigidRepresentation.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_RIGIDREPRESENTATION_H
17 #define SURGSIM_PHYSICS_RIGIDREPRESENTATION_H
18 
21 #include "SurgSim/Math/Vector.h"
22 #include "SurgSim/Math/Matrix.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace Physics
29 {
30 class RigidRepresentationState;
31 class Localization;
32 
33 SURGSIM_STATIC_REGISTRATION(RigidRepresentation);
34 
40 {
41 public:
44  explicit RigidRepresentation(const std::string& name);
45 
47  virtual ~RigidRepresentation();
48 
50 
51  virtual RepresentationType getType() const override;
52 
55  void setLinearVelocity(const SurgSim::Math::Vector3d& linearVelocity);
56 
59  void setAngularVelocity(const SurgSim::Math::Vector3d& angularVelocity);
60 
68  void addExternalGeneralizedForce(const SurgSim::Math::Vector6d& generalizedForce,
69  const SurgSim::Math::Matrix66d& K = SurgSim::Math::Matrix66d::Zero(),
70  const SurgSim::Math::Matrix66d& D = SurgSim::Math::Matrix66d::Zero());
71 
81  const SurgSim::Math::Vector6d& generalizedForce,
82  const SurgSim::Math::Matrix66d& K = SurgSim::Math::Matrix66d::Zero(),
83  const SurgSim::Math::Matrix66d& D = SurgSim::Math::Matrix66d::Zero());
84 
87 
90 
93 
94  virtual void beforeUpdate(double dt) override;
95 
96  virtual void update(double dt) override;
97 
98  virtual void afterUpdate(double dt) override;
99 
100  void applyCorrection(double dt, const Eigen::VectorBlock<SurgSim::Math::Vector>& deltaVelocity) override;
101 
105 
106 protected:
111 
116 
119 
123 
124 private:
125  virtual bool doInitialize() override;
126 
129  void computeComplianceMatrix(double dt);
130 
133  virtual void updateGlobalInertiaMatrices(const RigidRepresentationState& state) override;
134 };
135 
136 }; // Physics
137 }; // SurgSim
138 
139 #endif // SURGSIM_PHYSICS_RIGIDREPRESENTATION_H
const SurgSim::Math::Matrix66d & getComplianceMatrix() const
Retrieve the rigid body 6x6 compliance matrix.
Definition: RigidRepresentation.cpp:396
Definition: DriveElementFromInputBehavior.cpp:27
RepresentationType
Definition: Representation.h:42
virtual ~RigidRepresentation()
Destructor.
Definition: RigidRepresentation.cpp:53
Eigen::Matrix< double, 6, 6, Eigen::RowMajor > Matrix66d
A 6x6 matrix of doubles.
Definition: Matrix.h:59
RigidRepresentation(const std::string &name)
Constructor.
Definition: RigidRepresentation.cpp:37
virtual void updateGlobalInertiaMatrices(const RigidRepresentationState &state) override
Update global inertia matrices (internal data structure)
Definition: RigidRepresentation.cpp:427
SurgSim::Math::Matrix33d m_globalInertia
Inertia matrices in global coordinates.
Definition: RigidRepresentation.h:108
Definition: Location.h:31
The RigidRepresentation class defines the dynamic rigid body representation Note that the rigid repre...
Definition: RigidRepresentation.h:39
SurgSim::Math::Matrix66d m_externalGeneralizedStiffness
Definition: RigidRepresentation.h:121
Eigen::Matrix< double, 6, 1 > Vector6d
A 6D matrix of doubles.
Definition: Vector.h:64
The RigidRepresentationBase class defines the base class for all rigid motion based representations (...
Definition: RigidRepresentationBase.h:38
void setAngularVelocity(const SurgSim::Math::Vector3d &angularVelocity)
Set the current angular velocity of the rigid representation.
Definition: RigidRepresentation.cpp:459
const SurgSim::Math::Matrix66d & getExternalGeneralizedStiffness() const
Definition: RigidRepresentation.cpp:187
SurgSim::Math::Vector3d m_force
Current force applied on the rigid representation (in N)
Definition: RigidRepresentation.h:113
SurgSim::Math::Matrix66d m_C
Compliance matrix (size of the number of Dof = 6)
Definition: RigidRepresentation.h:118
SurgSim::Math::Vector6d m_externalGeneralizedForce
Definition: RigidRepresentation.h:120
void setLinearVelocity(const SurgSim::Math::Vector3d &linearVelocity)
Set the current linear velocity of the rigid representation.
Definition: RigidRepresentation.cpp:454
Definitions of small fixed-size square matrix types.
SURGSIM_CLASSNAME(SurgSim::Physics::RigidRepresentation)
SurgSim::Math::Matrix33d m_invGlobalInertia
Inverse of inertia matrix in global coordinates.
Definition: RigidRepresentation.h:110
Definitions of small fixed-size vector types.
void addExternalGeneralizedForce(const SurgSim::Math::Vector6d &generalizedForce, const SurgSim::Math::Matrix66d &K=SurgSim::Math::Matrix66d::Zero(), const SurgSim::Math::Matrix66d &D=SurgSim::Math::Matrix66d::Zero())
Add an external generalized force applied to the rigid representation's mass center.
Definition: RigidRepresentation.cpp:62
SurgSim::Math::Matrix66d m_externalGeneralizedDamping
Definition: RigidRepresentation.h:122
virtual void afterUpdate(double dt) override
Postprocessing done after the update call This needs to be called from the outside usually from a Com...
Definition: RigidRepresentation.cpp:312
virtual void beforeUpdate(double dt) override
Preprocessing done before the update call This needs to be called from the outside usually from a Com...
Definition: RigidRepresentation.cpp:197
SurgSim::Math::Vector3d m_torque
Current torque applied on the rigid representation (in N.m)
Definition: RigidRepresentation.h:115
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
void applyCorrection(double dt, const Eigen::VectorBlock< SurgSim::Math::Vector > &deltaVelocity) override
Update the Representation's current position and velocity using a time interval, dt, and change in velocity, deltaVelocity.
Definition: RigidRepresentation.cpp:330
const SurgSim::Math::Matrix66d & getExternalGeneralizedDamping() const
Definition: RigidRepresentation.cpp:192
virtual bool doInitialize() override
Interface to be implemented by derived classes.
Definition: RigidRepresentation.cpp:442
void computeComplianceMatrix(double dt)
Compute compliance matrix (internal data structure)
Definition: RigidRepresentation.cpp:401
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
The RigidRepresentationState class describes a state (position and velocity information).
Definition: RigidRepresentationState.h:31
const SurgSim::Math::Vector6d & getExternalGeneralizedForce() const
Definition: RigidRepresentation.cpp:182
virtual RepresentationType getType() const override
Query the representation type.
Definition: RigidRepresentation.cpp:57
virtual void update(double dt) override
Update the representation state to the current time step.
Definition: RigidRepresentation.cpp:211
SURGSIM_STATIC_REGISTRATION(DeformableCollisionRepresentation)