vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Tracker_Filter.h
Go to the documentation of this file.
1
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#include <vector>
21
32 public:
33 // name is the name that the filtered reports go out under
34 // trackercon is the server connection to use to send filtered reports on
35 // listen_tracker_name is the name of the tracker we listen to to filter
36 // If the tracker should use the server connection, then put * in
37 // front of the name.
38 // channels tells how many channels from the listening tracker to
39 // filter (reports on other channels are ignored by this tracker)
40 // The other parameters are passed to each One-Euro filter.
41 vrpn_Tracker_FilterOneEuro(const char * name, vrpn_Connection * trackercon,
42 const char *listen_tracker_name,
43 unsigned channels, vrpn_float64 vecMinCutoff = 1.15,
44 vrpn_float64 vecBeta = 0.5, vrpn_float64 vecDerivativeCutoff = 1.2,
45 vrpn_float64 quatMinCutoff = 1.5, vrpn_float64 quatBeta = 0.5,
46 vrpn_float64 quatDerivativeCutoff = 1.2);
48
49 virtual void mainloop();
50
51 private:
52 int d_channels; // How many channels on our tracker?
53 vrpn_OneEuroFilterVec *d_filters; // Set of position filters, one/channel
54 vrpn_OneEuroFilterQuat *d_qfilters; // Set of orientation filters, one/channel
55 struct timeval *d_last_report_times; // Last time of report for each tracker.
56 vrpn_Tracker_Remote *d_listen_tracker; // Tracker we get our reports from
57
58 // Callback handler to deal with getting messages from the tracker we're
59 // listening to. It filters them and then sends them on.
60 static void VRPN_CALLBACK handle_tracker_update(void *userdata, const vrpn_TRACKERCB info);
61};
62
63
65// of the specified sensors from the specified tracker. If there are no orientation
66// velocity reports, use the two most-recent poses to estimate angular velocity and
67// use that to predict.
68// Note: This class does not try to listen for angular acceleration.
69// Note: This class does not try to forward-predict position, it leaves that
70// part of the tracker message alone.
71
73{
74 public:
75
77 std::string myName //< Name of the tracking device we're exposing
78 , vrpn_Connection *c //< Connection to use to send reports on
79 , std::string origTrackerName //< Name of tracker to predict (*Name for one using our connection, Name@URL for one we should connect to)
80 , vrpn_int32 numSensors = 1 //< How many sensors to predict for?
81 , vrpn_float64 predictionTime = 1.0 / 60.0 //< How far to predict into the future?
82 , bool estimateVelocity = true //< Should we estimate angular velocity if we don't get it?
83 //< If false, this is basically just a pass-through filter, but estimating velocity can be choppy.
84 );
85
87
88 // Handle ping/pong requests.
89 void mainloop();
90
92 // prints an error message and returns an integer indicating what happened on failure.
93 static int test(void);
94
95 protected:
96
97 vrpn_float64 d_predictionTime; //< How far ahead to predict rotation
98 vrpn_int32 d_numSensors; //< How many sensors to predict for?
99 vrpn_Tracker_Remote *d_origTracker; //< Original tracker we're predicting for
100
101 typedef struct {
102 bool d_receivedAngularVelocityReport; //< If we get these, we don't estimate them
103 vrpn_float64 d_rotationAmount[4]; //< How far did we rotate in the specified interval
104 double d_rotationInterval; //< Interval over which we rotated
105 vrpn_float64 d_lastPosition[3]; //< What was our last reported position?
106 vrpn_float64 d_lastOrientation[4]; //< What was our last orientation?
107 struct timeval d_lastReportTime; //< When did we receive it?
109 std::vector<RotationState> d_rotationStates; //< State of rotation of each sensor.
110
112 static void VRPN_CALLBACK handle_tracker_report(void *userdata,
113 const vrpn_TRACKERCB info);
114 static void VRPN_CALLBACK handle_tracker_velocity_report(void *userdata,
115 const vrpn_TRACKERVELCB info);
116
118 // prediction in the future from the original message by the prediction
119 // interval.
120 void sendNewPrediction(vrpn_int32 sensor);
121
123};
124
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.
Use angular velocity reports, if available, to predict the future orientation.
std::vector< RotationState > d_rotationStates
Tracker filter based on the one-Euro filter by Jan Ciger jan.ciger@reviatech.com
#define VRPN_API
#define VRPN_CALLBACK
Header file that completely implements a direction and orientation filter on tracking reports; it doe...