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

A device filter that integrates the pose, turning a relative device into an absolute one. More...

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

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

Public Types

typedef
SurgSim::Math::RigidTransform3d 
PoseType
 The type used for poses. More...
 

Public Member Functions

 PoseIntegrator (const std::string &name)
 Constructor. More...
 
const PoseTypeintegrate (const PoseType &pose)
 Integrates the pose. More...
 
virtual bool initialize () override
 Fully initialize the device. More...
 
virtual bool finalize () override
 Finalize (de-initialize) the device. More...
 
virtual void initializeInput (const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
 Set the initial input data group. 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 setReset (const std::string &name)
 Sets the string name of the boolean entry that will reset the pose to its initial value. 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 Attributes

PoseType m_poseResult
 The result of integrating the input poses. More...
 
SurgSim::Framework::Timer m_timer
 A timer for the update rate needed for calculating velocity. More...
 
bool m_firstInput
 true if the input DataGroup should be created. More...
 
std::shared_ptr
< SurgSim::DataStructures::DataGroupCopier
m_copier
 A copier into the input DataGroup, if needed. More...
 
std::string m_resetName
 The name of the reset boolean (if any). More...
 
int m_poseIndex
 
int m_linearVelocityIndex
 
int m_angularVelocityIndex
 
int m_resetIndex
 

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

A device filter that integrates the pose, turning a relative device into an absolute one.

Also provides the instantaneous linear and angular velocities.

See also
SurgSim::Input::CommonDevice
SurgSim::Input::InputConsumerInterface
SurgSim::Input::OutputProducerInterface

Member Typedef Documentation

The type used for poses.

Constructor & Destructor Documentation

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

Constructor.

Parameters
nameName of this device filter.

Member Function Documentation

bool SurgSim::Device::PoseIntegrator::finalize ( )
overridevirtual

Finalize (de-initialize) the device.

Implements SurgSim::Input::DeviceInterface.

void SurgSim::Device::PoseIntegrator::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.

Treats the pose coming from the input device as a delta pose and integrates it to get the output pose.

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::PoseIntegrator::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.

Implements SurgSim::Input::DeviceInterface.

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

Set the initial input data group.

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.

const PoseIntegrator::PoseType & SurgSim::Device::PoseIntegrator::integrate ( const PoseType pose)

Integrates the pose.

Parameters
poseThe latest differential pose.
Returns
The integrated pose.
bool SurgSim::Device::PoseIntegrator::requestOutput ( const std::string &  device,
SurgSim::DataStructures::DataGroup outputData 
)
overridevirtual

Asks the producer to provide output state to the device.

Note that devices may never call this method, e.g. because the device doesn't actually have any output capability.

Typical output data contents (but note that individual devices may do things differently):

type name
vector "force" Commanded force for the device (units are newtons).
vector "torque" Commanded torque for the device (units are newton-meters).
bool "isEnabled" Safety switch input.

Other possible contents includes:

type name
bool "led0" Desired state for LED 0.
bool "led1" Desired state for LED 1.
string "toolId" Calibration ID to use, e.g. for camera devices.
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 application output state being fed into the device.
Returns
true if the producer has provided some output, false if it refuses to do so. A producer that returns false should leave outputData unmodified.

Implements SurgSim::Input::OutputProducerInterface.

void SurgSim::Device::PoseIntegrator::setReset ( const std::string &  name)

Sets the string name of the boolean entry that will reset the pose to its initial value.

Such a reset can be useful if the integrated pose is used to position an object and the integration takes the object out of view.

Parameters
nameThe name of the NamedData<bool> entry.
Warning
A pose reset may generate high velocities, and if the pose is the input to a VirtualToolCoupler then large forces will likely be generated.
Exceptions
Assertsif called after initialize.

Member Data Documentation

int SurgSim::Device::PoseIntegrator::m_angularVelocityIndex
private

The indices into the DataGroups.

std::shared_ptr<SurgSim::DataStructures::DataGroupCopier> SurgSim::Device::PoseIntegrator::m_copier
private

A copier into the input DataGroup, if needed.

bool SurgSim::Device::PoseIntegrator::m_firstInput
private

true if the input DataGroup should be created.

int SurgSim::Device::PoseIntegrator::m_linearVelocityIndex
private

The indices into the DataGroups.

int SurgSim::Device::PoseIntegrator::m_poseIndex
private

The indices into the DataGroups.

PoseType SurgSim::Device::PoseIntegrator::m_poseResult
private

The result of integrating the input poses.

int SurgSim::Device::PoseIntegrator::m_resetIndex
private

The indices into the DataGroups.

std::string SurgSim::Device::PoseIntegrator::m_resetName
private

The name of the reset boolean (if any).

SurgSim::Framework::Timer SurgSim::Device::PoseIntegrator::m_timer
private

A timer for the update rate needed for calculating velocity.


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