Panda3D
vrpnClient.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file vrpnClient.I
10  * @author jason
11  * @date 2000-08-04
12  */
13 
14 /**
15  * Returns the name of the server as passed to the VrpnClient constructor.
16  */
17 INLINE const std::string &VrpnClient::
18 get_server_name() const {
19  return _server_name;
20 }
21 
22 /**
23  * Returns true if everything seems to be kosher with the server (even if
24  * there is no connection), or false otherwise.
25  */
26 INLINE bool VrpnClient::
27 is_valid() const {
28  return (_connection->doing_okay() != 0);
29 }
30 
31 /**
32  * Returns true if the connection is established successfully, false
33  * otherwise.
34  */
35 INLINE bool VrpnClient::
36 is_connected() const {
37  return (_connection->connected() != 0);
38 }
39 
40 
41 /**
42  * Little inline function to convert a struct timeval to only seconds
43  */
44 INLINE double VrpnClient::
45 convert_to_secs(struct timeval msg_time) {
46  return (double)(msg_time.tv_sec) + (double)msg_time.tv_usec * 0.000001;
47 }
48 
49 
50 
51 
52 #if 0
53 
54 /**
55  *
56  */
57 INLINE VrpnClient::
58 VrpnClient(const std::string &server) :
59  ClientBase(server)
60 {
61  _connection = vrpn_get_connection_by_name(server.c_str());
62 }
63 
64 /**
65  * Stores the latest position information as sent by the tracker (for the
66  * particular sensor we have interest in)
67  */
68 INLINE void VrpnClient::
69 tracker_position(const std::string &tracker, const vrpn_TRACKERCB info) {
70  double ptime = convert_to_secs(info.msg_time);
71  LPoint3 pos(info.pos[0], info.pos[1], info.pos[2]);
72  LVector4 pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]);
73 
74  push_tracker_position(tracker, info.sensor, ptime, pos, pquat);
75 }
76 
77 /**
78  * Stores the latest velocity information as sent by the tracker (for the
79  * particular sensor we have interest in)
80  */
81 INLINE void VrpnClient::
82 tracker_velocity(const std::string &tracker, const vrpn_TRACKERVELCB info) {
83  double vtime = convert_to_secs(info.msg_time);
84  LPoint3 vel(info.vel[0], info.vel[1], info.vel[2]);
85  LVector4 vquat(info.vel_quat[0], info.vel_quat[1],
86  info.vel_quat[2], info.vel_quat[3]);
87  PN_stdfloat dt = info.vel_quat_dt;
88 
89  push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt);
90 }
91 /**
92  * Stores the latest acceleration information as sent by the tracker (for the
93  * particular sensor we have interest in)
94  */
95 INLINE void VrpnClient::
96 tracker_acceleration(const std::string &tracker, const vrpn_TRACKERACCCB info) {
97  double atime = convert_to_secs(info.msg_time);
98  LPoint3 acc(info.acc[0], info.acc[1], info.acc[2]);
99  LVector4 aquat(info.acc_quat[0], info.acc_quat[1],
100  info.acc_quat[2], info.acc_quat[3]);
101  PN_stdfloat dt = info.acc_quat_dt;
102 
103  push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt);
104 }
105 
106 /**
107  * Stores the latest information as sent by the analog device
108  */
109 INLINE void VrpnClient::
110 analog(const std::string &analog, const vrpn_ANALOGCB info) {
111  double atime = convert_to_secs(info.msg_time);
112 
113  push_analog(analog, atime, info.channel, info.num_channel);
114 }
115 
116 /**
117  * Stores the latest button pressed information as sent by the button
118  */
119 INLINE void VrpnClient::
120 button(const std::string &button, const vrpn_BUTTONCB info) {
121  double btime = convert_to_secs(info.msg_time);
122 
123  push_button(button, btime, info.button, info.state);
124 }
125 
126 /**
127  * Stores the latest change information as sent by the dial
128  */
129 INLINE void VrpnClient::
130 dial(const std::string &dial, const vrpn_DIALCB info) {
131  double dtime = convert_to_secs(info.msg_time);
132 
133  push_dial(dial, dtime, info.dial, info.change);
134 }
135 
136 #endif
bool is_connected() const
Returns true if the connection is established successfully, false otherwise.
Definition: vrpnClient.I:36
bool is_valid() const
Returns true if everything seems to be kosher with the server (even if there is no connection),...
Definition: vrpnClient.I:27
An abstract base class for a family of client device interfaces–including trackers,...
Definition: clientBase.h:43
const std::string & get_server_name() const
Returns the name of the server as passed to the VrpnClient constructor.
Definition: vrpnClient.I:18
static double convert_to_secs(struct timeval msg_time)
Little inline function to convert a struct timeval to only seconds.
Definition: vrpnClient.I:45