RigidRepresentationBase.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_RIGIDREPRESENTATIONBASE_H
#define SURGSIM_PHYSICS_RIGIDREPRESENTATIONBASE_H
#include "SurgSim/DataStructures/Location.h"
#include "SurgSim/Math/Shape.h"
#include "SurgSim/Physics/Representation.h"
#include "SurgSim/Physics/RigidLocalization.h"
#include "SurgSim/Physics/RigidState.h"
namespace SurgSim
{
namespace Collision
{
class Representation;
}
namespace Physics
{
class RigidRepresentationBase : public Representation
{
public:
explicit RigidRepresentationBase(const std::string& name);
virtual ~RigidRepresentationBase();
void setInitialState(const RigidState& state);
void resetState() override;
const RigidState& getInitialState() const;
const RigidState& getCurrentState() const;
const RigidState& getPreviousState() const;
std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location& location) override;
void setDensity(double rho);
double getDensity() const;
double getMass() const;
const SurgSim::Math::Vector3d& getMassCenter() const;
const SurgSim::Math::Matrix33d& getLocalInertia() const;
void setLinearDamping(double linearDamping);
double getLinearDamping() const;
void setAngularDamping(double angularDamping);
double getAngularDamping() const;
void setShape(const std::shared_ptr<SurgSim::Math::Shape> shape);
const std::shared_ptr<SurgSim::Math::Shape> getShape() const;
void setCollisionRepresentation(std::shared_ptr<SurgSim::Collision::Representation> representation) override;
void beforeUpdate(double dt) override;
void afterUpdate(double dt) override;
protected:
bool doInitialize() override;
bool doWakeUp() override;
RigidState m_initialState;
RigidState m_previousState;
RigidState m_currentState;
RigidState m_finalState;
bool m_parametersValid;
double m_rho;
double m_mass;
double m_linearDamping;
double m_angularDamping;
SurgSim::Math::Vector3d m_massCenter;
SurgSim::Math::Matrix33d m_localInertia;
std::shared_ptr<SurgSim::Math::Shape> m_shape;
template <class T>
std::shared_ptr<T> createTypedLocalization(const SurgSim::DataStructures::Location& location);
private:
void updateProperties();
virtual void updateGlobalInertiaMatrices(const RigidState& state) = 0;
};
}; // Physics
}; // SurgSim
#include "SurgSim/Physics/RigidRepresentationBase-inl.h"
#endif // SURGSIM_PHYSICS_RIGIDREPRESENTATIONBASE_H
SurgSim::Physics::RigidRepresentationBase::m_angularDamping
double m_angularDamping
Angular damping parameter (in N.m.s.rad-1)
Definition: RigidRepresentationBase.h:148
Representation.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
RigidRepresentationBase-inl.h
SurgSim::Physics::RigidRepresentationBase::m_shape
std::shared_ptr< SurgSim::Math::Shape > m_shape
Shape to be used for the mass/inertia calculation.
Definition: RigidRepresentationBase.h:157
SurgSim::Physics::RigidRepresentationBase::m_localInertia
SurgSim::Math::Matrix33d m_localInertia
Inertia matrix in local coordinates.
Definition: RigidRepresentationBase.h:154
SurgSim::Physics::Representation
The Representation class defines the base class for all physics objects.
Definition: Representation.h:53
SurgSim::DataStructures::Location
A Location defines a local position w.r.t.
Definition: Location.h:39
SurgSim::Physics::RigidRepresentationBase::m_previousState
RigidState m_previousState
Previous rigid representation state.
Definition: RigidRepresentationBase.h:129
SurgSim::Physics::RigidRepresentationBase::m_initialState
RigidState m_initialState
Initial rigid representation state (useful for reset)
Definition: RigidRepresentationBase.h:127
SurgSim::Physics::RigidRepresentationBase
The RigidRepresentationBase class defines the base class for all rigid motion based representations (...
Definition: RigidRepresentationBase.h:38
SurgSim::Physics::RigidState
The RigidState class describes a state (position and velocity information).
Definition: RigidState.h:31
SurgSim::Physics::RigidRepresentationBase::m_mass
double m_mass
Total mass of the object (in Kg)
Definition: RigidRepresentationBase.h:142
SurgSim::Physics::RigidRepresentationBase::m_currentState
RigidState m_currentState
Current rigid representation state.
Definition: RigidRepresentationBase.h:131
SurgSim::Physics::RigidRepresentationBase::m_rho
double m_rho
Density of the object (in Kg.m-3)
Definition: RigidRepresentationBase.h:139
SurgSim::Physics::RigidRepresentationBase::m_parametersValid
bool m_parametersValid
Validity of the parameters.
Definition: RigidRepresentationBase.h:136
SurgSim::Physics::RigidRepresentationBase::m_finalState
RigidState m_finalState
Last valid/final rigid representation state.
Definition: RigidRepresentationBase.h:133
SurgSim::Physics::RigidRepresentationBase::m_linearDamping
double m_linearDamping
Linear damping parameter (in N.s.m-1 or Kg.s-1)
Definition: RigidRepresentationBase.h:145
SurgSim::Physics::RigidRepresentationBase::m_massCenter
SurgSim::Math::Vector3d m_massCenter
Mass-center of the object.
Definition: RigidRepresentationBase.h:151
SurgSim::Math::Matrix33d
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
RigidState.h
Shape.h
RigidLocalization.h
Location.h
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57