RigidRepresentation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_RIGIDREPRESENTATION_H
#define SURGSIM_PHYSICS_RIGIDREPRESENTATION_H
#include "SurgSim/DataStructures/BufferedValue.h"
#include "SurgSim/Framework/Macros.h"
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Math/Vector.h"
#include "SurgSim/Math/Matrix.h"
#include "SurgSim/Physics/RigidRepresentationBase.h"
namespace SurgSim
{
namespace Physics
{
class RigidState;
class Localization;
typedef RigidLocalization RigidLocalization;
SURGSIM_STATIC_REGISTRATION(RigidRepresentation);
class RigidRepresentation : public RigidRepresentationBase
{
public:
explicit RigidRepresentation(const std::string& name);
virtual ~RigidRepresentation();
SURGSIM_CLASSNAME(SurgSim::Physics::RigidRepresentation);
void setLinearVelocity(const SurgSim::Math::Vector3d& linearVelocity);
void setAngularVelocity(const SurgSim::Math::Vector3d& angularVelocity);
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());
void addExternalGeneralizedForce(const SurgSim::DataStructures::Location& location,
const SurgSim::Math::Vector6d& generalizedForce,
const SurgSim::Math::Matrix66d& K = SurgSim::Math::Matrix66d::Zero(),
const SurgSim::Math::Matrix66d& D = SurgSim::Math::Matrix66d::Zero());
SurgSim::DataStructures::BufferedValue<SurgSim::Math::Vector6d>& getExternalGeneralizedForce();
const SurgSim::Math::Matrix66d& getExternalGeneralizedStiffness() const;
const SurgSim::Math::Matrix66d& getExternalGeneralizedDamping() const;
void beforeUpdate(double dt) override;
void update(double dt) override;
void afterUpdate(double dt) override;
void applyCorrection(double dt, const Eigen::VectorBlock<SurgSim::Math::Vector>& deltaVelocity) override;
const SurgSim::Math::Matrix66d& getComplianceMatrix() const;
protected:
SurgSim::Math::Matrix33d m_globalInertia;
SurgSim::Math::Matrix33d m_invGlobalInertia;
SurgSim::Math::Vector3d m_force;
SurgSim::Math::Vector3d m_torque;
SurgSim::Math::Matrix66d m_C;
bool m_hasExternalGeneralizedForce;
SurgSim::DataStructures::BufferedValue<SurgSim::Math::Vector6d> m_externalGeneralizedForce;
SurgSim::Math::Matrix66d m_externalGeneralizedStiffness;
SurgSim::Math::Matrix66d m_externalGeneralizedDamping;
private:
bool doInitialize() override;
void computeComplianceMatrix(double dt);
void updateGlobalInertiaMatrices(const RigidState& state) override;
};
}; // Physics
}; // SurgSim
#endif // SURGSIM_PHYSICS_RIGIDREPRESENTATION_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::RigidRepresentation::~RigidRepresentation
virtual ~RigidRepresentation()
Destructor.
Definition: RigidRepresentation.cpp:53
SurgSim::Math::Matrix66d
Eigen::Matrix< double, 6, 6, Eigen::RowMajor > Matrix66d
A 6x6 matrix of doubles.
Definition: Matrix.h:59
SurgSim::Physics::RigidRepresentation::RigidRepresentation
RigidRepresentation(const std::string &name)
Constructor.
Definition: RigidRepresentation.cpp:36
BufferedValue.h
SurgSim::Physics::RigidRepresentation::getExternalGeneralizedDamping
const SurgSim::Math::Matrix66d & getExternalGeneralizedDamping() const
Definition: RigidRepresentation.cpp:191
SurgSim::Physics::RigidRepresentation::m_globalInertia
SurgSim::Math::Matrix33d m_globalInertia
Inertia matrices in global coordinates.
Definition: RigidRepresentation.h:109
SurgSim::DataStructures::Location
A Location defines a local position w.r.t.
Definition: Location.h:39
SurgSim::Physics::RigidRepresentation::getExternalGeneralizedForce
SurgSim::DataStructures::BufferedValue< SurgSim::Math::Vector6d > & getExternalGeneralizedForce()
Definition: RigidRepresentation.cpp:181
SurgSim::DataStructures::BufferedValue< SurgSim::Math::Vector6d >
ObjectFactory.h
SurgSim::Physics::RigidLocalization
RigidLocalization RigidLocalization
Definition: RigidRepresentation.h:32
SurgSim::Physics::RigidRepresentation
The RigidRepresentation class defines the dynamic rigid body representation Note that the rigid repre...
Definition: RigidRepresentation.h:42
RigidRepresentationBase.h
SurgSim::Physics::RigidRepresentation::m_hasExternalGeneralizedForce
bool m_hasExternalGeneralizedForce
External generalized force, stiffness and damping applied on the rigid representation.
Definition: RigidRepresentation.h:123
SurgSim::Physics::RigidRepresentation::m_externalGeneralizedStiffness
SurgSim::Math::Matrix66d m_externalGeneralizedStiffness
External generalized force, stiffness and damping applied on the rigid representation.
Definition: RigidRepresentation.h:125
SurgSim::Math::Vector6d
Eigen::Matrix< double, 6, 1 > Vector6d
A 6D matrix of doubles.
Definition: Vector.h:65
SurgSim::Physics::RigidRepresentationBase
The RigidRepresentationBase class defines the base class for all rigid motion based representations (...
Definition: RigidRepresentationBase.h:38
SurgSim::Physics::RigidRepresentation::setAngularVelocity
void setAngularVelocity(const SurgSim::Math::Vector3d &angularVelocity)
Set the current angular velocity of the rigid representation.
Definition: RigidRepresentation.cpp:470
SurgSim::Physics::RigidState
The RigidState class describes a state (position and velocity information).
Definition: RigidState.h:31
SurgSim::Physics::RigidRepresentation::m_force
SurgSim::Math::Vector3d m_force
Current force applied on the rigid representation (in N)
Definition: RigidRepresentation.h:114
SurgSim::Physics::RigidRepresentation::m_C
SurgSim::Math::Matrix66d m_C
Compliance matrix (size of the number of Dof = 6)
Definition: RigidRepresentation.h:119
SurgSim::Physics::RigidRepresentation::setLinearVelocity
void setLinearVelocity(const SurgSim::Math::Vector3d &linearVelocity)
Set the current linear velocity of the rigid representation.
Definition: RigidRepresentation.cpp:465
SurgSim::Physics::RigidLocalization
This class implements the localization on a RigidRepresentationBase, as a local position.
Definition: RigidLocalization.h:31
Macros.h
Matrix.h
Definitions of small fixed-size square matrix types.
SurgSim::Physics::RigidRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Physics::RigidRepresentation)
SurgSim::Physics::RigidRepresentation::m_invGlobalInertia
SurgSim::Math::Matrix33d m_invGlobalInertia
Inverse of inertia matrix in global coordinates.
Definition: RigidRepresentation.h:111
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Physics::RigidRepresentation::addExternalGeneralizedForce
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&#39;s mass center.
Definition: RigidRepresentation.cpp:57
SurgSim::Physics::RigidRepresentation::m_externalGeneralizedForce
SurgSim::DataStructures::BufferedValue< SurgSim::Math::Vector6d > m_externalGeneralizedForce
External generalized force, stiffness and damping applied on the rigid representation.
Definition: RigidRepresentation.h:124
SurgSim::Physics::RigidRepresentation::m_externalGeneralizedDamping
SurgSim::Math::Matrix66d m_externalGeneralizedDamping
External generalized force, stiffness and damping applied on the rigid representation.
Definition: RigidRepresentation.h:126
SurgSim::Physics::RigidRepresentation::afterUpdate
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:314
SurgSim::Physics::RigidRepresentation::updateGlobalInertiaMatrices
void updateGlobalInertiaMatrices(const RigidState &state) override
Update global inertia matrices (internal data structure)
Definition: RigidRepresentation.cpp:438
SurgSim::Physics::RigidRepresentation::beforeUpdate
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:196
SurgSim::Physics::RigidRepresentation::m_torque
SurgSim::Math::Vector3d m_torque
Current torque applied on the rigid representation (in N.m)
Definition: RigidRepresentation.h:116
SurgSim::Math::Matrix33d
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
SurgSim::Physics::RigidRepresentation::applyCorrection
void applyCorrection(double dt, const Eigen::VectorBlock< SurgSim::Math::Vector > &deltaVelocity) override
Update the Representation&#39;s current position and velocity using a time interval, dt, and change in velocity, deltaVelocity.
Definition: RigidRepresentation.cpp:338
SurgSim::Physics::RigidRepresentation::getComplianceMatrix
const SurgSim::Math::Matrix66d & getComplianceMatrix() const
Retrieve the rigid body 6x6 compliance matrix.
Definition: RigidRepresentation.cpp:404
SurgSim::Physics::RigidRepresentation::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: RigidRepresentation.cpp:453
SurgSim::Physics::RigidRepresentation::computeComplianceMatrix
void computeComplianceMatrix(double dt)
Compute compliance matrix (internal data structure)
Definition: RigidRepresentation.cpp:409
SurgSim::Physics::RigidRepresentation::getExternalGeneralizedStiffness
const SurgSim::Math::Matrix66d & getExternalGeneralizedStiffness() const
Definition: RigidRepresentation.cpp:186
SurgSim::Physics::Localization
This class localize a point on a representation (representation specific)
Definition: Localization.h:39
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Physics::RigidRepresentation::update
void update(double dt) override
Update the representation state to the current time step.
Definition: RigidRepresentation.cpp:210