Ejemplo n.º 1
0
void vrpn_IMU_SimpleCombiner::mainloop()
{
  // Call generic server mainloop, since we are a server
  server_mainloop();

  // Mainloop() all of the analogs that are defined and the button
  // so that we will get all of the values fresh.
  if (d_acceleration.ana != NULL) { d_acceleration.ana->mainloop(); }
  if (d_rotational_vel.ana != NULL) { d_rotational_vel.ana->mainloop(); }
  if (d_magnetometer.ana != NULL) { d_magnetometer.ana->mainloop(); }

  // Update the matrix based on the change in time since the last
  // update and the current values.
  struct timeval	now;
  vrpn_gettimeofday(&now, NULL);
  double delta_t = vrpn_TimevalDurationSeconds(now, d_prev_update_time);
  update_matrix_based_on_values(delta_t);
  d_prev_update_time = now;

  // See if it has been long enough since our last report.
  // If so, generate a new one.
  double interval = vrpn_TimevalDurationSeconds(now, d_prevtime);
  if (interval >= d_update_interval) {

    // pack and deliver tracker report with info from the current matrix;
    if (d_connection) {
      char	msgbuf[1000];
      int	len = encode_to(msgbuf);
      if (d_connection->pack_message(len, vrpn_Tracker::timestamp,
        position_m_id, d_sender_id, msgbuf,
        vrpn_CONNECTION_LOW_LATENCY)) {
        fprintf(stderr, "vrpn_IMU_SimpleCombiner: "
          "cannot write pose message: tossing\n");
      }
      len = encode_vel_to(msgbuf);
      if (d_connection->pack_message(len, vrpn_Tracker::timestamp,
        velocity_m_id, d_sender_id, msgbuf,
        vrpn_CONNECTION_LOW_LATENCY)) {
        fprintf(stderr, "vrpn_IMU_SimpleCombiner: "
          "cannot write velocity message: tossing\n");
      }
    } else {
      fprintf(stderr, "vrpn_IMU_SimpleCombiner: "
        "No valid connection\n");
    }

    // We just sent a report, so reset the time
    d_prevtime = now;
  }
}
Ejemplo n.º 2
0
int vrpn_Poser_Remote::client_send_pose_velocity_relative() 
{
    char msgbuf[1000];
    vrpn_int32 len;

    // Pack velocity delta
    len = encode_vel_to(msgbuf);
    if (d_connection->pack_message(len, p_timestamp,
        req_velocity_relative_m_id, d_sender_id, msgbuf,
        vrpn_CONNECTION_LOW_LATENCY)) {
        fprintf(stderr, "vrpn_Poser_Remote: can't write a message: tossing\n");
        return -1;
    }

    return 0;
}
Ejemplo n.º 3
0
void vrpn_Tracker_Crossbow::send_report(void) {
    // Send the message on the connection
    if (d_connection) {
		char msgbuf[1000];
		int	len = encode_to(msgbuf);
		if (d_connection->pack_message(len, timestamp, position_m_id, d_sender_id, msgbuf, vrpn_CONNECTION_LOW_LATENCY)) {
			fprintf(stderr,"Tracker: cannot write message: tossing\n");
		}

		len = encode_acc_to(msgbuf);
		if (d_connection->pack_message(len, timestamp, accel_m_id, d_sender_id, msgbuf, vrpn_CONNECTION_LOW_LATENCY)) {
			fprintf(stderr,"Tracker: cannot write message: tossing\n");
		}

		len = encode_vel_to(msgbuf);
		if (d_connection->pack_message(len, timestamp, velocity_m_id, d_sender_id, msgbuf, vrpn_CONNECTION_LOW_LATENCY)) {
			fprintf(stderr,"Tracker: cannot write message: tossing\n");
		}
    } else {
	    fprintf(stderr,"Tracker: No valid connection\n");
    }
}