4#ifdef VRPN_INCLUDE_INTERSENSE
23#include <netinet/in.h>
33#define MAX_TIME_INTERVAL (5000000)
40 sprintf(msg,
"%s (Unknown series:", msg);
42 case ISD_PRECISION_SERIES:
43 sprintf(msg,
"%s (Precision series:", msg);
45 case ISD_INTERTRAX_SERIES:
46 sprintf(msg,
"%s (InterTrax series:", msg);
51 sprintf(msg,
"%s Unknown model)", msg);
55 sprintf(msg,
"%s IS300)", msg);
59 sprintf(msg,
"%s IS600)", msg);
63 sprintf(msg,
"%s IS900)", msg);
67 sprintf(msg,
"%s IS1200)", msg);
71 sprintf(msg,
"%s InterTrax)", msg);
75 sprintf(msg,
"%s InterTrax2)", msg);
78 case ISD_INTERTRAX_LS:
79 sprintf(msg,
"%s InterTrax LS)", msg);
82 case ISD_INTERTRAX_LC:
83 sprintf(msg,
"%s InterTrax LC)", msg);
87 sprintf(msg,
"%s InertiaCube2)", msg);
91 sprintf(msg,
"%s InertiaCube2 Pro)", msg);
95 sprintf(msg,
"%s InertiaCube3)", msg);
98 sprintf(msg,
"%s\n", msg);
103 int commPort,
const char *additional_reset_commands,
104 int is900_timestamps,
int reset_at_start) :
105vrpn_Tracker(name,c), do_is900_timestamps(is900_timestamps),
106m_reset_at_start(reset_at_start)
108#ifdef VRPN_INCLUDE_INTERSENSE
114 if (additional_reset_commands == NULL) {
122 for (i = 0; i < ISD_MAX_STATIONS; i++) {
128 m_Handle = ISD_OpenTracker(NULL, commPort, FALSE, FALSE);
132 sprintf(errStr,
"Failed to open tracker '%s' on COM%d: ISLIB_OpenTracker returned -1",name,commPort);
141 for (i = 0; i < ISD_MAX_STATIONS; i++) {
143 sprintf(errStr,
"Failed to reset sensor %d on tracker '%s' on COM%d",i, name,commPort);
156 fprintf(stderr,errStr);
160 fprintf(stderr,
"Intersense library not compiled into this version. Use Fastrak driver for IS-600/900 or recompile with VRPN_INCLUDE_INTERSENSE defined\n");
167#ifdef VRPN_INCLUDE_INTERSENSE
174 for (i = 0; i < ISD_MAX_STATIONS; i++) {
179 fprintf(stderr,
"vrpn_Tracker_InterSense::~vrpn_Tracker_InterSense(): delete failed\n");
188 fprintf(stderr,
"vrpn_Tracker_InterSense::~vrpn_Tracker_InterSense(): delete failed\n");
215 ISD_Boresight(
m_Handle, station+1,
true);
233 sprintf(errStr,
"Warning: Your tracker doesn't seem to support the quaternion format - couldn't set station config for Station%d. ",station+1);
248 sprintf(errStr,
"Warning: Your tracker doesn't seem to support the IS900 timestamps - couldn't set station config for Station%d. ",station+1);
259 sprintf(errStr,
"Warning: Your tracker doesn't seem to support the IS900 buttons/analogs - couldn't set station config for Station%d. ",station+1);
271#ifdef VRPN_INCLUDE_INTERSENSE
279 sprintf(errStr,
"InterSense: Failed to open tracker '%s' on COM%d: ISD_OpenTracker returned -1",
d_servicename,
m_CommPort);
280 fprintf(stderr,errStr);
298 for (i = 0; i < ISD_MAX_STATIONS; i++) {
308 printf(
" Intersense writing extended reset commands...\n");
311 sprintf(errStr,
"Warning: Your tracker failed executing the additional command string. ");
324 char clear_timestamp_cmd[] =
"MT\015MZ\015";
325 if(!ISD_SendScript(
m_Handle,clear_timestamp_cmd))
327 sprintf(errStr,
"Warning: Your tracker failed executing the additional command string. ");
342 fprintf(stderr,
"Intersense library not compiled into this version. Use Fastrak driver for IS-600/900 or recompile with VRPN_INCLUDE_INTERSENSE defined\n");
352#ifdef VRPN_INCLUDE_INTERSENSE
354 ISD_TRACKING_DATA_TYPE data;
357 if(ISD_GetTrackingData(
m_Handle,&data)) {
358 for(
int station=0;station<ISD_MAX_STATIONS;station++) {
359 if(data.Station[station].NewData == TRUE) {
371 vrpn_float32 read_time = data.Station[station].TimeStamp;
373 struct timeval delta_time;
376 delta_time.tv_sec = (long)(read_time / 1000);
377 read_time -= delta_time.tv_sec * 1000;
378 delta_time.tv_usec = (long)(read_time * 1000);
426 pos[0] = data.Station[station].Position[0];
427 pos[1] = data.Station[station].Position[1];
428 pos[2] = data.Station[station].Position[2];
431 d_quat[0] = data.Station[station].Quaternion[1];
432 d_quat[1] = data.Station[station].Quaternion[2];
433 d_quat[2] = data.Station[station].Quaternion[3];
434 d_quat[3] = data.Station[station].Quaternion[0];
442 q_from_euler(
d_quat, angles[0], angles[1], angles[2]);
462#ifdef VRPN_INCLUDE_INTERSENSE
470 fprintf(stderr,
"InterSense: cannot write message: tossing\n");
515 VRPN_MSG_WARNING(
"Tracking failed, trying to reset (try power cycle if more than 4 attempts made)");
533 if ( (sensor < 0) || (sensor >= ISD_MAX_STATIONS) ) {
564 double c0Min,
double c0Low,
double c0Hi,
double c0Max,
565 double c1Min,
double c1Low,
double c1Hi,
double c1Max)
568 if ( (sensor < 0) || (sensor >= ISD_MAX_STATIONS) ) {
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Makes public the protected base class function.
virtual void mainloop()
For this server, the user must normally call report() or report_changes() directly....
vrpn_int32 setNumChannels(vrpn_int32 sizeRequested)
Sets the size of the array; returns the size actually set. (May be clamped to vrpn_CHANNEL_MAX) This ...
vrpn_Connection * d_connection
Connection that this object talks to.
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...
char * d_servicename
Name of this device, not including the connection part.
int setChannelValue(int channel, double value)
This method should be used to set the value of a channel. It will be scaled and clipped as described ...
int setClipValues(int channel, double min, double lowzero, double highzero, double max)
Set the clipping values for the specified channel. min maps to -1, values between lowzero and highzer...
Generic connection class not specific to the transport mechanism.
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
int add_is900_button(const char *button_device_name, int sensor, int numbuttons=5)
Add an IS900 button device to one of the sensors This allows configuration of an InterSense IS-900.
~vrpn_Tracker_InterSense()
struct timeval is900_zerotime
ISD_TRACKER_INFO_TYPE m_TrackerInfo
vrpn_Clipping_Analog_Server * is900_analogs[ISD_MAX_STATIONS]
int add_is900_analog(const char *analog_device_name, int sensor, double c0Min=-1, double c0Low=0, double c0Hi=0, double c0Max=1, double c1Min=-1, double c1Low=0, double c1Hi=0, double c1Max=1)
Add the analog part of an IS900 joystick device to one of the sensors This allows configuration of an...
virtual void send_report(void)
int set_sensor_output_format(int sensor)
Augments the basic Fastrak format to include IS900 features if needed.
ISD_STATION_INFO_TYPE m_StationInfo[ISD_MAX_STATIONS]
void getTrackerInfo(char *msg)
virtual void get_report(void)
virtual void mainloop()
This function should be called each time through the main loop of the server code....
ISD_TRACKER_HANDLE m_Handle
vrpn_Tracker_InterSense(const char *name, vrpn_Connection *c, int commPort, const char *additional_reset_commands=NULL, int is900_timestamps=0, int reset_at_start=0)
vrpn_Button_Server * is900_buttons[ISD_MAX_STATIONS]
virtual int encode_to(char *buf)
int register_server_handlers(void)
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
Header containing macros formerly duplicated in a lot of implementation files.
#define VRPN_MSG_INFO(msg)
#define VRPN_MSG_ERROR(msg)
#define VRPN_MSG_WARNING(msg)
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
timeval vrpn_TimevalSum(const timeval &tv1, const timeval &tv2)
void vrpn_strcpy(char(&to)[charCount], const char *pSrc)
Null-terminated-string copy function that both guarantees not to overrun the buffer and guarantees th...
#define vrpn_gettimeofday
#define VRPN_DEGREES_TO_RADIANS
const int vrpn_TRACKER_FAIL
const int vrpn_TRACKER_RESETTING
const int vrpn_TRACKER_SYNCING
const int vrpn_TRACKER_PARTIAL
const int vrpn_TRACKER_REPORT_READY
const int vrpn_TRACKER_AWAITING_STATION
class VRPN_API vrpn_Clipping_Analog_Server
class VRPN_API vrpn_Button_Server