SixenseThread.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_SIXENSE_SIXENSETHREAD_H
#define SURGSIM_DEVICES_SIXENSE_SIXENSETHREAD_H
#include <memory>
#include <string>
#include "SurgSim/Framework/BasicThread.h"
namespace SurgSim
{
namespace Devices
{
class SixenseScaffold;
class SixenseThread : public SurgSim::Framework::BasicThread
{
public:
explicit SixenseThread(SixenseScaffold* scaffold) :
BasicThread("Sixense thread"),
m_scaffold(scaffold)
{
setRate(120.0); // The Hydra runs at 60Hz, but running at 60Hz here could introduce up to 16.6ms extra latency
}
virtual ~SixenseThread();
protected:
bool doInitialize() override;
bool doStartUp() override;
bool doUpdate(double dt) override;
private:
SixenseScaffold* m_scaffold;
};
}; // namespace Devices
}; // namespace SurgSim
#endif // SURGSIM_DEVICES_SIXENSE_SIXENSETHREAD_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::SixenseScaffold
A class that manages Sixense devices, such as the Razer Hydra.
Definition: SixenseScaffold.h:35
SurgSim::Devices::SixenseThread::~SixenseThread
virtual ~SixenseThread()
Definition: SixenseThread.cpp:25
SurgSim::Devices::SixenseThread::SixenseThread
SixenseThread(SixenseScaffold *scaffold)
Definition: SixenseThread.h:36
SurgSim::Framework::BasicThread::setRate
void setRate(double val)
Set the update rate of the thread.
Definition: BasicThread.h:103
SurgSim::Devices::SixenseThread::doInitialize
bool doInitialize() override
Definition: SixenseThread.cpp:35
SurgSim::Framework::BasicThread::BasicThread
BasicThread(const std::string &name="Unknown Thread")
Definition: BasicThread.cpp:31
SurgSim::Devices::SixenseThread::m_scaffold
SixenseScaffold * m_scaffold
Definition: SixenseThread.h:51
SurgSim::Devices::SixenseThread::doStartUp
bool doStartUp() override
Definition: SixenseThread.cpp:40
SurgSim::Devices::SixenseThread
A class implementing the thread context for sampling Sixense devices.
Definition: SixenseThread.h:33
SurgSim::Framework::BasicThread
Basic thread implementation, tries to maintain a constant rate, supplies startup an initialization...
Definition: BasicThread.h:48
SurgSim::Devices::SixenseThread::doUpdate
bool doUpdate(double dt) override
Implementation of actual work function for this thread, this has a default implementation to handle d...
Definition: SixenseThread.cpp:29
BasicThread.h