opensurgsim
MovingSquareForce.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_TESTING_VISUALTESTCOMMON_MOVINGSQUAREFORCE_H
17 #define SURGSIM_TESTING_VISUALTESTCOMMON_MOVINGSQUAREFORCE_H
18 
19 #include <string>
20 
21 #include "SurgSim/Input/InputConsumerInterface.h"
22 #include "SurgSim/Input/OutputProducerInterface.h"
23 #include "SurgSim/DataStructures/DataGroup.h"
24 
25 #include "SurgSim/Framework/LockedContainer.h"
26 
27 
32 {
33 public:
35  MovingSquareForce(const std::string& toolDeviceName, const std::string& squareDeviceName);
36 
37  void initializeInput(const std::string& device, const SurgSim::DataStructures::DataGroup& inputData) override;
38 
39  void handleInput(const std::string& device, const SurgSim::DataStructures::DataGroup& inputData) override;
40 
41  bool requestOutput(const std::string& device, SurgSim::DataStructures::DataGroup* outputData) override;
42 
43 protected:
46  void updateTool(const SurgSim::DataStructures::DataGroup& toolInputData);
47 
50  void updateSquare(const SurgSim::DataStructures::DataGroup& squareInputData);
51 
58 
59 private:
61  struct SquarePoseVectors
62  {
64  SquarePoseVectors();
65 
69  SurgSim::Math::Vector3d edgeDirectionX;
71  SurgSim::Math::Vector3d edgeDirectionY;
74  };
75 
76 
78  const std::string m_toolDeviceName;
80  const std::string m_squareDeviceName;
81 
84 
86  double m_squareHalfSize;
88  double m_surfaceStiffness;
90  double m_forceLimit;
91 
95  double m_squareNormalDirection;
96 
98  SurgSim::Math::Vector3d m_tipPoint;
99 };
100 
101 #endif // SURGSIM_TESTING_VISUALTESTCOMMON_MOVINGSQUAREFORCE_H
Interface for a producer that generates device output updates (forces, status LED state...
Definition: OutputProducerInterface.h:33
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.
Definition: MovingSquareForce.cpp:65
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
MovingSquareForce(const std::string &toolDeviceName, const std::string &squareDeviceName)
Constructor.
Definition: MovingSquareForce.cpp:43
bool requestOutput(const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
Asks the producer to provide output state to the device.
Definition: MovingSquareForce.cpp:116
Interface for a consumer that monitors device and signal state updates (pose, buttons, etc).
Definition: InputConsumerInterface.h:33
A simple listener to calculate collision force against a square area for the example application...
Definition: MovingSquareForce.h:31
A collection of NamedData objects.
Definition: DataGroup.h:68
void updateTool(const SurgSim::DataStructures::DataGroup &toolInputData)
Updates the state of the tool as described by toolInputData.
Definition: MovingSquareForce.cpp:81
SurgSim::Math::Vector3d computeForce(const SurgSim::Math::Vector3d &position)
Calculates the force as a function of device tip position.
Definition: MovingSquareForce.cpp:122
void initializeInput(const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
Set the initial input data group.
Definition: MovingSquareForce.cpp:61
void updateSquare(const SurgSim::DataStructures::DataGroup &squareInputData)
Updates the state of the square as described by squareInputData.
Definition: MovingSquareForce.cpp:98