opensurgsim
NovintDevice.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_DEVICES_NOVINT_NOVINTDEVICE_H
17 #define SURGSIM_DEVICES_NOVINT_NOVINTDEVICE_H
18 
19 #include <string>
20 
21 #include "SurgSim/DataStructures/OptionalValue.h"
22 #include "SurgSim/Input/CommonDevice.h"
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 class NovintScaffold;
29 
30 SURGSIM_STATIC_REGISTRATION(NovintDevice);
31 
70 {
71 public:
74  explicit NovintDevice(const std::string& name);
75 
76  SURGSIM_CLASSNAME(SurgSim::Devices::NovintDevice);
77 
79  virtual ~NovintDevice();
80 
85  void setSerialNumber(const std::string& serialNumber);
86 
90  bool getSerialNumber(std::string* serialNumber) const;
91 
98  void setInitializationName(const std::string& initializationName);
99 
103  bool getInitializationName(std::string* initializationName) const;
104 
105  bool initialize() override;
106 
107  bool isInitialized() const override;
108 
113  void setPositionScale(double scale);
115  double getPositionScale() const;
116 
121  void setOrientationScale(double scale);
123  double getOrientationScale() const;
124 
129  void set7DofDevice(bool val);
132  virtual bool is7DofDevice() const;
133 
138  void setMaxForce(double force);
139 
141  double getMaxForce() const;
142 
145  void setAntigrav(Math::Vector3d antigrav);
146 
148  Math::Vector3d getAntigrav() const;
149 
151  double getYawOffset() const;
152 
155  void setYawOffset(double yawOffset);
156 
158  double getPitchOffset() const;
159 
162  void setPitchOffset(double pitchOffset);
163 
165  double getRollOffset() const;
166 
169  void setRollOffset(double rollOffset);
170 
172  double getToolDofOffset() const;
173 
176  void setToolDofOffset(double toolDofOffset);
177 
178 protected:
181 
183  double m_maxForce;
184 
187 
190  double m_yawOffset;
191  double m_pitchOffset;
192  double m_rollOffset;
193  double m_toolDofOffset;
195 
196 private:
197  friend class NovintScaffold;
198 
199  bool finalize() override;
200 
203  const DataStructures::OptionalValue<std::string>& getOptionalInitializationName() const;
204  void setOptionalInitializationName(const DataStructures::OptionalValue<std::string>& name);
205  const DataStructures::OptionalValue<std::string>& getOptionalSerialNumber() const;
206  void setOptionalSerialNumber(const DataStructures::OptionalValue<std::string>& serial);
208 
210  std::shared_ptr<NovintScaffold> m_scaffold;
211 
214 
217 
219  double m_positionScale;
221  double m_orientationScale;
222 };
223 
224 }; // namespace Devices
225 }; // namespace SurgSim
226 
227 #endif // SURGSIM_DEVICES_NOVINT_NOVINTDEVICE_H
void setOrientationScale(double scale)
Sets the orientation scale for this device.
Definition: NovintDevice.cpp:148
double m_maxForce
The maximum force magnitude (in Newtons) that should be sent to the hardware.
Definition: NovintDevice.h:183
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
void setPositionScale(double scale)
Sets the position scale for this device.
Definition: NovintDevice.cpp:134
virtual bool is7DofDevice() const
Query if this object represents a 7 degree of freedom hardware device.
Definition: NovintDevice.cpp:168
void setAntigrav(Math::Vector3d antigrav)
Set a constant force that gets added to all forces sent to the hardware.
Definition: NovintDevice.cpp:187
bool getSerialNumber(std::string *serialNumber) const
Gets the serial number used to register this device with the hardware library.
Definition: NovintDevice.cpp:76
bool m_7DofDevice
True if the device is 7Dof, false if the device is 3Dof.
Definition: NovintDevice.h:180
void setYawOffset(double yawOffset)
Set constant offset for yaw.
Definition: NovintDevice.cpp:225
A class that manages Novint Falcon devices.
Definition: NovintScaffold.h:37
void set7DofDevice(bool val)
Sets whether or not this is supposed to be a 7Dof device.
Definition: NovintDevice.cpp:162
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
double getToolDofOffset() const
Definition: NovintDevice.cpp:250
void setPitchOffset(double pitchOffset)
Set constant offset for pitch.
Definition: NovintDevice.cpp:235
double getYawOffset() const
Definition: NovintDevice.cpp:220
void setSerialNumber(const std::string &serialNumber)
Sets the serial number used to register this device with the hardware library.
Definition: NovintDevice.cpp:66
A class implementing the communication with a Novint Falcon device.
Definition: NovintDevice.h:69
bool getInitializationName(std::string *initializationName) const
Gets the name used to register this device with the hardware library.
Definition: NovintDevice.cpp:96
double getRollOffset() const
Definition: NovintDevice.cpp:240
bool isInitialized() const override
Definition: NovintDevice.cpp:129
Math::Vector3d m_antigrav
The anti-gravity force in Newtons.
Definition: NovintDevice.h:186
void setToolDofOffset(double toolDofOffset)
Set constant offset for tool DOF.
Definition: NovintDevice.cpp:255
double getPitchOffset() const
Definition: NovintDevice.cpp:230
void setRollOffset(double rollOffset)
Set constant offset for roll.
Definition: NovintDevice.cpp:245
NovintDevice(const std::string &name)
Constructor.
Definition: NovintDevice.cpp:31
A class that implements some common management code on top of the DeviceInterface.
Definition: CommonDevice.h:35
double getOrientationScale() const
Gets the orientation scale for this device.
Definition: NovintDevice.cpp:157
virtual ~NovintDevice()
Destructor.
Definition: NovintDevice.cpp:58
void setInitializationName(const std::string &initializationName)
Sets the name used to register this device with the hardware library.
Definition: NovintDevice.cpp:86
void setMaxForce(double force)
Set the maximum force that can be sent to the device.
Definition: NovintDevice.cpp:173
double m_yawOffset
Definition: NovintDevice.h:190
double getPositionScale() const
Gets the position scale for this device.
Definition: NovintDevice.cpp:143
Math::Vector3d getAntigrav() const
Definition: NovintDevice.cpp:195
double getMaxForce() const
Definition: NovintDevice.cpp:182
bool initialize() override
Fully initialize the device.
Definition: NovintDevice.cpp:106