Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE const std::string &VrpnClient::
18get_server_name() const {
19 return _server_name;
20}
21
22/**
23 * Little inline function to convert a struct timeval to only seconds
24 */
25INLINE double VrpnClient::
26convert_to_secs(struct timeval msg_time) {
27 return (double)(msg_time.tv_sec) + (double)msg_time.tv_usec * 0.000001;
28}
29
30
31
32
33#if 0
34
35/**
36 *
37 */
38INLINE VrpnClient::
39VrpnClient(const std::string &server) :
40 ClientBase(server)
41{
42 _connection = vrpn_get_connection_by_name(server.c_str());
43}
44
45/**
46 * Stores the latest position information as sent by the tracker (for the
47 * particular sensor we have interest in)
48 */
49INLINE void VrpnClient::
50tracker_position(const std::string &tracker, const vrpn_TRACKERCB info) {
51 double ptime = convert_to_secs(info.msg_time);
52 LPoint3 pos(info.pos[0], info.pos[1], info.pos[2]);
53 LVector4 pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]);
54
55 push_tracker_position(tracker, info.sensor, ptime, pos, pquat);
56}
57
58/**
59 * Stores the latest velocity information as sent by the tracker (for the
60 * particular sensor we have interest in)
61 */
62INLINE void VrpnClient::
63tracker_velocity(const std::string &tracker, const vrpn_TRACKERVELCB info) {
64 double vtime = convert_to_secs(info.msg_time);
65 LPoint3 vel(info.vel[0], info.vel[1], info.vel[2]);
66 LVector4 vquat(info.vel_quat[0], info.vel_quat[1],
67 info.vel_quat[2], info.vel_quat[3]);
68 PN_stdfloat dt = info.vel_quat_dt;
69
70 push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt);
71}
72/**
73 * Stores the latest acceleration information as sent by the tracker (for the
74 * particular sensor we have interest in)
75 */
76INLINE void VrpnClient::
77tracker_acceleration(const std::string &tracker, const vrpn_TRACKERACCCB info) {
78 double atime = convert_to_secs(info.msg_time);
79 LPoint3 acc(info.acc[0], info.acc[1], info.acc[2]);
80 LVector4 aquat(info.acc_quat[0], info.acc_quat[1],
81 info.acc_quat[2], info.acc_quat[3]);
82 PN_stdfloat dt = info.acc_quat_dt;
83
84 push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt);
85}
86
87/**
88 * Stores the latest information as sent by the analog device
89 */
90INLINE void VrpnClient::
91analog(const std::string &analog, const vrpn_ANALOGCB info) {
92 double atime = convert_to_secs(info.msg_time);
93
94 push_analog(analog, atime, info.channel, info.num_channel);
95}
96
97/**
98 * Stores the latest button pressed information as sent by the button
99 */
100INLINE void VrpnClient::
101button(const std::string &button, const vrpn_BUTTONCB info) {
102 double btime = convert_to_secs(info.msg_time);
103
104 push_button(button, btime, info.button, info.state);
105}
106
107/**
108 * Stores the latest change information as sent by the dial
109 */
110INLINE void VrpnClient::
111dial(const std::string &dial, const vrpn_DIALCB info) {
112 double dtime = convert_to_secs(info.msg_time);
113
114 push_dial(dial, dtime, info.dial, info.change);
115}
116
117#endif
An abstract base class for a family of client device interfaces–including trackers,...
Definition clientBase.h:43
static double convert_to_secs(struct timeval msg_time)
Little inline function to convert a struct timeval to only seconds.
Definition vrpnClient.I:26
const std::string & get_server_name() const
Returns the name of the server as passed to the VrpnClient constructor.
Definition vrpnClient.I:18