VirtualToolCoupler.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_VIRTUALTOOLCOUPLER_H
#define SURGSIM_PHYSICS_VIRTUALTOOLCOUPLER_H
#include <memory>
#include "SurgSim/DataStructures/DataGroup.h"
#include "SurgSim/DataStructures/DataGroupBuilder.h"
#include "SurgSim/DataStructures/OptionalValue.h"
#include "SurgSim/Framework/Behavior.h"
#include "SurgSim/Framework/Log.h"
#include "SurgSim/Framework/ObjectFactory.h"
namespace SurgSim
{
namespace Input
{
class InputComponent;
class OutputComponent;
}
namespace Physics
{
class RigidRepresentation;
SURGSIM_STATIC_REGISTRATION(VirtualToolCoupler);
class VirtualToolCoupler : public Framework::Behavior
{
public:
explicit VirtualToolCoupler(const std::string& name);
~VirtualToolCoupler();
SURGSIM_CLASSNAME(SurgSim::Physics::VirtualToolCoupler);
const std::shared_ptr<Framework::Component> getInput();
void setInput(const std::shared_ptr<Framework::Component> input);
const std::shared_ptr<Framework::Component> getOutput();
void setOutput(const std::shared_ptr<Framework::Component> output);
const std::shared_ptr<Framework::Component> getRepresentation();
void setRepresentation(const std::shared_ptr<Framework::Component> rigid);
bool isHapticOutputOnlyWhenColliding() const;
void setHapticOutputOnlyWhenColliding(bool haptic);
const std::string& getPoseName();
void setPoseName(const std::string& poseName = DataStructures::Names::POSE);
void update(double dt) override;
void overrideLinearStiffness(double linearStiffness);
double getLinearStiffness();
void overrideLinearDamping(double linearDamping);
double getLinearDamping();
void overrideAngularStiffness(double angularStiffness);
double getAngularStiffness();
void overrideAngularDamping(double angularDamping);
double getAngularDamping();
void overrideAttachmentPoint(const Math::Vector3d& attachment);
const Math::Vector3d& getAttachmentPoint();
void setCalculateInertialTorques(bool calculateInertialTorques);
bool getCalculateInertialTorques() const;
void doRetire() override;
void setLocalActive(bool val) override;
protected:
bool doInitialize() override;
bool doWakeUp() override;
int getTargetManagerType() const override;
virtual DataStructures::DataGroup buildOutputData();
void setOptionalLinearStiffness(const DataStructures::OptionalValue<double>& linearStiffness);
const DataStructures::OptionalValue<double>& getOptionalLinearStiffness() const;
void setOptionalLinearDamping(const DataStructures::OptionalValue<double>& linearDamping);
const DataStructures::OptionalValue<double>& getOptionalLinearDamping() const;
void setOptionalAngularStiffness(const DataStructures::OptionalValue<double>& angularStiffness);
const DataStructures::OptionalValue<double>& getOptionalAngularStiffness() const;
void setOptionalAngularDamping(const DataStructures::OptionalValue<double>& angularDamping);
const DataStructures::OptionalValue<double>& getOptionalAngularDamping() const;
void setOptionalAttachmentPoint(const DataStructures::OptionalValue<Math::Vector3d>& attachmentPoint);
const DataStructures::OptionalValue<Math::Vector3d>& getOptionalAttachmentPoint() const;
DataStructures::OptionalValue<double> m_optionalLinearStiffness;
DataStructures::OptionalValue<double> m_optionalLinearDamping;
DataStructures::OptionalValue<double> m_optionalAngularStiffness;
DataStructures::OptionalValue<double> m_optionalAngularDamping;
DataStructures::OptionalValue<Math::Vector3d> m_optionalAttachmentPoint;
DataStructures::DataGroup m_outputData;
std::shared_ptr<Input::InputComponent> m_input;
std::shared_ptr<Input::OutputComponent> m_output;
private:
std::shared_ptr<RigidRepresentation> m_rigid;
std::string m_poseName;
double m_linearStiffness;
double m_linearDamping;
double m_angularStiffness;
double m_angularDamping;
double m_outputForceScaling;
double m_outputTorqueScaling;
Math::Vector3d m_localAttachmentPoint;
bool m_calculateInertialTorques;
std::shared_ptr<Framework::Logger> m_logger;
bool m_hapticOutputOnlyWhenColliding;
Math::RigidTransform3d m_previousInputPose;
int m_poseIndex;
int m_linearVelocityIndex;
int m_angularVelocityIndex;
int m_forceIndex;
int m_torqueIndex;
int m_inputLinearVelocityIndex;
int m_inputAngularVelocityIndex;
int m_inputPoseIndex;
int m_springJacobianIndex;
int m_damperJacobianIndex;
};
}; // Physics
}; // SurgSim
#endif // SURGSIM_PHYSICS_VIRTUALTOOLCOUPLER_H
SurgSim::Physics::VirtualToolCoupler::m_outputData
DataStructures::DataGroup m_outputData
The DataGroup to output.
Definition: VirtualToolCoupler.h:241
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::VirtualToolCoupler::m_output
std::shared_ptr< Input::OutputComponent > m_output
The output component.
Definition: VirtualToolCoupler.h:247
SurgSim::Physics::VirtualToolCoupler::m_linearVelocityIndex
int m_linearVelocityIndex
Definition: VirtualToolCoupler.h:290
DataGroup.h
SurgSim::Physics::VirtualToolCoupler::m_torqueIndex
int m_torqueIndex
Definition: VirtualToolCoupler.h:293
SurgSim::Physics::VirtualToolCoupler::m_linearStiffness
double m_linearStiffness
Used Vtc stiffness parameter in linear mode (in N·m-1)
Definition: VirtualToolCoupler.h:254
SurgSim::Physics::VirtualToolCoupler::m_inputPoseIndex
int m_inputPoseIndex
Definition: VirtualToolCoupler.h:296
SurgSim::Physics::VirtualToolCoupler::m_springJacobianIndex
int m_springJacobianIndex
Definition: VirtualToolCoupler.h:297
SurgSim::DataStructures::OptionalValue< double >
ObjectFactory.h
Log.h
The convenience header that provides the entirety of the logging API.
SurgSim::Physics::VirtualToolCoupler::m_outputTorqueScaling
double m_outputTorqueScaling
Scaling factor for the torques sent to the OutputComponent.
Definition: VirtualToolCoupler.h:269
SurgSim::Physics::VirtualToolCoupler::m_poseIndex
int m_poseIndex
Definition: VirtualToolCoupler.h:289
SurgSim::Physics::VirtualToolCoupler::m_hapticOutputOnlyWhenColliding
bool m_hapticOutputOnlyWhenColliding
Whether or not the VTC sends forces and torques to the output device (if any) only when the tool is c...
Definition: VirtualToolCoupler.h:282
SurgSim::Physics::VirtualToolCoupler::m_angularDamping
double m_angularDamping
Used Vtc damping parameter in angular mode (in N·m·s·rad-1)
Definition: VirtualToolCoupler.h:263
SurgSim::Physics::VirtualToolCoupler::m_inputLinearVelocityIndex
int m_inputLinearVelocityIndex
Definition: VirtualToolCoupler.h:294
SurgSim::Physics::VirtualToolCoupler::m_localAttachmentPoint
Math::Vector3d m_localAttachmentPoint
The input&#39;s point of attachment in the local frame, i.e., the same frame in which the mass center is ...
Definition: VirtualToolCoupler.h:272
SurgSim::Physics::VirtualToolCoupler::m_optionalLinearDamping
DataStructures::OptionalValue< double > m_optionalLinearDamping
User supplied Vtc damping parameter in linear mode (in N·s·m-1 or Kg·s-1)
Definition: VirtualToolCoupler.h:229
Behavior.h
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Physics::VirtualToolCoupler::m_angularVelocityIndex
int m_angularVelocityIndex
Definition: VirtualToolCoupler.h:291
SurgSim::Physics::VirtualToolCoupler::m_inputAngularVelocityIndex
int m_inputAngularVelocityIndex
Definition: VirtualToolCoupler.h:295
SurgSim::Physics::VirtualToolCoupler::m_linearDamping
double m_linearDamping
Used Vtc damping parameter in linear mode (in N·s·m-1 or Kg·s-1)
Definition: VirtualToolCoupler.h:257
SurgSim::Physics::VirtualToolCoupler::m_optionalLinearStiffness
DataStructures::OptionalValue< double > m_optionalLinearStiffness
User supplied Vtc stiffness parameter in linear mode (in N·m-1)
Definition: VirtualToolCoupler.h:226
SurgSim::Physics::VirtualToolCoupler::m_poseName
std::string m_poseName
Definition: VirtualToolCoupler.h:251
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Physics::VirtualToolCoupler::m_calculateInertialTorques
bool m_calculateInertialTorques
Whether or not the calculated torques will simulate inertia.
Definition: VirtualToolCoupler.h:276
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Physics::VirtualToolCoupler
The VirtualToolCoupler couples a rigid object to an input/output device through a spring and damper...
Definition: VirtualToolCoupler.h:58
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Physics::VirtualToolCoupler::m_optionalAttachmentPoint
DataStructures::OptionalValue< Math::Vector3d > m_optionalAttachmentPoint
User supplied attachment point.
Definition: VirtualToolCoupler.h:238
SurgSim::Physics::VirtualToolCoupler::m_damperJacobianIndex
int m_damperJacobianIndex
Definition: VirtualToolCoupler.h:298
SurgSim::Physics::VirtualToolCoupler::m_input
std::shared_ptr< Input::InputComponent > m_input
The input component.
Definition: VirtualToolCoupler.h:244
OptionalValue.h
DataGroupBuilder.h
SurgSim::Physics::VirtualToolCoupler::m_outputForceScaling
double m_outputForceScaling
Scaling factor for the forces sent to the OutputComponent.
Definition: VirtualToolCoupler.h:266
SurgSim::Physics::VirtualToolCoupler::m_rigid
std::shared_ptr< RigidRepresentation > m_rigid
Definition: VirtualToolCoupler.h:250
SurgSim::Physics::VirtualToolCoupler::m_previousInputPose
Math::RigidTransform3d m_previousInputPose
The previous input pose.
Definition: VirtualToolCoupler.h:285
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Physics::VirtualToolCoupler::m_optionalAngularDamping
DataStructures::OptionalValue< double > m_optionalAngularDamping
User supplied Vtc damping parameter in angular mode (in N·m·s·rad-1)
Definition: VirtualToolCoupler.h:235
SurgSim::Physics::VirtualToolCoupler::m_logger
std::shared_ptr< Framework::Logger > m_logger
The logger.
Definition: VirtualToolCoupler.h:279
SurgSim::Physics::VirtualToolCoupler::m_angularStiffness
double m_angularStiffness
Used Vtc stiffness parameter in angular mode (in N·m rad-1)
Definition: VirtualToolCoupler.h:260
SurgSim::Physics::VirtualToolCoupler::m_forceIndex
int m_forceIndex
Definition: VirtualToolCoupler.h:292
SurgSim::Physics::VirtualToolCoupler::m_optionalAngularStiffness
DataStructures::OptionalValue< double > m_optionalAngularStiffness
User supplied Vtc stiffness parameter in angular mode (in N·m rad-1)
Definition: VirtualToolCoupler.h:232