vrpn 07.36
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Tracker_Filter.h
Go to the documentation of this file.
1
12
13#pragma once
14
15// Internal Includes
16#include "quat.h" // for q_vec_type
17#include "vrpn_Tracker.h" // for vrpn_Tracker
18#include "vrpn_OneEuroFilter.h"
19#include <string>
20
29
31 public:
32 // name is the name that the filtered reports go out under
33 // trackercon is the server connection to use to send filtered reports on
34 // listen_tracker_name is the name of the tracker we listen to to filter
35 // If the tracker should use the server connection, then put * in
36 // front of the name.
37 // channels tells how many channels from the listening tracker to
38 // filter (reports on other channels are ignored by this tracker)
39 // The other parameters are passed to each One-Euro filter.
40 vrpn_Tracker_FilterOneEuro(const char * name, vrpn_Connection * trackercon,
41 const char *listen_tracker_name,
42 unsigned channels, vrpn_float64 vecMinCutoff = 1.15,
43 vrpn_float64 vecBeta = 0.5, vrpn_float64 vecDerivativeCutoff = 1.2,
44 vrpn_float64 quatMinCutoff = 1.5, vrpn_float64 quatBeta = 0.5,
45 vrpn_float64 quatDerivativeCutoff = 1.2);
47
48 virtual void mainloop();
49
50 private:
51 int d_channels; // How many channels on our tracker?
52 vrpn_OneEuroFilterVec *d_filters; // Set of position filters, one/channel
53 vrpn_OneEuroFilterQuat *d_qfilters; // Set of orientation filters, one/channel
54 struct timeval *d_last_report_times; // Last time of report for each tracker.
55 vrpn_Tracker_Remote *d_listen_tracker; // Tracker we get our reports from
56
57 // Callback handler to deal with getting messages from the tracker we're
58 // listening to. It filters them and then sends them on.
59 static void VRPN_CALLBACK handle_tracker_update(void *userdata, const vrpn_TRACKERCB info);
60};
61
62
64// of the specified sensors from the specified tracker. If there are no orientation
65// velocity reports, use the two most-recent poses to estimate angular velocity and
66// use that to predict.
67// Note: This class does not try to listen for angular acceleration.
68// Note: This class does not try to forward-predict position, it leaves that
69// part of the tracker message alone.
70
72{
73 public:
74
76 std::string myName //< Name of the tracking device we're exposing
77 , vrpn_Connection *c //< Connection to use to send reports on
78 , std::string origTrackerName //< Name of tracker to predict (*Name for one using our connection, Name@URL for one we should connect to)
79 , vrpn_int32 numSensors = 1 //< How many sensors to predict for?
80 , vrpn_float64 predictionTime = 1.0 / 60.0 //< How far to predict into the future?
81 , bool estimateVelocity = true //< Should we estimate angular velocity if we don't get it?
82 //< If false, this is basically just a pass-through filter, but estimating velocity can be choppy.
83 );
84
86
87 // Handle ping/pong requests.
88 void mainloop();
89
91 // prints an error message and returns an integer indicating what happened on failure.
92 static int test(void);
93
94 protected:
95
96 vrpn_float64 d_predictionTime; //< How far ahead to predict rotation
97 vrpn_int32 d_numSensors; //< How many sensors to predict for?
98 vrpn_Tracker_Remote *d_origTracker; //< Original tracker we're predicting for
99
100 typedef struct {
101 bool d_receivedAngularVelocityReport; //< If we get these, we don't estimate them
102 vrpn_float64 d_rotationAmount[4]; //< How far did we rotate in the specified interval
103 double d_rotationInterval; //< Interval over which we rotated
104 vrpn_float64 d_lastPosition[3]; //< What was our last reported position?
105 vrpn_float64 d_lastOrientation[4]; //< What was our last orientation?
106 struct timeval d_lastReportTime; //< When did we receive it?
108 vrpn_vector<RotationState> d_rotationStates; //< State of rotation of each sensor.
109
112 const vrpn_TRACKERCB info);
114 const vrpn_TRACKERVELCB info);
115
117 // prediction in the future from the original message by the prediction
118 // interval.
119 void sendNewPrediction(vrpn_int32 sensor);
120
122};
123
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Generic connection class not specific to the transport mechanism.
void sendNewPrediction(vrpn_int32 sensor)
Send a prediction based on the time of the new information; date the.
vrpn_Tracker_DeadReckoning_Rotation(std::string myName, vrpn_Connection *c, std::string origTrackerName, vrpn_int32 numSensors=1, vrpn_float64 predictionTime=1.0/60.0, bool estimateVelocity=true)
static void VRPN_CALLBACK handle_tracker_report(void *userdata, const vrpn_TRACKERCB info)
Static callback handler for tracker reports and tracker velocity reports.
static void VRPN_CALLBACK handle_tracker_velocity_report(void *userdata, const vrpn_TRACKERVELCB info)
vrpn_vector< RotationState > d_rotationStates
static int test(void)
Test the class to make sure it functions as it should. Returns 0 on success,.
vrpn_Tracker_FilterOneEuro(const char *name, vrpn_Connection *trackercon, const char *listen_tracker_name, unsigned channels, vrpn_float64 vecMinCutoff=1.15, vrpn_float64 vecBeta=0.5, vrpn_float64 vecDerivativeCutoff=1.2, vrpn_float64 quatMinCutoff=1.5, vrpn_float64 quatBeta=0.5, vrpn_float64 quatDerivativeCutoff=1.2)
vrpn_Tracker_Server(const char *name, vrpn_Connection *c, vrpn_int32 sensors=1)
vrpn_Tracker(const char *name, vrpn_Connection *c=NULL, const char *tracker_cfg_file_name=NULL)
#define VRPN_API
#define VRPN_CALLBACK
Header file that completely implements a direction and orientation filter on tracking reports; it doe...
vrpn_OneEuroFilter< vrpn_QuatFilterable > vrpn_OneEuroFilterQuat
vrpn_OneEuroFilter vrpn_OneEuroFilterVec