ForceScale.h
Go to the documentation of this file.
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_DEVICES_DEVICEFILTERS_FORCESCALE_H
17 #define SURGSIM_DEVICES_DEVICEFILTERS_FORCESCALE_H
18 
19 #include <boost/thread/mutex.hpp>
20 #include <string>
21 
26 
27 namespace SurgSim
28 {
29 
30 namespace Device
31 {
39 {
40 public:
43  explicit ForceScale(const std::string& name);
44 
46  virtual ~ForceScale();
47 
52  virtual bool initialize() override;
53 
58  virtual void initializeInput(const std::string& device,
59  const SurgSim::DataStructures::DataGroup& inputData) override;
60 
66  virtual void handleInput(const std::string& device, const SurgSim::DataStructures::DataGroup& inputData) override;
67 
76  virtual bool requestOutput(const std::string& device, SurgSim::DataStructures::DataGroup* outputData) override;
77 
80  void setForceScale(double forceScale);
81 
84  void setTorqueScale(double torqueScale);
85 
86 private:
89  virtual bool finalize() override;
90 
95  void outputFilter(const SurgSim::DataStructures::DataGroup& dataToFilter,
97 
99  boost::mutex m_mutex;
100 
102  double m_forceScale;
103 
106 
114 
117 };
118 
119 }; // namespace Device
120 }; // namespace SurgSim
121 
122 #endif // SURGSIM_DEVICES_DEVICEFILTERS_FORCESCALE_H
void setForceScale(double forceScale)
Set the force scale factor so that each direction has the same scale.
Definition: ForceScale.cpp:128
ForceScale(const std::string &name)
Constructor.
Definition: ForceScale.cpp:30
void setTorqueScale(double torqueScale)
Set the torque scale factor so that each direction has the same scale.
Definition: ForceScale.cpp:134
Definition: DriveElementFromInputBehavior.cpp:27
Interface for a producer that generates device output updates (forces, status LED state...
Definition: OutputProducerInterface.h:33
virtual ~ForceScale()
Destructor.
Definition: ForceScale.cpp:42
int m_forceIndex
Definition: ForceScale.h:109
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
virtual bool finalize() override
Finalize (de-initialize) the device.
Definition: ForceScale.cpp:52
int m_torqueIndex
Definition: ForceScale.h:110
int m_springJacobianIndex
Definition: ForceScale.h:111
Interface for a consumer that monitors device and signal state updates (pose, buttons, etc).
Definition: InputConsumerInterface.h:33
int m_damperJacobianIndex
Definition: ForceScale.h:112
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.
Definition: ForceScale.cpp:62
An output device filter that scales forces and/or torques.
Definition: ForceScale.h:37
A collection of NamedData objects.
Definition: DataGroup.h:66
bool m_cachedOutputIndices
True if the output DataGroup indices have been cached.
Definition: ForceScale.h:116
double m_forceScale
The scaling factor applied to each direction of the force.
Definition: ForceScale.h:102
boost::mutex m_mutex
The mutex that protects the scaling factors.
Definition: ForceScale.h:99
A class that implements some common management code on top of the DeviceInterface.
Definition: CommonDevice.h:34
virtual void initializeInput(const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
Set the initial input data.
Definition: ForceScale.cpp:57
virtual bool initialize() override
Fully initialize the device.
Definition: ForceScale.cpp:47
double m_torqueScale
The scaling factor applied to each direction of the torque.
Definition: ForceScale.h:105
void outputFilter(const SurgSim::DataStructures::DataGroup &dataToFilter, SurgSim::DataStructures::DataGroup *result)
Filter the output data, scaling the forces and torques.
Definition: ForceScale.cpp:89
virtual bool requestOutput(const std::string &device, SurgSim::DataStructures::DataGroup *outputData) override
Asks the producer to provide output state to the device.
Definition: ForceScale.cpp:68