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
Select Git revision
  • cli_segfault_test
  • commands-dev
  • commands-dev-backend
  • commands-to-make-andy-happy
  • groundStation-dev-cli
  • groundStation-dev-cli-setpoint
  • groundStation-dev-frontend-pid
  • groundStation-dev-getpid
  • groundStation-dev-quad-response
  • groundstation-datalog-vrpn
  • groundstation-dev-cliCommandHelpMessages
  • master
  • new-commands
  • new-uart
  • new-uart-circ
  • quad-auto-height
  • update-commands
17 results

Target

Select target project
  • danc/MicroCART
  • snawerdt/MicroCART_17-18
  • bbartels/MicroCART_17-18
  • jonahu/MicroCART
4 results
Select Git revision
  • develop
  • master
  • 2020-team-final-state
  • Lab_Part_1_tag
  • Lab_Part_2_tag
  • sdmay25-32-final
  • team_17-16_demo
  • team_17-16_v1
  • team_17-16_v2
  • team_18-17
10 results
Show changes
Showing
with 0 additions and 388 deletions
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
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