opensurgsim
NovintScaffold.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_NOVINTSCAFFOLD_H
17 #define SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/DataStructures/DataGroup.h"
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 
29 class NovintDevice;
30 
38 {
39 public:
42 
45 
49  static std::shared_ptr<NovintScaffold> getOrCreateSharedInstance();
50 
51 private:
52  NovintScaffold(const NovintScaffold&) /*= delete*/;
53  NovintScaffold& operator=(const NovintScaffold&) /*= delete*/;
54 
56  struct StateData;
58  struct DeviceData;
60  class Callback;
62  class Handle;
63 
64  friend class NovintDevice;
65 
71  bool registerDevice(NovintDevice* device);
72 
78  bool unregisterDevice(const NovintDevice* device);
79 
83  bool initializeDeviceState(DeviceData* info);
84 
88  std::shared_ptr<NovintScaffold::Handle> findHandleByInitializationName(const std::string& initializationName);
89 
93  bool updateDeviceInput(DeviceData* info);
94 
99  bool updateDeviceOutput(DeviceData* info, bool pulledOutput);
100 
105  void checkDeviceHoming(DeviceData* info);
106 
117  void calculateForceAndTorque(DeviceData* info);
118 
121  void setInputData(DeviceData* info);
122 
125  std::map<std::string, std::string> getNameMap();
126 
129  bool createAllHandles();
130 
132  void destroyAllHandles();
133 
136  bool storeHandleIfValid(const std::shared_ptr<Handle>& handle, const std::string& serial);
137 
140  void runHapticFrame();
141 
146  bool getGravityCompensation(const DeviceData* info, bool* gravityCompensationState);
147 
159  bool enforceGravityCompensation(const DeviceData* info, bool gravityCompensationState);
160 
165  bool setGravityCompensation(const DeviceData* info, bool gravityCompensationState);
166 
168  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
169 
173  void setPositionScale(const NovintDevice* device, double scale);
174 
178  void setOrientationScale(const NovintDevice* device, double scale);
179 
181  std::unique_ptr<StateData> m_state;
182 };
183 
184 }; // namespace Devices
185 }; // namespace SurgSim
186 
187 #endif // SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definition: NovintScaffold.cpp:255
static std::shared_ptr< NovintScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all NovintDevice and Novint7DofDevice instances.
Definition: NovintScaffold.cpp:1310
Definition: NovintScaffold.cpp:113
A class that manages Novint Falcon devices.
Definition: NovintScaffold.h:37
Definition: NovintScaffold.cpp:361
A class implementing the communication with a Novint Falcon device.
Definition: NovintDevice.h:69
A collection of NamedData objects.
Definition: DataGroup.h:68
~NovintScaffold()
Destructor.
Definition: NovintScaffold.cpp:463
Definition: NovintScaffold.cpp:191
NovintScaffold()
Constructor.
Definition: NovintScaffold.cpp:416