All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SurgSim::Device::ForceScale Class Reference

An output device filter that scales forces and/or torques. More...

#include <SurgSim/Devices/DeviceFilters/ForceScale.h>

Inheritance diagram for SurgSim::Device::ForceScale:
Inheritance graph
[legend]
Collaboration diagram for SurgSim::Device::ForceScale:
Collaboration graph
[legend]

Public Member Functions

 ForceScale (const std::string &name)
 Constructor. More...
 
virtual ~ForceScale ()
 Destructor. More...
 
virtual bool initialize () override
 Fully initialize the device. More...
 
virtual void initializeInput (const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
 Set the initial input data. More...
 
virtual void handleInput (const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
 Notifies the consumer that the application input coming from the device has been updated. More...
 
virtual bool requestOutput (const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
 Asks the producer to provide output state to the device. More...
 
void setForceScale (double forceScale)
 Set the force scale factor so that each direction has the same scale. More...
 
void setTorqueScale (double torqueScale)
 Set the torque scale factor so that each direction has the same scale. More...
 
- Public Member Functions inherited from SurgSim::Input::CommonDevice
 CommonDevice (const std::string &name)
 Constructor. More...
 
 CommonDevice (const std::string &name, const SurgSim::DataStructures::DataGroup &inputData)
 Constructor. More...
 
 CommonDevice (const std::string &name, SurgSim::DataStructures::DataGroup &&inputData)
 Constructor. More...
 
virtual ~CommonDevice ()
 Destructor. More...
 
virtual std::string getName () const override
 Return a (hopefully unique) device name. More...
 
void setNameForCallback (const std::string &name)
 Set the name used for calling the input consumers and output producer. More...
 
std::string getNameForCallback () const
 Get the name used for calling the input consumers and output producer. More...
 
virtual bool addInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer) override
 Connect this device to an InputConsumerInterface, which will receive the data that comes from this device. More...
 
virtual bool removeInputConsumer (std::shared_ptr< InputConsumerInterface > inputConsumer) override
 Disconnect this device from an InputConsumerInterface, which will no longer receive data from this device. More...
 
virtual bool setOutputProducer (std::shared_ptr< OutputProducerInterface > outputProducer) override
 Connect this device to an OutputProducerInterface, which will send data to this device. More...
 
virtual bool removeOutputProducer (std::shared_ptr< OutputProducerInterface > outputProducer) override
 Disconnect this device from an OutputProducerInterface, which will no longer send data to this device. More...
 
virtual bool hasOutputProducer () override
 Getter for whether or not this device is connected with an OutputProducerInterface. More...
 
- Public Member Functions inherited from SurgSim::Input::DeviceInterface
virtual ~DeviceInterface ()
 Virtual destructor (empty). More...
 
- Public Member Functions inherited from SurgSim::Input::InputConsumerInterface
virtual ~InputConsumerInterface ()
 Virtual destructor (empty). More...
 
- Public Member Functions inherited from SurgSim::Input::OutputProducerInterface
virtual ~OutputProducerInterface ()
 Virtual destructor (empty). More...
 

Private Member Functions

virtual bool finalize () override
 Finalize (de-initialize) the device. More...
 
void outputFilter (const SurgSim::DataStructures::DataGroup &dataToFilter, SurgSim::DataStructures::DataGroup *result)
 Filter the output data, scaling the forces and torques. More...
 

Private Attributes

boost::mutex m_mutex
 The mutex that protects the scaling factors. More...
 
double m_forceScale
 The scaling factor applied to each direction of the force. More...
 
double m_torqueScale
 The scaling factor applied to each direction of the torque. More...
 
bool m_cachedOutputIndices
 True if the output DataGroup indices have been cached. More...
 
int m_forceIndex
 
int m_torqueIndex
 
int m_springJacobianIndex
 
int m_damperJacobianIndex
 

Additional Inherited Members

- Protected Member Functions inherited from SurgSim::Input::CommonDevice
virtual void pushInput ()
 Push application input to consumers. More...
 
virtual bool pullOutput ()
 Pull application output from a producer. More...
 
SurgSim::DataStructures::DataGroupgetInputData ()
 Getter for the input data DataGroup. More...
 
const
SurgSim::DataStructures::DataGroup
getOutputData () const
 Getter for the output data DataGroup. More...
 

Detailed Description

An output device filter that scales forces and/or torques.

Any other entries in the DataGroup are passed through. For convenience, it is also an InputConsumerInterface that does no filtering of the input data. Thus it can be added as an input consumer to the raw device, and set as the output producer for the raw device, after which other device filters, input components, and output components only need access to the ForceScale instance, not the raw device.

Constructor & Destructor Documentation

SurgSim::Device::ForceScale::ForceScale ( const std::string &  name)
explicit

Constructor.

Parameters
nameName of this device filter.
SurgSim::Device::ForceScale::~ForceScale ( )
virtual

Destructor.

Member Function Documentation

bool SurgSim::Device::ForceScale::finalize ( )
overrideprivatevirtual

Finalize (de-initialize) the device.

Returns
True on success.

Implements SurgSim::Input::DeviceInterface.

void SurgSim::Device::ForceScale::handleInput ( const std::string &  device,
const SurgSim::DataStructures::DataGroup inputData 
)
overridevirtual

Notifies the consumer that the application input coming from the device has been updated.

Passes through all data unchanged.

Parameters
deviceThe name of the device that is producing the input. This should only be used to identify the device (e.g. if the consumer is listening to several devices at once).
inputDataThe application input state coming from the device.

Implements SurgSim::Input::InputConsumerInterface.

bool SurgSim::Device::ForceScale::initialize ( )
overridevirtual

Fully initialize the device.

When the manager object creates the device, the internal state of the device usually isn't fully initialized yet. This method performs any needed initialization.

Returns
True on success.

Implements SurgSim::Input::DeviceInterface.

void SurgSim::Device::ForceScale::initializeInput ( const std::string &  device,
const SurgSim::DataStructures::DataGroup inputData 
)
overridevirtual

Set the initial input data.

Passes through all data unchanged.

Parameters
deviceThe name of the device that is producing the input. This should only be used to identify the device (e.g. if the consumer is listening to several devices at once).
inputDataThe application input state coming from the device.

Implements SurgSim::Input::InputConsumerInterface.

void SurgSim::Device::ForceScale::outputFilter ( const SurgSim::DataStructures::DataGroup dataToFilter,
SurgSim::DataStructures::DataGroup result 
)
private

Filter the output data, scaling the forces and torques.

Parameters
dataToFilterThe data that will be filtered.
[in,out]resultA pointer to a DataGroup object that must be assignable to by the dataToFilter object. Will contain the filtered data.
bool SurgSim::Device::ForceScale::requestOutput ( const std::string &  device,
SurgSim::DataStructures::DataGroup outputData 
)
overridevirtual

Asks the producer to provide output state to the device.

Passes through all data, modifying certain data entries used by haptic devices to calculate force and torque. Note that devices may never call this method, e.g., because the device doesn't actually have any output capability.

Parameters
deviceThe name of the device that is requesting the output. This should only be used to identify the device (e.g. if the producer is listening to several devices at once).
[out]outputDataThe data being sent to the device.
Returns
True if the producer has provided output data. A producer that returns false should leave outputData unmodified.

Implements SurgSim::Input::OutputProducerInterface.

void SurgSim::Device::ForceScale::setForceScale ( double  forceScale)

Set the force scale factor so that each direction has the same scale.

Parameters
forceScaleThe scalar scaling factor.
void SurgSim::Device::ForceScale::setTorqueScale ( double  torqueScale)

Set the torque scale factor so that each direction has the same scale.

Parameters
torqueScaleThe scalar scaling factor.

Member Data Documentation

bool SurgSim::Device::ForceScale::m_cachedOutputIndices
private

True if the output DataGroup indices have been cached.

int SurgSim::Device::ForceScale::m_damperJacobianIndex
private

The indices into the DataGroups.

int SurgSim::Device::ForceScale::m_forceIndex
private

The indices into the DataGroups.

double SurgSim::Device::ForceScale::m_forceScale
private

The scaling factor applied to each direction of the force.

boost::mutex SurgSim::Device::ForceScale::m_mutex
private

The mutex that protects the scaling factors.

int SurgSim::Device::ForceScale::m_springJacobianIndex
private

The indices into the DataGroups.

int SurgSim::Device::ForceScale::m_torqueIndex
private

The indices into the DataGroups.

double SurgSim::Device::ForceScale::m_torqueScale
private

The scaling factor applied to each direction of the torque.


The documentation for this class was generated from the following files: