vrpn
07.35
Virtual Reality Peripheral Network
Toggle main menu visibility
Loading...
Searching...
No Matches
vrpn_LUDL.h
Go to the documentation of this file.
1
// Device drivers for the LUDL family of translation stage controllers.
2
// The only device currently implemented is the USBMAC6000 controller in its
3
// two-axis configuration controlling the stage for the Panoptes system
4
// at UNC Chapel Hill.
5
6
#ifndef VRPN_LUDL_H
7
#define VRPN_LUDL_H
8
9
#include "
vrpn_Analog.h
"
// for vrpn_Analog
10
#include "
vrpn_Analog_Output.h
"
// for vrpn_Analog_Output
11
#include "
vrpn_Configure.h
"
// for VRPN_CALLBACK, etc
12
#include "
vrpn_Connection.h
"
// for vrpn_CONNECTION_RELIABLE, etc
13
#include "
vrpn_Shared.h
"
// for timeval
14
#include "
vrpn_Types.h
"
// for vrpn_uint32, vrpn_uint8, etc
15
16
#if defined(VRPN_USE_LIBUSB_1_0)
17
18
// This driver uses the VRPN-preferred LibUSB-1.0 to control the device.
19
// It exposes the vrpn_Analog and the
20
// vrpn_Analog_Output interfaces, to report and set the stage position.
21
// The first two entries below enable the client to set the desired
22
// position (in ticks) and to read back when the device has finished
23
// the move to the requested position. They do not actually look at
24
// the position sensors on the device.
25
//
26
// Analog/Analog_Output channel 0 is X (0 to maximum #ticks, in ticks).
27
// Analog/Analog_Output channel 1 is Y (0 to maximum #ticks, in ticks).
28
//
29
// The next two report the actual sensor positions in X and Y. These
30
// may differ by quite a lot (a micron or more) from the requested
31
// position, so code that is watching to see if a requested move has
32
// completed should use the ones above, but those that want to know
33
// the actual postion, even as it shifts, should use the ones below.
34
//
35
// Analog channel 2 is X (0 to maximum #ticks, in ticks).
36
// Analog channel 3 is Y (0 to maximum #ticks, in ticks).
37
38
class
vrpn_LUDL_USBMAC6000
:
39
public
vrpn_Analog
,
40
public
vrpn_Analog_Output
41
{
42
public
:
43
vrpn_LUDL_USBMAC6000
(
const
char
*name,
vrpn_Connection
*c = 0,
bool
do_recenter =
false
);
44
virtual
~vrpn_LUDL_USBMAC6000
();
45
46
virtual
void
mainloop
();
47
48
protected
:
49
struct
libusb_context *
_context
;
// LibUSB context used for this device
50
struct
libusb_device_handle *
_device_handle
;
// Handle for the USB device
51
struct
timeval
_timestamp
;
52
unsigned
_endpoint
;
// Which endpoint to use to communicate with the device
53
54
// Buffer to store incoming data from the device and count of how many characters
55
// we got. Function to check and read any incoming data (and set _incount).
56
// Function to parse accumulated data.
57
static
const
unsigned
_INBUFFER_SIZE
= 1024;
58
vrpn_uint8
_inbuffer
[
_INBUFFER_SIZE
];
// MUST CHANGE the sizeof() code if this becomes not an array.
59
unsigned
_incount
;
60
bool
check_for_data
();
// False if error. True even if no data.
61
bool
interpret_usbmac_ascii_response
(
const
vrpn_uint8 *buffer,
62
int
*device_return,
63
int
*command_return,
64
int
*index_return,
65
int
*value_return);
66
67
// vrpn_Analog overridden methods.
68
// Send report iff changed
69
void
report_changes
(vrpn_uint32 class_of_service =
vrpn_CONNECTION_RELIABLE
);
70
// Send report whether or not changed
71
void
report
(vrpn_uint32 class_of_service =
vrpn_CONNECTION_RELIABLE
);
72
73
// No actual types to register, derived classes will be analogs and analog_outputs
74
int
register_types
(
void
) {
return
0; }
75
76
// Handlers for the Analog_Output messages.
79
static
int
VRPN_CALLBACK
handle_request_message
(
void
*
userdata
,
vrpn_HANDLERPARAM
p);
80
82
static
int
VRPN_CALLBACK
handle_request_channels_message
(
void
*
userdata
,
vrpn_HANDLERPARAM
p);
83
85
static
int
VRPN_CALLBACK
handle_connect_message
(
void
*
userdata
,
vrpn_HANDLERPARAM
p);
86
87
private
:
88
// Helper functions for communication with the stage
89
void
flush_input_from_ludl(
void
);
90
bool
send_usbmac_command(
unsigned
device,
unsigned
command,
unsigned
index,
int
value);
91
bool
recenter(
void
);
92
bool
ludl_axis_moving(
unsigned
axis);
// Returns true if the axis is still moving
93
bool
move_axis_to_position(
int
axis,
int
position);
94
// Returns true on success, fills in the position of the axis.
95
bool
ludl_axis_position(
unsigned
axis, vrpn_int32 *position_return);
96
97
// Stores whether we think each axis is moving and where we think each axis is
98
// going if it is moving. These are set in the move_axis_to_position() routine
99
// and used in the mainloop() routine to decide if it is time to report that we
100
// have gotten where we want to be.
101
bool
*_axis_moving;
102
vrpn_float64 *_axis_destination;
103
};
104
105
// end of OS selection
106
#endif
107
108
// end of VRPN_LUDL_H
109
#endif
vrpn_Analog_Output::vrpn_Analog_Output
vrpn_Analog_Output(const char *name, vrpn_Connection *c=NULL)
Definition
vrpn_Analog_Output.C:4
vrpn_Analog::vrpn_Analog
vrpn_Analog(const char *name, vrpn_Connection *c=NULL)
Definition
vrpn_Analog.C:14
vrpn_BaseClassUnique::userdata
void * userdata
Definition
vrpn_BaseClass.h:290
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition
vrpn_Connection.h:561
vrpn_LUDL_USBMAC6000::_inbuffer
vrpn_uint8 _inbuffer[_INBUFFER_SIZE]
Definition
vrpn_LUDL.h:58
vrpn_LUDL_USBMAC6000::report_changes
void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_RELIABLE)
Definition
vrpn_LUDL.C:263
vrpn_LUDL_USBMAC6000::check_for_data
bool check_for_data()
Definition
vrpn_LUDL.C:171
vrpn_LUDL_USBMAC6000::register_types
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
Definition
vrpn_LUDL.h:74
vrpn_LUDL_USBMAC6000::interpret_usbmac_ascii_response
bool interpret_usbmac_ascii_response(const vrpn_uint8 *buffer, int *device_return, int *command_return, int *index_return, int *value_return)
Definition
vrpn_LUDL.C:323
vrpn_LUDL_USBMAC6000::_endpoint
unsigned _endpoint
Definition
vrpn_LUDL.h:52
vrpn_LUDL_USBMAC6000::handle_connect_message
static int VRPN_CALLBACK handle_connect_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a connection request with a report of the values.
Definition
vrpn_LUDL.C:627
vrpn_LUDL_USBMAC6000::handle_request_message
static int VRPN_CALLBACK handle_request_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a request to change one of the values by setting the channel to that value.
Definition
vrpn_LUDL.C:572
vrpn_LUDL_USBMAC6000::mainloop
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition
vrpn_LUDL.C:209
vrpn_LUDL_USBMAC6000::report
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_RELIABLE)
Definition
vrpn_LUDL.C:257
vrpn_LUDL_USBMAC6000::_device_handle
struct libusb_device_handle * _device_handle
Definition
vrpn_LUDL.h:50
vrpn_LUDL_USBMAC6000::_timestamp
struct timeval _timestamp
Definition
vrpn_LUDL.h:51
vrpn_LUDL_USBMAC6000::vrpn_LUDL_USBMAC6000
vrpn_LUDL_USBMAC6000(const char *name, vrpn_Connection *c=0, bool do_recenter=false)
Definition
vrpn_LUDL.C:48
vrpn_LUDL_USBMAC6000::~vrpn_LUDL_USBMAC6000
virtual ~vrpn_LUDL_USBMAC6000()
Definition
vrpn_LUDL.C:149
vrpn_LUDL_USBMAC6000::_context
struct libusb_context * _context
Definition
vrpn_LUDL.h:49
vrpn_LUDL_USBMAC6000::_incount
unsigned _incount
Definition
vrpn_LUDL.h:59
vrpn_LUDL_USBMAC6000::handle_request_channels_message
static int VRPN_CALLBACK handle_request_channels_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a request to change multiple channels at once.
Definition
vrpn_LUDL.C:599
vrpn_LUDL_USBMAC6000::_INBUFFER_SIZE
static const unsigned _INBUFFER_SIZE
Definition
vrpn_LUDL.h:57
vrpn_HANDLERPARAM
This structure is what is passed to a vrpn_Connection message callback.
Definition
vrpn_Connection.h:41
vrpn_Analog.h
vrpn_Analog_Output.h
vrpn_Configure.h
VRPN_CALLBACK
#define VRPN_CALLBACK
Definition
vrpn_Configure.h:649
vrpn_Connection.h
vrpn_CONNECTION_RELIABLE
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
Definition
vrpn_Connection.h:118
vrpn_Shared.h
vrpn_Types.h
vrpn_LUDL.h
Generated by
1.17.0