opensurgsim
Classes | Public Member Functions | Protected Member Functions | List of all members
MovingSquareForce Class Reference

A simple listener to calculate collision force against a square area for the example application. More...

#include <MovingSquareForce.h>

Inheritance diagram for MovingSquareForce:
SurgSim::Input::InputConsumerInterface SurgSim::Input::OutputProducerInterface

Public Member Functions

 MovingSquareForce (const std::string &toolDeviceName, const std::string &squareDeviceName)
 Constructor.
 
void initializeInput (const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
 Set the initial input data group. More...
 
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...
 
bool requestOutput (const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
 Asks the producer to provide output state to the device. More...
 
- Public Member Functions inherited from SurgSim::Input::InputConsumerInterface
virtual ~InputConsumerInterface ()
 Virtual destructor (empty).
 
- Public Member Functions inherited from SurgSim::Input::OutputProducerInterface
virtual ~OutputProducerInterface ()
 Virtual destructor (empty).
 

Protected Member Functions

void updateTool (const SurgSim::DataStructures::DataGroup &toolInputData)
 Updates the state of the tool as described by toolInputData. More...
 
void updateSquare (const SurgSim::DataStructures::DataGroup &squareInputData)
 Updates the state of the square as described by squareInputData. More...
 
SurgSim::Math::Vector3d computeForce (const SurgSim::Math::Vector3d &position)
 Calculates the force as a function of device tip position. More...
 

Detailed Description

A simple listener to calculate collision force against a square area for the example application.

Includes support for the square being moved by a second tool.

See also
SurgSim::Input::InputConsumerInterface, SurgSim::Input::OutputProducerInterface

Member Function Documentation

§ computeForce()

Vector3d MovingSquareForce::computeForce ( const SurgSim::Math::Vector3d position)
protected

Calculates the force as a function of device tip position.

The calculation is very simple, for a simple demo of the device input/output functionality.

Parameters
positionThe device tip position.
Returns
The computed force.

§ handleInput()

void MovingSquareForce::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.

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

type name
pose "pose" Device pose (units are meters).
bool "button1" State of the first device button.
bool "button2" State of the second device button (and so on).

Other possible contents includes:

type name
bool "isHomed" Device homing status.
bool "isHomedX" Individual homing status for the X axis (and so on).
bool "isHeld" Safety sensor etc. status.
string "model" Device model description.
string "serial" Serial number string.
(any) "debug:*" Various debugging information
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.

§ initializeInput()

void MovingSquareForce::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.

§ requestOutput()

bool MovingSquareForce::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.

§ updateSquare()

void MovingSquareForce::updateSquare ( const SurgSim::DataStructures::DataGroup squareInputData)
protected

Updates the state of the square as described by squareInputData.

Parameters
squareInputDataThe state of the device controlling the colliding square.

§ updateTool()

void MovingSquareForce::updateTool ( const SurgSim::DataStructures::DataGroup toolInputData)
protected

Updates the state of the tool as described by toolInputData.

Parameters
toolInputDataThe state of the device controlling the tool.

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