66 fprintf(stderr,
"Quat: %lf, %lf, %lf, %lf\n",
p_quat[0],
p_quat[1],
73 fprintf(stderr,
"Quat: %lf, %lf, %lf, %lf\n",
p_vel_quat[0],
83 d_connection->register_message_type(
"vrpn_Poser Request Pos_Quat");
85 "vrpn_Poser Request Relative Pos_Quat");
87 d_connection->register_message_type(
"vrpn_Poser Request Velocity");
89 "vrpn_Poser Request Relative Velocity");
133 return 1000 - buflen;
156 return 1000 - buflen;
160 const vrpn_float64 quaternion[4])
172 const vrpn_float64 position_delta[3],
173 const vrpn_float64 quaternion[4])
180 p_pos[0] += position_delta[0];
181 p_pos[1] += position_delta[1];
182 p_pos[2] += position_delta[2];
187 const vrpn_float64 velocity[3],
188 const vrpn_float64 quaternion[4],
189 const vrpn_float64 interval)
204 const timeval t,
const vrpn_float64 velocity_delta[3],
205 const vrpn_float64 quaternion[4],
const vrpn_float64 interval_delta)
212 p_vel[0] += velocity_delta[0];
213 p_vel[1] += velocity_delta[1];
214 p_vel[2] += velocity_delta[2];
231 fprintf(stderr,
"vrpn_Poser_Server: No connection\n");
238 fprintf(stderr,
"vrpn_Poser_Server: can't register position handler\n");
249 "vrpn_Poser_Server: can't register relative position handler\n");
256 fprintf(stderr,
"vrpn_Poser_Server: can't register velocity handler\n");
265 fprintf(stderr,
"vrpn_Poser_Server: can't register velocity handler\n");
280 const char* params = (p.
buffer);
286 fprintf(stderr,
"vrpn_Poser_Server: change message payload error\n");
287 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
288 static_cast<unsigned long>(7 *
sizeof(vrpn_float64)));
293 for (i = 0; i < 3; i++) {
296 for (i = 0; i < 4; i++) {
301 for (i = 0; i < 3; i++) {
325 const char* params = (p.
buffer);
330 fprintf(stderr,
"vrpn_Poser_Server: change message payload error\n");
331 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
332 static_cast<unsigned long>(7 *
sizeof(vrpn_float64)));
337 vrpn_float64 dp[3], dq[4];
338 for (i = 0; i < 3; i++) {
341 for (i = 0; i < 4; i++) {
346 for (i = 0; i <= 2; i++)
347 me->
p_pos[i] += dp[i];
351 for (i = 0; i < 3; i++) {
363 memcpy(cp.
pos, dp,
sizeof(cp.
pos));
364 memcpy(cp.
quat, dq,
sizeof(cp.
quat));
375 const char* params = (p.
buffer);
380 fprintf(stderr,
"vrpn_Poser_Server: velocity message payload error\n");
381 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
382 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
387 for (i = 0; i < 3; i++) {
390 for (i = 0; i < 4; i++) {
396 for (i = 0; i < 3; i++) {
411 const char* params = (p.
buffer);
416 fprintf(stderr,
"vrpn_Poser_Server: velocity message payload error\n");
417 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
418 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
423 vrpn_float64 dv[3], dq[4], di;
424 for (i = 0; i < 3; i++) {
427 for (i = 0; i < 4; i++) {
433 for (i = 0; i < 2; i++)
434 me->
p_vel[i] += dv[i];
439 for (i = 0; i < 3; i++) {
464 fprintf(stderr,
"vrpn_Poser_Remote: No connection\n");
489 const vrpn_float64 position[3],
490 const vrpn_float64 quaternion[4])
497 fprintf(stderr,
"vrpn_Poser_Remote: request_pose failed\n");
505 const struct timeval t,
const vrpn_float64 position_delta[3],
506 const vrpn_float64 quaternion[4])
513 fprintf(stderr,
"vrpn_Poser_Remote: request_pose_relative failed\n");
521 const vrpn_float64 velocity[3],
522 const vrpn_float64 quaternion[4],
523 const vrpn_float64 interval)
530 fprintf(stderr,
"vrpn_Poser_Remote: request_pose_velocity failed\n");
538 const struct timeval t,
const vrpn_float64 velocity_delta[3],
539 const vrpn_float64 quaternion[4],
const vrpn_float64 interval_delta)
547 "vrpn_Poser_Remote: request_pose_velocity_relative failed\n");
564 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
581 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
598 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
615 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
int request_pose_velocity(const struct timeval t, const vrpn_float64 velocity[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval)
virtual int client_send_pose_velocity_relative()
virtual int client_send_pose_relative()
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual ~vrpn_Poser_Remote(void)
int request_pose_velocity_relative(const struct timeval t, const vrpn_float64 velocity_delta[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval_delta)
virtual int client_send_pose()
virtual int client_send_pose_velocity()
int request_pose_relative(const struct timeval t, const vrpn_float64 position_delta[3], const vrpn_float64 quaternion[4])
int request_pose(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4])
vrpn_Poser_Remote(const char *name, vrpn_Connection *c=NULL)
static int VRPN_CALLBACK handle_relative_vel_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Poser_Server(const char *name, vrpn_Connection *c)
virtual void mainloop()
This function should be called each time through app mainloop.
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK handle_vel_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Callback_List< vrpn_POSERCB > d_callback_list
static int VRPN_CALLBACK handle_relative_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Callback_List< vrpn_POSERCB > d_relative_callback_list
vrpn_float64 p_pos_min[3]
vrpn_int32 req_velocity_relative_m_id
virtual void set_pose(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4])
vrpn_float64 p_pos_rot_max[3]
vrpn_float64 p_vel_min[3]
virtual int encode_vel_to(char *buf)
virtual void set_pose_velocity(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval)
vrpn_float64 p_pos_rot_min[3]
virtual ~vrpn_Poser(void)
virtual void set_pose_relative(const struct timeval t, const vrpn_float64 position_delta[3], const vrpn_float64 quaternion[4])
vrpn_float64 p_vel_rot_min[3]
vrpn_float64 p_vel_max[3]
vrpn_int32 req_position_relative_m_id
vrpn_float64 p_vel_quat[4]
vrpn_Poser(const char *name, vrpn_Connection *c=NULL)
vrpn_float64 p_vel_quat_dt
vrpn_float64 p_vel_rot_max[3]
vrpn_float64 p_pos_max[3]
virtual int encode_to(char *buf)
vrpn_int32 req_position_m_id
virtual void set_pose_velocity_relative(const struct timeval t, const vrpn_float64 velocity_delta[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval_delta)
struct timeval p_timestamp
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
vrpn_int32 req_velocity_m_id
This structure is what is passed to a vrpn_Connection message callback.
A structure for Call-Backs related to Vrpn Poser Server.
vrpn_float64 pos[3]
NOTE: I think since we have different routines for handling velocity and position poser requests,...
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
class VRPN_API vrpn_Connection
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
#define vrpn_gettimeofday