![]() |
An output device filter that scales forces and/or torques. More...
#include <SurgSim/Devices/DeviceFilters/ForceScale.h>
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... | |
![]() | |
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... | |
![]() | |
virtual | ~DeviceInterface () |
Virtual destructor (empty). More... | |
![]() | |
virtual | ~InputConsumerInterface () |
Virtual destructor (empty). More... | |
![]() | |
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 | |
![]() | |
virtual void | pushInput () |
Push application input to consumers. More... | |
virtual bool | pullOutput () |
Pull application output from a producer. More... | |
SurgSim::DataStructures::DataGroup & | getInputData () |
Getter for the input data DataGroup. More... | |
const SurgSim::DataStructures::DataGroup & | getOutputData () const |
Getter for the output data DataGroup. More... | |
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.
|
explicit |
Constructor.
name | Name of this device filter. |
|
virtual |
Destructor.
|
overrideprivatevirtual |
Finalize (de-initialize) the device.
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Notifies the consumer that the application input coming from the device has been updated.
Passes through all data unchanged.
device | The 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). |
inputData | The application input state coming from the device. |
Implements SurgSim::Input::InputConsumerInterface.
|
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.
Implements SurgSim::Input::DeviceInterface.
|
overridevirtual |
Set the initial input data.
Passes through all data unchanged.
device | The 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). |
inputData | The application input state coming from the device. |
Implements SurgSim::Input::InputConsumerInterface.
|
private |
Filter the output data, scaling the forces and torques.
dataToFilter | The data that will be filtered. | |
[in,out] | result | A pointer to a DataGroup object that must be assignable to by the dataToFilter object. Will contain the filtered data. |
|
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.
device | The 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] | outputData | The data being sent to the device. |
Implements SurgSim::Input::OutputProducerInterface.
void SurgSim::Device::ForceScale::setForceScale | ( | double | forceScale | ) |
Set the force scale factor so that each direction has the same scale.
forceScale | The scalar scaling factor. |
void SurgSim::Device::ForceScale::setTorqueScale | ( | double | torqueScale | ) |
Set the torque scale factor so that each direction has the same scale.
torqueScale | The scalar scaling factor. |
|
private |
True if the output DataGroup indices have been cached.
|
private |
The indices into the DataGroups.
|
private |
The indices into the DataGroups.
|
private |
The scaling factor applied to each direction of the force.
|
private |
The mutex that protects the scaling factors.
|
private |
The indices into the DataGroups.
|
private |
The indices into the DataGroups.
|
private |
The scaling factor applied to each direction of the torque.