Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • danc/MicroCART
  • snawerdt/MicroCART_17-18
  • bbartels/MicroCART_17-18
  • jonahu/MicroCART
4 results
Show changes
Showing
with 0 additions and 2550 deletions
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
// phan_client.C - simplest example: generates a flat horizontal plane
#include <stdio.h> // for printf, NULL
#include <vrpn_Button.h> // for vrpn_BUTTONCB, etc
#include <vrpn_Tracker.h> // for vrpn_TRACKERCB, etc
#include "vrpn_Configure.h" // for VRPN_CALLBACK
#include "vrpn_Connection.h" // for vrpn_Connection
#include "vrpn_ForceDevice.h" // for vrpn_ForceDevice_Remote, etc
#include "vrpn_Types.h" // for vrpn_float64
#define PHANTOM_SERVER "Tracker0@localhost"
/*****************************************************************************
*
Callback handler
*
*****************************************************************************/
void VRPN_CALLBACK handle_force_change(void *userdata, const vrpn_FORCECB f)
{
static vrpn_FORCECB lr; // last report
static int first_report_done = 0;
if ((!first_report_done) ||
((f.force[0] != lr.force[0]) || (f.force[1] != lr.force[1])
|| (f.force[2] != lr.force[2])))
printf("force is (%f,%f,%f)\n", f.force[0], f.force[1], f.force[2]);
first_report_done = 1;
lr = f;
}
void VRPN_CALLBACK handle_tracker_change(void *userdata, const vrpn_TRACKERCB t)
{
static vrpn_TRACKERCB lr; // last report
static float dist_interval_sq = 0.004f;
if ((lr.pos[0] - t.pos[0])*(lr.pos[0] - t.pos[0]) +
(lr.pos[1] - t.pos[1])*(lr.pos[1] - t.pos[1]) +
(lr.pos[2] - t.pos[2])*(lr.pos[2] - t.pos[2]) > dist_interval_sq){
printf("Sensor %d is now at (%g,%g,%g)\n", t.sensor,
t.pos[0], t.pos[1], t.pos[2]);
lr = t;
}
}
void VRPN_CALLBACK handle_button_change(void *userdata, const vrpn_BUTTONCB b)
{
static int count=0;
static int buttonstate = 1;
int done = 0;
if (b.state != buttonstate) {
printf("button #%d is in state %d\n", b.button, b.state);
buttonstate = b.state;
count++;
}
if (count > 4)
done = 1;
*(int *)userdata = done;
}
int main(int argc, char *argv[])
{
printf("generates a flat horizontal plane on ForceDevice %s\n", PHANTOM_SERVER);
int done = 0;
vrpn_ForceDevice_Remote *forceDevice;
vrpn_Tracker_Remote *tracker;
vrpn_Button_Remote *button;
// initialize the force device
forceDevice = new vrpn_ForceDevice_Remote(PHANTOM_SERVER);
forceDevice->register_force_change_handler(NULL, handle_force_change);
// initialize the tracker
tracker = new vrpn_Tracker_Remote(PHANTOM_SERVER);
tracker->register_change_handler(NULL, handle_tracker_change);
// initialize the button
button = new vrpn_Button_Remote(PHANTOM_SERVER);
button->register_change_handler(&done, handle_button_change);
while (!forceDevice->connectionPtr()->connected()) {
forceDevice->mainloop();
}
// Set plane and surface parameters
forceDevice->set_plane(0.0, 1.0, 0.0, 0.0);
forceDevice->setSurfaceKspring(0.8f); // spring constant - units of
// dynes/cm
forceDevice->setSurfaceKdamping(0.0); // damping constant -
// units of dynes*sec/cm
forceDevice->setSurfaceFstatic(0.0); // set static friction
forceDevice->setSurfaceFdynamic(0.0); // set dynamic friction
forceDevice->setRecoveryTime(10); // recovery occurs over 10
// force update cycles
forceDevice->setSurfaceBuzzAmplitude(0.0);
forceDevice->setSurfaceBuzzFrequency(60.0);
forceDevice->setSurfaceTextureAmplitude(0.0);
forceDevice->setSurfaceTextureWavelength(0.01f);
// enable force device and send first surface
forceDevice->startSurface();
/*
// test spring constraint instead
vrpn_float32 p [3];
p[0] = 0.0f;
p[1] = 0.0f;
p[2] = 0.0f;
vrpn_float32 d [3];
d[0] = 0.0f;
d[1] = 1.0f;
d[2] = 0.0f;
//forceDevice->setConstraintMode(vrpn_ForceDevice::POINT_CONSTRAINT);
//forceDevice->setConstraintPoint(p);
// works
//forceDevice->setConstraintMode(vrpn_ForceDevice::LINE_CONSTRAINT);
//forceDevice->setConstraintLinePoint(p);
//forceDevice->setConstraintLineDirection(d);
// works
forceDevice->setConstraintMode(vrpn_ForceDevice::PLANE_CONSTRAINT);
forceDevice->setConstraintPlanePoint(p);
forceDevice->setConstraintPlaneNormal(d);
forceDevice->setConstraintKSpring(10.0);
forceDevice->enableConstraint(1);
*/
// main loop
while (! done ){
// Let the forceDevice send its planes to remote force device
forceDevice->mainloop();
// Let tracker receive position information from remote tracker
tracker->mainloop();
// Let button receive button status from remote button
button->mainloop();
// we may call forceDevice->set_plane(...) followed by
// forceDevice->sendSurface() here to change the plane
// for example: using position information from a tracker we can
// compute a plane to approximate a complex surface at that
// position and send that approximation 15-30 times per
// second to simulate the complex surface
}
// shut off force device
forceDevice->stopSurface();
} /* main */
#include <signal.h> // for signal, SIGINT
#include <stdio.h> // for printf, fprintf, stderr, etc
#include <stdlib.h> // for exit
#include "vrpn_Analog.h" // for vrpn_Analog_Remote, etc
#include "vrpn_Button.h" // for vrpn_Button_Remote, etc
#include "vrpn_Configure.h" // for VRPN_CALLBACK
#include "vrpn_Dial.h" // for vrpn_DIALCB, etc
#include "vrpn_Shared.h" // for vrpn_SleepMsecs
#include "vrpn_Types.h" // for vrpn_float64
vrpn_Button_Remote *btn;
vrpn_Analog_Remote *ana;
vrpn_Dial_Remote *dial;
int done = 0;
const int MAX_DIALS = 128;
vrpn_float64 cur_dial_values[MAX_DIALS];
/*****************************************************************************
*
Callback handlers
*
*****************************************************************************/
void VRPN_CALLBACK handle_button (void *, const vrpn_BUTTONCB b)
{
printf("B%d->%d\n", b.button, b.state);
}
void VRPN_CALLBACK handle_analog (void *, const vrpn_ANALOGCB a)
{
int i;
printf("Analogs: ");
for (i = 0; i < a.num_channel; i++) {
printf("%4.2f ",a.channel[i]);
}
printf("\n");
}
void VRPN_CALLBACK handle_dial (void *, const vrpn_DIALCB d)
{
cur_dial_values[d.dial] += d.change;
printf("Dial %d spun by %lf (currently at %lf)\n", d.dial, d.change,
cur_dial_values[d.dial]);
}
/*****************************************************************************
*
init - initialize everything
*
*****************************************************************************/
void init (const char * devicename)
{
int i;
fprintf(stderr, "Button's name is %s.\n", devicename);
btn = new vrpn_Button_Remote (devicename);
fprintf(stderr, "Analog's name is %s.\n", devicename);
ana = new vrpn_Analog_Remote (devicename);
fprintf(stderr, "Dial's name is %s.\n", devicename);
dial = new vrpn_Dial_Remote (devicename);
// Zero all of the dial records
for (i = 0; i < MAX_DIALS; i++) {
cur_dial_values[i] = 0.0;
}
// Set up the callback handlers
printf("Button update: B<number> is <newstate>\n");
btn->register_change_handler(NULL, handle_button);
printf("Analog update: Analogs: [new values listed]\n");
ana->register_change_handler(NULL, handle_analog);
printf("Dial update: Dial# spun by [amount]\n");
dial->register_change_handler(NULL, handle_dial);
} /* init */
void handle_cntl_c (int) {
done = 1;
}
void shutdown (void) {
fprintf(stderr, "\nIn control-c handler.\n");
if (btn) delete btn;
if (ana) delete ana;
if (dial) delete dial;
exit(0);
}
int main (int argc, char * argv [])
{
#ifdef hpux
char default_station_name [100];
strcpy(default_station_name, "CerealBox@ioglab");
#else
char default_station_name [] = { "CerealBox@ioglab" };
#endif
const char * station_name = default_station_name;
if (argc < 2) {
fprintf(stderr, "Usage: %s Device_name\n"
" Device_name: VRPN name of data source to contact\n"
" example: CerealBox@ioglab\n",
argv[0]);
exit(0);
}
// parse args
station_name = argv[1];
// initialize the PC/station
init(station_name);
// signal handler so logfiles get closed right
signal(SIGINT, handle_cntl_c);
/*
* main interactive loop
*/
while ( ! done )
{
// Let the tracker and button do their things
btn->mainloop();
ana->mainloop();
dial->mainloop();
// Sleep for 1ms so we don't eat the CPU
vrpn_SleepMsecs(1);
}
shutdown();
return 0;
} /* main */
# Microsoft Developer Studio Project File - Name="printcereal" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=printcereal - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "printcereal.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "printcereal.mak" CFG="printcereal - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "printcereal - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "printcereal - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "printcereal - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../pc_win32/client_src/printcereal/Release"
# PROP Intermediate_Dir "../pc_win32/client_src/printcereal/Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /D "_CONSOLE" /D "NDEBUG" /D "_MBCS" /D "WIN32" /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../pc_win32/Release" /libpath:"../pc_win32/DLL/Release"
!ELSEIF "$(CFG)" == "printcereal - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../pc_win32/client_src/printcereal/Debug"
# PROP Intermediate_Dir "../pc_win32/client_src/printcereal/Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\\" /D "_CONSOLE" /D "_DEBUG" /D "_MBCS" /D "WIN32" /FR /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../pc_win32/Debug" /libpath:"../pc_win32/DLL/Debug"
!ENDIF
# Begin Target
# Name "printcereal - Win32 Release"
# Name "printcereal - Win32 Debug"
# Begin Source File
SOURCE=printcereal.C
# End Source File
# End Target
# End Project
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="printcereal"
ProjectGUID="{4FC1C71E-8977-438B-AE1D-F1CD7D2C2D03}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../pc_win32/client_src/printcereal/Release"
IntermediateDirectory=".\../pc_win32/client_src/printcereal/Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/printcereal/Release/printcereal.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;.."
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\../pc_win32/client_src/printcereal/Release/printcereal.pch"
AssemblerListingLocation=".\../pc_win32/client_src/printcereal/Release/"
ObjectFile=".\../pc_win32/client_src/printcereal/Release/"
ProgramDataBaseFileName=".\../pc_win32/client_src/printcereal/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/printcereal/Release/printcereal.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
ProgramDatabaseFile=".\../pc_win32/client_src/printcereal/Release/printcereal.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/printcereal/Release/printcereal.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../pc_win32/client_src/printcereal/Debug"
IntermediateDirectory=".\../pc_win32/client_src/printcereal/Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/printcereal/Debug/printcereal.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;.."
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\../pc_win32/client_src/printcereal/Debug/printcereal.pch"
AssemblerListingLocation=".\../pc_win32/client_src/printcereal/Debug/"
ObjectFile=".\../pc_win32/client_src/printcereal/Debug/"
ProgramDataBaseFileName=".\../pc_win32/client_src/printcereal/Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/printcereal/Debug/printcereal.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../pc_win32/client_src/printcereal/Debug/printcereal.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/printcereal/Debug/printcereal.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="printcereal.C"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include <signal.h> // for signal, SIGINT
#include <stdio.h> // for fprintf, stderr, NULL, etc
#include <stdlib.h> // for atof, exit, atoi
#include <string.h> // for strcmp, strncmp
#include <vrpn_Configure.h> // for VRPN_CALLBACK
#include <vrpn_Button.h> // for vrpn_BUTTONCB
#include <vrpn_Shared.h> // for vrpn_SleepMsecs
#include <vrpn_Tracker.h> // for vrpn_TRACKERCB, etc
#include <vrpn_Connection.h> // for vrpn_HANDLERPARAM
#include <vrpn_Types.h> // for vrpn_float64, vrpn_int32
#include <vrpn_BaseClass.h> // for vrpn_System_TextPrinter, etc
#include <vrpn_FileConnection.h>
#include <vrpn_FileController.h>
#include <vrpn_RedundantTransmission.h>
//#include <vrpn_DelayedConnection.h>
vrpn_Button_Remote *btn,*btn2;
vrpn_Tracker_Remote *tkr;
vrpn_Connection * c;
vrpn_File_Controller * fc;
vrpn_RedundantRemote * rc;
int print_for_tracker = 1; // Print tracker reports?
int beQuiet = 0;
int beRedundant = 0;
int redNum = 0;
double redTime = 0.0;
double delayTime = 0.0;
int done = 0; // Signals that the program should exit
/*****************************************************************************
*
Callback handlers
*
*****************************************************************************/
void VRPN_CALLBACK handle_pos (void *, const vrpn_TRACKERCB t)
{
static int count = 0;
if (!print_for_tracker) { return; };
fprintf(stderr, "%d.", t.sensor);
if ((++count % 20) == 0) {
fprintf(stderr, "\n");
if (count > 300) {
printf("Pos, sensor %d = %5.3f, %5.3f, %5.3f", t.sensor,
t.pos[0], t.pos[1], t.pos[2]);
printf(" Quat = %5.2f, %5.2f, %5.2f, %5.2f\n",
t.quat[0], t.quat[1], t.quat[2], t.quat[3]);
count = 0;
}
}
}
void VRPN_CALLBACK handle_vel (void *, const vrpn_TRACKERVELCB t)
{
//static int count = 0;
if (!print_for_tracker) { return; };
fprintf(stderr, "%d/", t.sensor);
}
void VRPN_CALLBACK handle_acc (void *, const vrpn_TRACKERACCCB t)
{
//static int count = 0;
if (!print_for_tracker) { return; };
fprintf(stderr, "%d~", t.sensor);
}
void VRPN_CALLBACK handle_button (void *, const vrpn_BUTTONCB b)
{
printf("B%d is %d\n", b.button, b.state);
}
int VRPN_CALLBACK handle_gotConnection (void *, vrpn_HANDLERPARAM) {
if (beRedundant) {
fprintf(stderr, "printvals got connection; "
"initializing redundant xmission.\n");
rc->set(redNum, vrpn_MsecsTimeval(redTime * 1000.0));
}
return 0;
}
int VRPN_CALLBACK filter_pos (void * userdata, vrpn_HANDLERPARAM p) {
vrpn_Connection * c = (vrpn_Connection *) userdata;
int postype = c->register_message_type("Tracker Pos/Quat");
if (p.type == postype)
return 0; // keep position messages
return 1; // discard all others
}
/*****************************************************************************
*
init - initialize everything
*
*****************************************************************************/
void init (const char * station_name,
const char * local_in_logfile, const char * local_out_logfile,
const char * remote_in_logfile, const char * remote_out_logfile,
const char * NIC)
{
char devicename [1000];
//char * hn;
vrpn_int32 gotConn_type;
// explicitly open up connections with the proper logging parameters
// these will be entered in the table and found by the
// vrpn_get_connection_by_name() inside vrpn_Tracker and vrpn_Button
sprintf(devicename, "Tracker0@%s", station_name);
if (!strncmp(station_name, "file:", 5)) {
fprintf(stderr, "Opening file %s.\n", station_name);
c = new vrpn_File_Connection (station_name); // now unnecessary!
if (local_in_logfile || local_out_logfile ||
remote_in_logfile || remote_out_logfile) {
fprintf(stderr, "Warning: Reading from file, so not logging.\n");
}
} else {
fprintf(stderr, "Connecting to host %s.\n", station_name);
c = vrpn_get_connection_by_name
(station_name,
local_in_logfile, local_out_logfile,
remote_in_logfile, remote_out_logfile,
NIC);
if (delayTime > 0.0) {
//((vrpn_DelayedConnection *) c)->setDelay
//(vrpn_MsecsTimeval(delayTime * 1000.0));
//((vrpn_DelayedConnection *) c)->delayAllTypes(vrpn_TRUE);
}
}
fc = new vrpn_File_Controller (c);
if (beRedundant) {
rc = new vrpn_RedundantRemote (c);
}
fprintf(stderr, "Tracker's name is %s.\n", devicename);
tkr = new vrpn_Tracker_Remote (devicename);
sprintf(devicename, "Button0@%s", station_name);
fprintf(stderr, "Button's name is %s.\n", devicename);
btn = new vrpn_Button_Remote (devicename);
sprintf(devicename, "Button1@%s", station_name);
fprintf(stderr, "Button 2's name is %s.\n", devicename);
btn2 = new vrpn_Button_Remote (devicename);
// Set up the tracker callback handler
printf("Tracker update: '.' = pos, '/' = vel, '~' = acc\n");
tkr->register_change_handler(NULL, handle_pos);
tkr->register_change_handler(NULL, handle_vel);
tkr->register_change_handler(NULL, handle_acc);
// Set up the button callback handler
printf("Button update: B<number> is <newstate>\n");
btn->register_change_handler(NULL, handle_button);
btn2->register_change_handler(NULL, handle_button);
gotConn_type = c->register_message_type(vrpn_got_connection);
c->register_handler(gotConn_type, handle_gotConnection, NULL);
} /* init */
void shutdown () {
const char * n;
long i;
fprintf(stderr, "\nIn control-c handler.\n");
/* Commented out this test code for the common case
static int invocations = 0;
if (!invocations) {
printf("(First press -- setting replay rate to 2.0 -- 3 more to exit)\n");
fc->set_replay_rate(2.0f);
invocations++;
signal(SIGINT, handle_cntl_c);
return;
}
if (invocations == 1) {
printf("(Second press -- Starting replay over -- 2 more to exit)\n");
fc->reset();
invocations++;
signal(SIGINT, handle_cntl_c);
return;
}
if (invocations == 2) {
struct timeval t;
printf("(Third press -- Jumping replay to t+30 seconds -- "
"1 more to exit)\n");
t.tv_sec = 30L;
t.tv_usec = 0L;
fc->play_to_time(t);
invocations++;
signal(SIGINT, handle_cntl_c);
return;
}
*/
// print out sender names
if (c)
for (i = 0L; (n = c->sender_name(i)); i++)
printf("Knew local sender \"%s\".\n", n);
// print out type names
if (c)
for (i = 0L; (n = c->message_type_name(i)); i++)
printf("Knew local type \"%s\".\n", n);
if (btn)
delete btn;
if (btn2)
delete btn2;
if (tkr)
delete tkr;
if (c)
delete c;
exit(0);
}
// WARNING: On Windows systems, this handler is called in a separate
// thread from the main program (this differs from Unix). To avoid all
// sorts of chaos as the main program continues to handle packets, we
// set a done flag here and let the main program shut down in its own
// thread by calling shutdown() to do all of the stuff we used to do in
// this handler.
void handle_cntl_c(int) {
done = 1;
}
void Usage (const char * arg0) {
fprintf(stderr,
"Usage: %s [-lli logfile] [-llo logfile] [-rli logfile ] [-rlo logfile]\n"
" [-NIC ip] [-filterpos] [-quiet]\n"
" [-red num time] [-delay time] station_name\n"
" -notracker: Don't print tracker reports\n"
" -lli: log incoming messages locally in <logfile>\n"
" -llo: log outgoing messages locally in <logfile>\n"
" -rli: log incoming messages remotely in <logfile>\n"
" -rlo: log outgoing messages remotely in <logfile>\n"
" -NIC: use network interface with address <ip>\n"
" -filterpos: log only Tracker Position messages\n"
" -quiet: ignore VRPN warnings\n"
" -red <num> <time>: send every message <num>\n"
" times <time> seconds apart\n"
" -delay <time: delay all messages received by <time>\n"
" station_name: VRPN name of data source to contact\n"
" one of: <hostname>[:<portnum>]\n"
" file:<filename>\n",
arg0);
exit(0);
}
int main (int argc, char * argv [])
{
#ifdef hpux
char default_station_name [20];
strcpy(default_station_name, "ioph100");
#else
char default_station_name [] = { "ioph100" };
#endif
const char * station_name = default_station_name;
const char * local_in_logfile = NULL;
const char * local_out_logfile = NULL;
const char * remote_in_logfile = NULL;
const char * remote_out_logfile = NULL;
const char * NIC = NULL;
//long local_logmode = vrpn_LOG_NONE;
//long remote_logmode = vrpn_LOG_NONE;
int filter = 0;
int i;
#ifdef _WIN32
WSADATA wsaData;
int status;
if ((status = WSAStartup(MAKEWORD(1,1), &wsaData)) != 0) {
fprintf(stderr, "WSAStartup failed with %d\n", status);
exit(1);
}
#endif
if (argc < 2) {
Usage(argv[0]);
}
// parse args
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-lli")) {
i++;
local_in_logfile = argv[i];
} else if (!strcmp(argv[i], "-llo")) {
i++;
local_out_logfile = argv[i];
} else if (!strcmp(argv[i], "-rli")) {
i++;
remote_in_logfile = argv[i];
} else if (!strcmp(argv[i], "-rlo")) {
i++;
remote_out_logfile = argv[i];
} else if (!strcmp(argv[i], "-notracker")) {
print_for_tracker = 0;
} else if (!strcmp(argv[i], "-filterpos")) {
filter = 1;
} else if (!strcmp(argv[i], "-NIC")) {
i++;
NIC = argv[i];
} else if (!strcmp(argv[i], "-quiet")) {
beQuiet = 1;
} else if (!strcmp(argv[i], "-red")) {
beRedundant = 1;
i++;
redNum = atoi(argv[i]);
i++;
redTime = atof(argv[i]);
} else if (!strcmp(argv[i], "-delay")) {
i++;
delayTime = atof(argv[i]);
} else
station_name = argv[i];
}
// initialize the PC/station
init(station_name,
local_in_logfile, local_out_logfile,
remote_in_logfile, remote_out_logfile,
NIC);
// signal handler so logfiles get closed right
signal(SIGINT, handle_cntl_c);
// filter the log if requested
if (filter && c) {
c->register_log_filter(filter_pos, c);
}
if (beQuiet) {
vrpn_System_TextPrinter.remove_object(btn);
vrpn_System_TextPrinter.remove_object(btn2);
vrpn_System_TextPrinter.remove_object(tkr);
if (beRedundant) {
vrpn_System_TextPrinter.remove_object(rc);
}
}
if (beRedundant) {
rc->set(redNum, vrpn_MsecsTimeval(redTime * 1000.0));
}
/*
* main interactive loop
*/
while ( ! done ) {
// Run this so control happens!
c->mainloop();
// Let the tracker and button do their things
btn->mainloop();
btn2->mainloop();
tkr->mainloop();
if (beRedundant) {
rc->mainloop();
}
// Sleep for 1ms so we don't eat the CPU
vrpn_SleepMsecs(1);
}
shutdown();
return 0;
} /* main */
# Microsoft Developer Studio Project File - Name="printvals" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=printvals - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "printvals.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "printvals.mak" CFG="printvals - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "printvals - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "printvals - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "printvals - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../pc_win32/client_src/printvals/Release"
# PROP Intermediate_Dir "../pc_win32/client_src/printvals/Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /D "_CONSOLE" /D "NDEBUG" /D "_MBCS" /D "WIN32" /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../pc_win32/Release" /libpath:"../pc_win32/DLL/Release"
# SUBTRACT LINK32 /incremental:yes
!ELSEIF "$(CFG)" == "printvals - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../pc_win32/client_src/printvals/Debug"
# PROP Intermediate_Dir "../pc_win32/client_src/printvals/Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I ".." /D "_CONSOLE" /D "_DEBUG" /D "_MBCS" /D "WIN32" /FR /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../pc_win32/Debug" /libpath:"../pc_win32/DLL/Debug"
# SUBTRACT LINK32 /nodefaultlib
!ENDIF
# Begin Target
# Name "printvals - Win32 Release"
# Name "printvals - Win32 Debug"
# Begin Source File
SOURCE=printvals.C
# End Source File
# End Target
# End Project
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="printvals"
ProjectGUID="{A1B0D907-E30D-4CB9-B313-D342AD5CC3E7}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../pc_win32/client_src/printvals/Release"
IntermediateDirectory=".\../pc_win32/client_src/printvals/Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/printvals/Release/printvals.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include,$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include,.."
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\../pc_win32/client_src/printvals/Release/printvals.pch"
AssemblerListingLocation=".\../pc_win32/client_src/printvals/Release/"
ObjectFile=".\../pc_win32/client_src/printvals/Release/"
ProgramDataBaseFileName=".\../pc_win32/client_src/printvals/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/printvals/Release/printvals.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
ProgramDatabaseFile=".\../pc_win32/client_src/printvals/Release/printvals.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/printvals/Release/printvals.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../pc_win32/client_src/printvals/Debug"
IntermediateDirectory=".\../pc_win32/client_src/printvals/Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/printvals/Debug/printvals.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include,$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include,.."
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\../pc_win32/client_src/printvals/Debug/printvals.pch"
AssemblerListingLocation=".\../pc_win32/client_src/printvals/Debug/"
ObjectFile=".\../pc_win32/client_src/printvals/Debug/"
ProgramDataBaseFileName=".\../pc_win32/client_src/printvals/Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/printvals/Debug/printvals.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../pc_win32/client_src/printvals/Debug/printvals.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/printvals/Debug/printvals.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="printvals.C"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include <stdio.h> // for fprintf, NULL, printf, etc
#include <stdlib.h> // for atoi, exit
#include <string.h> // for strcmp, strncpy
#include "vrpn_Auxiliary_Logger.h"
#include "vrpn_Configure.h" // for VRPN_CALLBACK
#include "vrpn_Shared.h" // for timeval, vrpn_gettimeofday, etc
vrpn_Auxiliary_Logger_Remote *g_logger;
/*****************************************************************************
*
Callback handlers and the data structures they use to pass information
to the rest of the program.
*
*****************************************************************************/
// Caller sets to false before mainloop(); handle_log_report sets to true
// when a report arrives.
bool g_got_report = false;
// Names returned to the log report handler. Filled in by the report handler.
const unsigned NAMELEN = 2048;
char g_local_in[NAMELEN];
char g_local_out[NAMELEN];
char g_remote_in[NAMELEN];
char g_remote_out[NAMELEN];
void VRPN_CALLBACK handle_log_report (void *, const vrpn_AUXLOGGERCB info)
{
strncpy(g_local_in, info.local_in_logfile_name, NAMELEN);
strncpy(g_local_out, info.local_out_logfile_name, NAMELEN);
strncpy(g_remote_in, info.remote_in_logfile_name, NAMELEN);
strncpy(g_remote_out, info.remote_out_logfile_name, NAMELEN);
printf( "log report: \'%s\' \'%s\' \'%s\' \'%s\'\n",
g_local_in, g_local_out, g_remote_in, g_remote_out );
g_got_report = true;
}
/*****************************************************************************
*
*****************************************************************************/
// Request some log files and wait up to a second for the report of these
// files. Return true if we got a report and the names match.
bool test_logfile_names(const char *local_in, const char *local_out,
const char *remote_in, const char *remote_out)
{
struct timeval start;
struct timeval now;
// Mark no report and the request logging with the specified
// parameters.
g_got_report = false;
if (!g_logger->send_logging_request(local_in, local_out, remote_in, remote_out)) {
fprintf(stderr, "test_logfile_names: Logging request send failed\n");
return false;
}
// Mainloop the logger for up to five seconds waiting for a response.
// If we don't get a response, this is a failure.
vrpn_gettimeofday(&start, NULL);
do {
g_logger->mainloop();
vrpn_gettimeofday(&now, NULL);
vrpn_SleepMsecs(1);
} while ( !g_got_report && (vrpn_TimevalDurationSeconds(now, start) < 5.0));
if (!g_got_report) {
fprintf(stderr, "test_logfile_names: Timeout waiting for report of logging from server\n");
return false;
}
// Check to see if the names are the same. Return true if they all are.
if ( (strcmp(g_local_in, local_in) == 0) &&
(strcmp(g_local_out, local_out) == 0) &&
(strcmp(g_remote_in, remote_in) == 0) &&
(strcmp(g_remote_out, remote_out) == 0) ) {
return true;
} else {
return false;
}
}
/*****************************************************************************
*
init - initialize everything
*
*****************************************************************************/
int main (int argc, char * argv [])
{
const char * devicename = "Logger0@localhost";
const char * logfilename = "deleteme.vrpn";
int log_duration_seconds = 120;
struct timeval start;
struct timeval now;
int ret = 0;
// parse args
if (argc != 4) {
fprintf(stderr, "Usage: %s Device_name remote_logfile_name time_seconds\n"
" Device_name: VRPN name of data source to contact\n"
" example: Logger0@localhost\n"
" remote_logfile_name: The name of the file to log remotely\n"
" time_seconds: How long to log before closing and exiting\n",
argv[0]);
exit(0);
} else {
devicename = argv[1];
logfilename = argv[2];
log_duration_seconds = atoi(argv[3]);
}
// Open the logger and set up its callback handler.
fprintf(stderr, "Logger's name is %s.\n", devicename);
g_logger = new vrpn_Auxiliary_Logger_Remote (devicename);
g_logger->register_report_handler(NULL, handle_log_report);
// Main loop for half a second to get things started on the
// connection.
vrpn_gettimeofday(&start, NULL);
do {
g_logger->mainloop();
vrpn_gettimeofday(&now, NULL);
} while (vrpn_TimevalDurationSeconds(now, start) < 0.5);
// Try to create the named log file as the remote outgoing log
// on the server. Wait for the specified duration to give it
// time to log.
if (!test_logfile_names("", "", "", logfilename) ) {
fprintf(stderr,"Error creating remote outgoing log file %s\n",logfilename);
ret = -1;
}
vrpn_gettimeofday(&start, NULL);
do {
g_logger->mainloop();
vrpn_gettimeofday(&now, NULL);
} while (vrpn_TimevalDurationSeconds(now, start) <= log_duration_seconds);
// Try to create blank log files (no log should be made). Wait for a while after
// creation to give time to stop logging.
if (!test_logfile_names("", "", "", "") ) {
fprintf(stderr,"Error turning off logs\n");
ret = -1;
}
vrpn_gettimeofday(&start, NULL);
do {
g_logger->mainloop();
vrpn_gettimeofday(&now, NULL);
} while (vrpn_TimevalDurationSeconds(now, start) < 5.0);
// Done.
if (ret == 0) {
printf("Success!\n");
} else {
printf("Make sure that files with the requested names don't already exist.\n");
}
delete g_logger;
return ret;
} /* main */
# Microsoft Developer Studio Project File - Name="run_auxiliary_logger" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=run_auxiliary_logger - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "run_auxiliary_logger.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "run_auxiliary_logger.mak" CFG="run_auxiliary_logger - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "run_auxiliary_logger - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "run_auxiliary_logger - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "run_auxiliary_logger - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../pc_win32/server_src/run_auxiliary_logger/Release"
# PROP Intermediate_Dir "../pc_win32/server_src/run_auxiliary_logger/Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "..\..\quat" /D "_CONSOLE" /D "NDEBUG" /D "_MBCS" /D "WIN32" /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../pc_win32/Release" /libpath:"../pc_win32/DLL/Release"
!ELSEIF "$(CFG)" == "run_auxiliary_logger - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../pc_win32/server_src/run_auxiliary_logger/Debug"
# PROP Intermediate_Dir "../pc_win32/server_src/run_auxiliary_logger/Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".." /I "..\..\quat" /D "_CONSOLE" /D "_DEBUG" /D "_MBCS" /D "WIN32" /FR /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../pc_win32/Debug" /libpath:"../pc_win32/DLL/Debug"
!ENDIF
# Begin Target
# Name "run_auxiliary_logger - Win32 Release"
# Name "run_auxiliary_logger - Win32 Debug"
# Begin Source File
SOURCE=run_auxiliary_logger.C
# End Source File
# End Target
# End Project
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="run_auxiliary_logger"
ProjectGUID="{1D303E7B-DBBD-409B-BBEC-2A11AF9847A9}"
RootNamespace="run_auxiliary_logger"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../pc_win32/server_src/run_auxiliary_logger/Release"
IntermediateDirectory=".\../pc_win32/server_src/run_auxiliary_logger/Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/server_src/run_auxiliary_logger/Release/run_auxiliary_logger.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include,$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include,..,../quat"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\../pc_win32/server_src/run_auxiliary_logger/Release/run_auxiliary_logger.pch"
AssemblerListingLocation=".\../pc_win32/server_src/run_auxiliary_logger/Release/"
ObjectFile=".\../pc_win32/server_src/run_auxiliary_logger/Release/"
ProgramDataBaseFileName=".\../pc_win32/server_src/run_auxiliary_logger/Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/server_src/run_auxiliary_logger/Release/run_auxiliary_logger.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
ProgramDatabaseFile=".\../pc_win32/server_src/run_auxiliary_logger/Release/run_auxiliary_logger.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/server_src/run_auxiliary_logger/Release/run_auxiliary_logger.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../pc_win32/server_src/run_auxiliary_logger/Debug"
IntermediateDirectory=".\../pc_win32/server_src/run_auxiliary_logger/Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/server_src/run_auxiliary_logger/Debug/run_auxiliary_logger.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include,$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include,..,../quat"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\../pc_win32/server_src/run_auxiliary_logger/Debug/run_auxiliary_logger.pch"
AssemblerListingLocation=".\../pc_win32/server_src/run_auxiliary_logger/Debug/"
ObjectFile=".\../pc_win32/server_src/run_auxiliary_logger/Debug/"
ProgramDataBaseFileName=".\../pc_win32/server_src/run_auxiliary_logger/Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/server_src/run_auxiliary_logger/Debug/run_auxiliary_logger.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../pc_win32/server_src/run_auxiliary_logger/Debug/run_auxiliary_logger.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/server_src/run_auxiliary_logger/Debug/run_auxiliary_logger.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="run_auxiliary_logger.C"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include "vrpn_Sound.h"
#include <string.h>
#include <math.h>
#define FASTSPEED 100
#define CIRCLERADIUS 25.0F
vrpn_Sound_Client *soundClient;
float X,Y,Z,adj;
static void init_sample_values()
{
Y=Z=0.0F;
X=25.0F;
adj=0.0F;
}
static void move_sample_values()
{
// handle the circle movement
adj+=(2.0F*3.14159265358979F/(((FASTSPEED+1-50.0F)*1.6F)+20.0F));
X=(float)(CIRCLERADIUS*cos(adj));
Z=(float)(CIRCLERADIUS*sin(adj));
}
void loopSound(vrpn_SoundID id)
{
vrpn_float64 position[3], orientation[4], velocity[4];
while(1)
{
//save old settings
position[0] = X; position[1] = Y; position[2] = Z;
orientation[0] = -X; orientation[1] = -Y; orientation[2] = -Z; orientation[3] = 1;
(void)soundClient->setSoundPose(id, position, orientation);
// move the sample values
move_sample_values();
// calculate the delta vector
velocity[0]=X-position[0];
velocity[1]=0-position[1];
velocity[2]=Z-position[2];
velocity[3]=((50.0F/300.0F)+1.0F)/1500.0F;
(void)soundClient->setSoundVelocity(id,velocity);
soundClient->mainloop();
if (X == 25.0F)
break;
vrpn_SleepMsecs(1);
}
}
int main(int argc, char** argv)
{
char server[80], device[80], dummy[80];
vrpn_SoundID ids[100], id;
char files[100][80];
int curID = 0;
int command;
int loop = 1, i;
vrpn_int32 repeat, volume;
vrpn_float64 position[3], orientation[4], velocity[4];
vrpn_float64 Lposition[3], Lorientation[4], Lvelocity[4];
position[0] = 0; position[1] = 0; position[2] = 0;
orientation[0] = 0; orientation[1] = 0; orientation[2] = 1; orientation[3] = 0;
velocity[0] = 0; velocity[1] = 0; velocity[2] = 0; velocity[3] = 0;
Lposition[0] = 0; Lposition[1] = 0; Lposition[2] = 0;
Lorientation[0] = 0; Lorientation[1] = 0; Lorientation[2] = -1; Lorientation[3] = 1;
Lvelocity[0] = 0; Lvelocity[1] = 0; Lvelocity[2] = 0; Lvelocity[3] = 0;
printf("Please enter the server you wish to connect to.\n");
scanf("%s", server);
printf("Please enter the sound device name you wish to connect to.\n");
scanf("%s", device);
vrpn_Connection *connection = vrpn_get_connection_by_name(server);
soundClient = new vrpn_Sound_Client(device, connection);
for(i = 0; i < 100; i++)
ids[i] = -1;
while(loop)
{
printf("Current sounds loaded\n");
for(i = 0; i < 100; i++)
{
if (ids[i] == -1)
continue;
if (i % 3 == 2)
printf("\n");
else
printf("\t");
printf("%d %s", ids[i], files[i]);
}
printf("\nOptions\n");
printf("1) Load Sound\n");
printf("2) Unload Sound\n");
printf("3) Play Sound\n");
printf("4) Stop Sound\n");
printf("5) Change Sound Volume\n");
printf("6) Change Sound Position\n");
printf("7) Change Sound Orientation\n");
printf("8) Change Sound Velocity\n");
printf("9) Change Listener Position\n");
printf("10) Change Listener Orientation\n");
printf("11) Change Listener Velocity\n");
printf("12) Loop sound around head\n");
printf("13) Quit\n");
printf("Choose option ");
scanf("%d", &command);
switch(command)
{
case 1: {
printf("Enter path and file to load\n");
scanf("%s", dummy);
vrpn_SoundDef SoundDef;
ids[curID] = soundClient->loadSound(dummy, curID, SoundDef);
strcpy(files[curID++], dummy);
soundClient->mainloop();
}
break;
case 2:
printf("Enter ID of sound to unload ");
scanf("%d", &id);
(void)soundClient->unloadSound(id);
for(i = 0; i < 100; i++)
if (ids[i] == id) ids[i] = -1;
soundClient->mainloop();
break;
case 3:
printf("Enter ID of sound to play ");
scanf("%d", &id);
printf("Enter number of times to repeat. (0 = continuous) ");
scanf("%d", &repeat);
(void)soundClient->playSound(id, repeat);
soundClient->mainloop();
break;
case 4:
printf("Enter ID of sound to stop ");
scanf("%d", &id);
(void)soundClient->stopSound(id);
soundClient->mainloop();
break;
case 5:
printf("Enter ID of sound to change ");
scanf("%d", &id);
printf("Enter value to change volume to ");
scanf("%d", &volume);
(void)soundClient->setSoundVolume(id, volume);
soundClient->mainloop();
break;
case 6:
printf("Enter ID of sound to change ");
scanf("%d", &id);
printf("Enter the new X,Y, and Z position coordinates for the sound\n");
scanf("%lf %lf %lf", &position[0], &position[1], &position[2]);
(void)soundClient->setSoundPose(id, position, orientation);
soundClient->mainloop();
break;
case 7:
printf("Enter ID of sound to change ");
scanf("%d", &id);
printf("Enter the new X,Y, Z, and W orientation coordinates for the sound\n");
scanf("%lf %lf %lf %lf", &orientation[0], &orientation[1], &orientation[2], &orientation[3]);
(void)soundClient->setSoundPose(id, position, orientation);
soundClient->mainloop();
break;
case 8:
printf("Enter ID of sound to change ");
scanf("%d", &id);
printf("Enter the new X,Y, and Z velocity coordinates for the sound and magnitude\n");
scanf("%lf %lf %lf %lf", &velocity[0], &velocity[1], &velocity[2], &velocity[3]);
(void)soundClient->setSoundVelocity(id,velocity);
soundClient->mainloop();
break;
case 9:
printf("Enter the new X,Y, and Z position coordinates for the listener\n");
scanf("%lf %lf %lf", &Lposition[0], &Lposition[1], &Lposition[2]);
(void)soundClient->setListenerPose(Lposition, Lorientation);
soundClient->mainloop();
break;
case 10:
printf("Enter the new X,Y, Z, and W orientation coordinates for the listener\n");
scanf("%lf %lf %lf %lf", &Lorientation[0], &Lorientation[1], &Lorientation[2], &Lorientation[3]);
(void)soundClient->setListenerPose(Lposition, Lorientation);
soundClient->mainloop();
break;
case 11:
printf("Enter the new X,Y, and Z velocity coordinates for the listener and magnitude\n");
scanf("%lf %lf %lf %lf", &Lvelocity[0], &Lvelocity[1], &Lvelocity[2], &Lvelocity[3]);
(void)soundClient->setListenerVelocity(Lvelocity);
soundClient->mainloop();
break;
case 12:
printf("Enter ID of sound to loop");
scanf("%d", &id);
init_sample_values();
loopSound(id);
break;
case 13:
loop = 0;
break;
default:
break;
}
}
return 0;
}
//
// sphere.C - simple VRPN client, inspired by Randy Heiland
// generates a sphere with a radius of 3 cm
//
#include <math.h> // for sqrt
#include <stdio.h> // for printf, NULL
#include <stdlib.h> // for atof, exit
#include <vrpn_Button.h> // for vrpn_BUTTONCB, etc
#include <vrpn_ForceDevice.h> // for vrpn_ForceDevice_Remote, etc
#include <vrpn_Tracker.h> // for vrpn_TRACKERCB, etc
#include "vrpn_Configure.h" // for VRPN_CALLBACK
#include "vrpn_Connection.h" // for vrpn_Connection
#include "vrpn_Types.h" // for vrpn_float64
static float xpos,ypos,zpos;
/*****************************************************************************
*
Callback handler
*
*****************************************************************************/
void VRPN_CALLBACK handle_force_change(void * /*userdata*/, const vrpn_FORCECB f)
{
static vrpn_FORCECB lr; // last report
static int first_report_done = 0;
if ((!first_report_done) ||
((f.force[0] != lr.force[0]) || (f.force[1] != lr.force[1])
|| (f.force[2] != lr.force[2]))) {
printf("force is (%f,%f,%f)\n", f.force[0], f.force[1], f.force[2]);
}
first_report_done = 1;
lr = f;
}
vrpn_ForceDevice_Remote *forceDevice;
void VRPN_CALLBACK handle_tracker_change(void * /*userdata*/, const vrpn_TRACKERCB t)
{
static vrpn_TRACKERCB lr; // last report
static float dist_interval_sq = (float)0.004;
if ((lr.pos[0] - t.pos[0])*(lr.pos[0] - t.pos[0]) +
(lr.pos[1] - t.pos[1])*(lr.pos[1] - t.pos[1]) +
(lr.pos[2] - t.pos[2])*(lr.pos[2] - t.pos[2]) > dist_interval_sq){
printf("Sensor %d is now at (%g,%g,%g)\n", t.sensor,
t.pos[0], t.pos[1], t.pos[2]);
lr = t;
}
xpos = (float)t.pos[0];
ypos = (float)t.pos[1];
zpos = (float)t.pos[2];
// we may call forceDevice->set_plane(...) followed by
// forceDevice->sendSurface() here to change the plane
// for example: using position information from a tracker we can
// compute a plane to approximate a complex surface at that
// position and send that approximation 15-30 times per
// second to simulate the complex surface
double norm = sqrt(xpos*xpos + ypos*ypos + zpos*zpos);
double radius = .03; // radius is 3 cm
forceDevice->set_plane(xpos,ypos,zpos, (float)(-radius*norm));
forceDevice->sendSurface();
}
void VRPN_CALLBACK handle_button_change(void *userdata, const vrpn_BUTTONCB b)
{
static int count=0;
static int buttonstate = 1;
int done = 0;
if (b.state != buttonstate) {
printf("button #%d is in state %d\n", b.button, b.state);
buttonstate = b.state;
count++;
}
if (count > 4)
done = 1;
*(int *)userdata = done;
}
int main(int argc, char *argv[])
{
int done = 0;
vrpn_Tracker_Remote *tracker;
vrpn_Button_Remote *button;
if (argc != 4) {
printf("Usage: %s sFric dFric device_name\n",argv[0]);
printf(" Example: %s 0.1 0.1 Phantom@myhost.mydomain.edu\n",argv[0]);
exit(-1);
}
float sFric = (float)atof(argv[1]);
float dFric = (float)atof(argv[2]);
char *device_name = argv[3];
printf("Connecting to %s: sFric, dFric= %f %f\n",device_name, sFric,dFric);
/* initialize the force device */
forceDevice = new vrpn_ForceDevice_Remote(device_name);
forceDevice->register_force_change_handler(NULL, handle_force_change);
/* initialize the tracker */
tracker = new vrpn_Tracker_Remote(device_name);
tracker->register_change_handler(NULL, handle_tracker_change);
/* initialize the button */
button = new vrpn_Button_Remote(device_name);
button->register_change_handler(&done, handle_button_change);
// Wait until we are connected to the server.
while (!forceDevice->connectionPtr()->connected()) {
forceDevice->mainloop();
}
// Set plane and surface parameters. Initially, the plane will be
// far outside the volume so we don't get a sudden jerk at startup.
forceDevice->set_plane(0.0, 1.0, 0.0, 100.0);
/*-------------------------------------------------------------
correct ranges for these values (from GHOST 1.2 documentation):
dynamic, static friction: 0-1.0
Kspring: 0-1.0
Kdamping: 0-0.005
An additional constraint that I discovered is that dynamic friction must
be smaller than static friction or you will get the same error. "1.0" means
the maximum stable surface presentable by the device.
--------------------------------------------------------------*/
forceDevice->setSurfaceKspring(1.0);
forceDevice->setSurfaceKdamping(0.0); // damping constant -
// units of dynes*sec/cm
forceDevice->setSurfaceFstatic(sFric); // set static friction
forceDevice->setSurfaceFdynamic(dFric); // set dynamic friction
// texture and buzzing stuff:
// this turns off buzzing and texture
forceDevice->setSurfaceBuzzAmplitude(0.0);
forceDevice->setSurfaceBuzzFrequency(60.0); // Hz
forceDevice->setSurfaceTextureAmplitude(0.00); // meters!!!
forceDevice->setSurfaceTextureWavelength((float)0.01); // meters!!!
forceDevice->setRecoveryTime(10); // recovery occurs over 10
// force update cycles
// enable force device and send first surface
forceDevice->startSurface();
printf("\n3cm sphere at the origin should be present always\n");
printf("Press and release the Phantom button 3 times to exit\n");
// main loop
while (! done )
{
// Let the forceDevice send its planes to remote force device
forceDevice->mainloop();
// Let tracker receive position information from remote tracker
tracker->mainloop();
// Let button receive button status from remote button
button->mainloop();
}
// shut off force device
forceDevice->stopSurface();
// Delete the objects
delete forceDevice;
delete button;
delete tracker;
return 0;
} /* main */
# Microsoft Developer Studio Project File - Name="sphere_client" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sphere_client - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sphere_client.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sphere_client.mak" CFG="sphere_client - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sphere_client - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sphere_client - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sphere_client - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../pc_win32/client_src/Release"
# PROP Intermediate_Dir "../pc_win32/client_src/Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /D "_CONSOLE" /D "NDEBUG" /D "_MBCS" /D "WIN32" /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../pc_win32/Release" /libpath:"../pc_win32/DLL/Release"
!ELSEIF "$(CFG)" == "sphere_client - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../pc_win32/client_src/Debug"
# PROP Intermediate_Dir "../pc_win32/client_src/Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".." /D "_CONSOLE" /D "_DEBUG" /D "_MBCS" /D "WIN32" /FR /YX /FD /c /Tp
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../pc_win32/Debug" /libpath:"../pc_win32/DLL/Debug"
!ENDIF
# Begin Target
# Name "sphere_client - Win32 Release"
# Name "sphere_client - Win32 Debug"
# Begin Source File
SOURCE=sphere_client.C
# End Source File
# End Target
# End Project
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="sphere_client"
ProjectGUID="{14E21AB6-F3E9-4CA9-BF51-1E9443979B3C}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../pc_win32/client_src/Debug"
IntermediateDirectory=".\../pc_win32/client_src/Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/Debug/sphere_client.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include&quot;;..;..\..\quat"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\../pc_win32/client_src/Debug/sphere_client.pch"
AssemblerListingLocation=".\../pc_win32/client_src/Debug/"
ObjectFile=".\../pc_win32/client_src/Debug/"
ProgramDataBaseFileName=".\../pc_win32/client_src/Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/Debug/sphere_client.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../pc_win32/client_src/Debug/sphere_client.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/Debug/sphere_client.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../pc_win32/client_src/Release"
IntermediateDirectory=".\../pc_win32/client_src/Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../pc_win32/client_src/Release/sphere_client.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;&quot;$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK\Include&quot;;..;..\..\quat"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\../pc_win32/client_src/Release/sphere_client.pch"
AssemblerListingLocation=".\../pc_win32/client_src/Release/"
ObjectFile=".\../pc_win32/client_src/Release/"
ProgramDataBaseFileName=".\../pc_win32/client_src/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\../pc_win32/client_src/Release/sphere_client.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(SYSTEMDRIVE)\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib"
ProgramDatabaseFile=".\../pc_win32/client_src/Release/sphere_client.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\../pc_win32/client_src/Release/sphere_client.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="sphere_client.C"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>