NovintScaffold.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
#define SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
#include <memory>
#include <string>
#include "SurgSim/DataStructures/DataGroup.h"
namespace SurgSim
{
namespace Devices
{
class NovintDevice;
class NovintScaffold
{
public:
NovintScaffold();
~NovintScaffold();
static std::shared_ptr<NovintScaffold> getOrCreateSharedInstance();
private:
NovintScaffold(const NovintScaffold&) /*= delete*/;
NovintScaffold& operator=(const NovintScaffold&) /*= delete*/;
struct StateData;
struct DeviceData;
class Callback;
class Handle;
friend class NovintDevice;
bool registerDevice(NovintDevice* device);
bool unregisterDevice(const NovintDevice* device);
bool initializeDeviceState(DeviceData* info);
std::shared_ptr<NovintScaffold::Handle> findHandleByInitializationName(const std::string& initializationName);
bool updateDeviceInput(DeviceData* info);
bool updateDeviceOutput(DeviceData* info, bool pulledOutput);
void checkDeviceHoming(DeviceData* info);
void calculateForceAndTorque(DeviceData* info);
void setInputData(DeviceData* info);
std::map<std::string, std::string> getNameMap();
bool createAllHandles();
void destroyAllHandles();
bool storeHandleIfValid(const std::shared_ptr<Handle>& handle, const std::string& serial);
void runHapticFrame();
bool getGravityCompensation(const DeviceData* info, bool* gravityCompensationState);
bool enforceGravityCompensation(const DeviceData* info, bool gravityCompensationState);
bool setGravityCompensation(const DeviceData* info, bool gravityCompensationState);
static SurgSim::DataStructures::DataGroup buildDeviceInputData();
void setPositionScale(const NovintDevice* device, double scale);
void setOrientationScale(const NovintDevice* device, double scale);
std::unique_ptr<StateData> m_state;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_NOVINT_NOVINTSCAFFOLD_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::NovintScaffold::updateDeviceInput
bool updateDeviceInput(DeviceData *info)
Updates the device information for a single device&#39;s input.
Definition: NovintScaffold.cpp:698
SurgSim::Devices::NovintScaffold::DeviceData
Definition: NovintScaffold.cpp:255
SurgSim::Devices::NovintScaffold::unregisterDevice
bool unregisterDevice(const NovintDevice *device)
Unregisters the specified device object.
Definition: NovintScaffold.cpp:549
SurgSim::Devices::NovintScaffold::updateDeviceOutput
bool updateDeviceOutput(DeviceData *info, bool pulledOutput)
Updates the device information for a single device&#39;s output.
Definition: NovintScaffold.cpp:661
SurgSim::Devices::NovintScaffold::registerDevice
bool registerDevice(NovintDevice *device)
Registers the specified device object, and starts the servo loop if necessary.
Definition: NovintScaffold.cpp:489
DataGroup.h
SurgSim::Devices::NovintScaffold::getOrCreateSharedInstance
static std::shared_ptr< NovintScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all NovintDevice and Novint7DofDevice instances.
Definition: NovintScaffold.cpp:1315
SurgSim::Devices::NovintScaffold::Handle
Definition: NovintScaffold.cpp:113
SurgSim::Devices::NovintScaffold::operator=
NovintScaffold & operator=(const NovintScaffold &)
SurgSim::Devices::NovintScaffold
A class that manages Novint Falcon devices.
Definition: NovintScaffold.h:37
SurgSim::Devices::NovintScaffold::findHandleByInitializationName
std::shared_ptr< NovintScaffold::Handle > findHandleByInitializationName(const std::string &initializationName)
Get the Handle associated with an initialization name, if any.
Definition: NovintScaffold.cpp:575
SurgSim::Devices::NovintScaffold::initializeDeviceState
bool initializeDeviceState(DeviceData *info)
Initializes a single device, creating the necessary HDAL resources.
Definition: NovintScaffold.cpp:635
SurgSim::Devices::NovintScaffold::StateData
Definition: NovintScaffold.cpp:358
SurgSim::Devices::NovintScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: NovintScaffold.h:181
SurgSim::Devices::NovintDevice
A class implementing the communication with a Novint Falcon device.
Definition: NovintDevice.h:69
SurgSim::Devices::NovintScaffold::setPositionScale
void setPositionScale(const NovintDevice *device, double scale)
Sets the position scale for this device.
Definition: NovintScaffold.cpp:1285
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Devices::NovintScaffold::buildDeviceInputData
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: NovintScaffold.cpp:1270
SurgSim::Devices::NovintScaffold::enforceGravityCompensation
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
SurgSim::Devices::NovintScaffold::setInputData
void setInputData(DeviceData *info)
Sets the input DataGroup, which will be pushed to the InputComponent.
Definition: NovintScaffold.cpp:1031
SurgSim::Devices::NovintScaffold::~NovintScaffold
~NovintScaffold()
Destructor.
Definition: NovintScaffold.cpp:460
SurgSim::Devices::NovintScaffold::createAllHandles
bool createAllHandles()
Creates a NovintScaffold::Handle for each device connected when the first registerDevice is called...
Definition: NovintScaffold.cpp:1045
SurgSim::Devices::NovintScaffold::calculateForceAndTorque
void calculateForceAndTorque(DeviceData *info)
Calculates forces, and torques if the device is a 7Dof, and sends them to the HDAL.
Definition: NovintScaffold.cpp:852
SurgSim::Devices::NovintScaffold::runHapticFrame
void runHapticFrame()
Executes the operations for a single haptic frame.
Definition: NovintScaffold.cpp:1138
SurgSim::Devices::NovintScaffold::Callback
Definition: NovintScaffold.cpp:191
SurgSim::Devices::NovintScaffold::NovintScaffold
NovintScaffold()
Constructor.
Definition: NovintScaffold.cpp:413
SurgSim::Devices::NovintScaffold::getGravityCompensation
bool getGravityCompensation(const DeviceData *info, bool *gravityCompensationState)
Gets the gravity compensation flag for the current device.
Definition: NovintScaffold.cpp:1185
SurgSim::Devices::NovintScaffold::setOrientationScale
void setOrientationScale(const NovintDevice *device, double scale)
Sets the orientation scale for this device.
Definition: NovintScaffold.cpp:1300
SurgSim::Devices::NovintScaffold::destroyAllHandles
void destroyAllHandles()
Destroys all the initialized handles.
Definition: NovintScaffold.cpp:1096
SurgSim::Devices::NovintScaffold::checkDeviceHoming
void checkDeviceHoming(DeviceData *info)
Checks whether a device has been homed.
Definition: NovintScaffold.cpp:812
SurgSim::Devices::NovintScaffold::setGravityCompensation
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
SurgSim::Devices::NovintScaffold::getNameMap
std::map< std::string, std::string > getNameMap()
Gets the map from name to serial number.
Definition: NovintScaffold.cpp:1118
SurgSim::Devices::NovintScaffold::storeHandleIfValid
bool storeHandleIfValid(const std::shared_ptr< Handle > &handle, const std::string &serial)
Store the handle if it is valid.
Definition: NovintScaffold.cpp:1105