MovingSquareForce Class Reference

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

`#include <SurgSim/Testing/VisualTestCommon/MovingSquareForce.h>`

Inheritance diagram for MovingSquareForce:

## Classes

struct | SquarePoseVectors
| State defined by the pose of the square. More...

## Public Member Functions

| MovingSquareForce (const std::string &toolDeviceName, const std::string &squareDeviceName)
| Constructor. More...
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). More...
Public Member Functions inherited from SurgSim::Input::OutputProducerInterface
virtual | ~OutputProducerInterface ()
| Virtual destructor (empty). More...

## 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...

## Private Attributes

const std::string | m_toolDeviceName
| Name of the device used as the tool. More...
const std::string | m_squareDeviceName
| Name of the device used to move the square. More...
SurgSim::DataStructures::DataGroup | m_outputData
| Internally stored output data (force and torque). More...
double | m_squareHalfSize
| One half of the edge length of the square we're colliding against, in meters. More...
double | m_surfaceStiffness
| The surface stiffness, in newtons per meter. More...
double | m_forceLimit
| The maximum force before the application allows the tool to pop through. More...
SurgSim::Framework::LockedContainer< SquarePoseVectors > | m_square
| Points and directions defined by the pose of the square. More...
double | m_squareNormalDirection
| The current sign of the direction of the normal vector of the square. More...
SurgSim::Math::Vector3d | m_tipPoint
| The location of the "tip" (i.e. interacting point) of the tool, in the local frame relative to the tool pose. 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

## Constructor & Destructor Documentation

## MovingSquareForce()

MovingSquareForce::MovingSquareForce | ( | const std::string & | toolDeviceName,
|  | const std::string & | squareDeviceName
| ) |  |

Constructor.

## 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

  position | The device tip position.

Returns
  The computed force.

## handleInput()

void MovingSquareForce::handleInput | ( | const std::string & | device,
|  | const SurgSim::DataStructures::DataGroup & | inputData
| ) |  |

override virtual

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

  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.

## initializeInput()

void MovingSquareForce::initializeInput | ( | const std::string & | device,
|  | const SurgSim::DataStructures::DataGroup & | inputData
| ) |  |

override virtual

Set the initial input data group.

Parameters

  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.

## requestOutput()

bool MovingSquareForce::requestOutput | ( | const std::string & | device,
|  | SurgSim::DataStructures::DataGroup * | outputData
| ) |  |

override virtual

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

  | 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 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

  squareInputData | The 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

  toolInputData | The state of the device controlling the tool.

## Member Data Documentation

## m_forceLimit

double MovingSquareForce::m_forceLimit

private

The maximum force before the application allows the tool to pop through.

## m_outputData

SurgSim::DataStructures::DataGroup MovingSquareForce::m_outputData

private

Internally stored output data (force and torque).

## m_square

SurgSim::Framework::LockedContainer<SquarePoseVectors> MovingSquareForce::m_square

private

Points and directions defined by the pose of the square.

## m_squareDeviceName

const std::string MovingSquareForce::m_squareDeviceName

private

Name of the device used to move the square.

## m_squareHalfSize

double MovingSquareForce::m_squareHalfSize

private

One half of the edge length of the square we're colliding against, in meters.

## m_squareNormalDirection

double MovingSquareForce::m_squareNormalDirection

private

The current sign of the direction of the normal vector of the square.

## m_surfaceStiffness

double MovingSquareForce::m_surfaceStiffness

private

The surface stiffness, in newtons per meter.

## m_tipPoint

SurgSim::Math::Vector3d MovingSquareForce::m_tipPoint

private

The location of the "tip" (i.e. interacting point) of the tool, in the local frame relative to the tool pose.

## m_toolDeviceName

const std::string MovingSquareForce::m_toolDeviceName

private

Name of the device used as the tool.

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

- SurgSim/Testing/VisualTestCommon/MovingSquareForce.h
- SurgSim/Testing/VisualTestCommon/MovingSquareForce.cpp