28 return (_connection->doing_okay() != 0);
37 return (_connection->connected() != 0);
46 return (
double)(msg_time.tv_sec) + (
double)msg_time.tv_usec * 0.000001;
58 VrpnClient(
const std::string &server) :
61 _connection = vrpn_get_connection_by_name(server.c_str());
68 INLINE
void VrpnClient::
69 tracker_position(
const std::string &tracker,
const vrpn_TRACKERCB info) {
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]);
74 push_tracker_position(tracker, info.sensor, ptime, pos, pquat);
81 INLINE
void VrpnClient::
82 tracker_velocity(
const std::string &tracker,
const vrpn_TRACKERVELCB info) {
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;
89 push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt);
95 INLINE
void VrpnClient::
96 tracker_acceleration(
const std::string &tracker,
const vrpn_TRACKERACCCB info) {
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;
103 push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt);
109 INLINE
void VrpnClient::
110 analog(
const std::string &analog,
const vrpn_ANALOGCB info) {
113 push_analog(analog, atime, info.channel, info.num_channel);
119 INLINE
void VrpnClient::
120 button(
const std::string &button,
const vrpn_BUTTONCB info) {
123 push_button(button, btime, info.button, info.state);
129 INLINE
void VrpnClient::
130 dial(
const std::string &dial,
const vrpn_DIALCB info) {
133 push_dial(dial, dtime, info.dial, info.change);
bool is_connected() const
Returns true if the connection is established successfully, false otherwise.
bool is_valid() const
Returns true if everything seems to be kosher with the server (even if there is no connection),...
An abstract base class for a family of client device interfaces–including trackers,...
const std::string & get_server_name() const
Returns the name of the server as passed to the VrpnClient constructor.
static double convert_to_secs(struct timeval msg_time)
Little inline function to convert a struct timeval to only seconds.