NovintScaffold.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_NOVINT_NOVINTSCAFFOLD_H
17 #define SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
18 
19 #include <memory>
20 #include <string>
21 
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 
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 
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 
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
Definition: CompoundShapeToGraphics.cpp:29
bool updateDeviceInput(DeviceData *info)
Updates the device information for a single device&#39;s input.
Definition: NovintScaffold.cpp:698
Definition: NovintScaffold.cpp:255
bool unregisterDevice(const NovintDevice *device)
Unregisters the specified device object.
Definition: NovintScaffold.cpp:549
bool updateDeviceOutput(DeviceData *info, bool pulledOutput)
Updates the device information for a single device&#39;s output.
Definition: NovintScaffold.cpp:661
bool registerDevice(NovintDevice *device)
Registers the specified device object, and starts the servo loop if necessary.
Definition: NovintScaffold.cpp:489
static std::shared_ptr< NovintScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all NovintDevice and Novint7DofDevice instances.
Definition: NovintScaffold.cpp:1315
Definition: NovintScaffold.cpp:113
NovintScaffold & operator=(const NovintScaffold &)
A class that manages Novint Falcon devices.
Definition: NovintScaffold.h:37
std::shared_ptr< NovintScaffold::Handle > findHandleByInitializationName(const std::string &initializationName)
Get the Handle associated with an initialization name, if any.
Definition: NovintScaffold.cpp:575
bool initializeDeviceState(DeviceData *info)
Initializes a single device, creating the necessary HDAL resources.
Definition: NovintScaffold.cpp:635
Definition: NovintScaffold.cpp:358
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: NovintScaffold.h:181
A class implementing the communication with a Novint Falcon device.
Definition: NovintDevice.h:69
void setPositionScale(const NovintDevice *device, double scale)
Sets the position scale for this device.
Definition: NovintScaffold.cpp:1285
A collection of NamedData objects.
Definition: DataGroup.h:68
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: NovintScaffold.cpp:1270
bool enforceGravityCompensation(const DeviceData *info, bool gravityCompensationState)
Attempts to force the gravity compensation flag for the current device to the specified value...
Definition: NovintScaffold.cpp:1219
void setInputData(DeviceData *info)
Sets the input DataGroup, which will be pushed to the InputComponent.
Definition: NovintScaffold.cpp:1031
~NovintScaffold()
Destructor.
Definition: NovintScaffold.cpp:460
bool createAllHandles()
Creates a NovintScaffold::Handle for each device connected when the first registerDevice is called...
Definition: NovintScaffold.cpp:1045
void calculateForceAndTorque(DeviceData *info)
Calculates forces, and torques if the device is a 7Dof, and sends them to the HDAL.
Definition: NovintScaffold.cpp:852
void runHapticFrame()
Executes the operations for a single haptic frame.
Definition: NovintScaffold.cpp:1138
Definition: NovintScaffold.cpp:191
NovintScaffold()
Constructor.
Definition: NovintScaffold.cpp:413
bool getGravityCompensation(const DeviceData *info, bool *gravityCompensationState)
Gets the gravity compensation flag for the current device.
Definition: NovintScaffold.cpp:1185
void setOrientationScale(const NovintDevice *device, double scale)
Sets the orientation scale for this device.
Definition: NovintScaffold.cpp:1300
void destroyAllHandles()
Destroys all the initialized handles.
Definition: NovintScaffold.cpp:1096
void checkDeviceHoming(DeviceData *info)
Checks whether a device has been homed.
Definition: NovintScaffold.cpp:812
bool setGravityCompensation(const DeviceData *info, bool gravityCompensationState)
Sets the gravity compensation flag for the current device, unless it&#39;s already set as desired...
Definition: NovintScaffold.cpp:1257
std::map< std::string, std::string > getNameMap()
Gets the map from name to serial number.
Definition: NovintScaffold.cpp:1118
bool storeHandleIfValid(const std::shared_ptr< Handle > &handle, const std::string &serial)
Store the handle if it is valid.
Definition: NovintScaffold.cpp:1105