PST SDK 7.0.0.0-ebe6e713
Loading...
Searching...
No Matches
minimal.cpp
#include <thread>
#include <chrono>
#include "pstsdk_cpp.h"
/*
* Implementation of the PSTech::pstsdk::Listener class to receive tracking data.
* The OnTrackerData() callback function receives the data as soon as it becomes
* available and prints the tracking target pose to the command line.
*/
class MyListener : public PSTech::pstsdk::Listener
{
virtual void OnTrackerData(const PSTech::pstsdk::TrackerData& td) override
{
// Do something with the tracker data in td
}
public:
virtual ~MyListener() override
{
// Unregistering listener before destruction to prevent unwanted behavior
}
} listener;
int main(int argc, char *argv[])
{
// Implement error handling of PSTech::TrackerException exceptions to prevent
// improper PST Tracker shutdown on errors.
try
{
// Create an instance of the Tracker object using the default configuration path and file names.
#ifdef WIN32
#else
// On Linux, specify the type of grabber that needs to be used as the last parameter:
// "basler_ace" for PST HD or "basler_dart" for PST Pico
PSTech::pstsdk::Tracker pst("","config.cfg","models.db",argv[1]);
#endif
// Register the listener object to the tracker server.
// Start the tracker server.
pst.Start();
// Wait for 10 seconds, allowing for the detection of tracking targets.
std::this_thread::sleep_for(std::chrono::seconds(10));
}
catch (const PSTech::TrackerException &e)
{
// Do something with the error.
}
// Make sure that the connection to the PST Tracker is shut down properly.
return 0;
}
Definition TrackerExceptions.h:54
Abstract listener class for receiving tracking information and tracking mode updates.
Definition pstsdk_cpp.h:38
virtual void OnTrackerData(const TrackerData &data)
Callback function receiving tracking information from the tracker.
Definition pstsdk_cpp.h:49
Main PST SDK class implementing tracker communication.
Definition pstsdk_cpp.h:101
void Start()
Start tracking.
static void Shutdown()
Shutdown the tracking system, stopping tracking.
static void AddTrackerListener(Listener *listener)
Add a listener for receiving tracker data and tracking mode updates.
static void RemoveTrackerListener(Listener *listener)
Remove a listener for receiving tracker data and tracking mode updates.
Tracking information retrieved from tracker.
Definition PstTypes.h:173