vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
vrpn_IDEA.h
Go to the documentation of this file.
1#ifndef VRPN_IDEA_H
2#define VRPN_IDEA_H
3
4//------------------------------------------------------------------------------
5// Driver for the Haydon-Kerk IDEA PCM4806X motor controller.
6// This assumes that the operating system has provided a virtual COM port
7// for the device, so that it can be opened as a serial device. Both
8// Windows 7 and Ubuntu Linux provided this by default as of 8/6/2012.
9// This driver does not support the daisy-chained configuration of the
10// devices (which is available for RS-485 devices). If you do not find
11// the serial device, you may need to install the device driver for the FTDI
12// chipset it uses under Windows.
13
14// See http://www.haydonkerk.com/LinkClick.aspx?fileticket=LEcwYeRmKVg%3d&tabid=331
15// for the software manual for this device.
16
17#include "vrpn_Analog.h" // for vrpn_Serial_Analog
18#include "vrpn_Button.h" // for vrpn_Button_Filter
19#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output
20#include "vrpn_Configure.h" // for VRPN_CALLBACK, VRPN_API
21#include "vrpn_Connection.h" // for vrpn_CONNECTION_RELIABLE, etc
22#include "vrpn_Shared.h" // for timeval
23#include "vrpn_Types.h" // for vrpn_float64, vrpn_uint32
24
25// XXX Add two buttons to the device, to report limit-switch state.
26
29{
30public:
31 vrpn_IDEA (const char * name, vrpn_Connection * c, const char * port
32 , int run_speed_tics_sec = 3200
33 , int start_speed_tics_sec = 1200
34 , int end_speed_tics_sec = 2000
35 , int accel_rate_tics_sec_sec = 40000
36 , int decel_rate_tics_sec_sec = 100000
37 , int run_current = 290
38 , int hold_current = 0
39 , int accel_current = 290
40 , int decel_current = 290
41 , int delay = 50
42 , int step = 8 // Microstepping to do; 1/step steps
43 , int high_limit_index = -1 // Input index for high limits switch (-1 for none)
44 , int low_limit_index = -1 // Input index fro low limit switch (-1 for none)
45 , int output_1_setting = -1
46 , int output_2_setting = -1
47 , int output_3_setting = -1
48 , int output_4_setting = -1
49 , double initial_move = 0 // Move to one end of travel when reset
50 , double fractional_c_a = 1.0 // Use lower accel and current during this move
51 , double reset_location = 0.0 // Where to set the value to after reset
52 );
54
56 virtual void mainloop ();
57
58 protected:
59 unsigned char d_buffer[512]; //< Buffer of characters in report
60 unsigned d_bufcount; //< How many characters we have so far
61
62 struct timeval d_timestamp; //< Time of the last report from the device
63
74 int d_step;
84 struct timeval d_last_poll;
85
86 virtual int reset(void); //< Set device back to starting config
87 virtual int get_report(void); //< Try to read a report from the device
88
90 // Returns true if all characters could be sent. Returns false
91 // on failure.
92 bool send_command(const char *cmd);
93
95 // Scale the acceleration and current values for the move by the
96 // specified fraction between 0 and 1. This lets us execute
97 // "gentler" moves for doing things like jamming against the rails,
98 // so we don't get stuck.
99 bool send_move_request(vrpn_float64 location_in_steps, double scale = 1.0);
100
102 // the command asking the motor to move until it says that we are no
103 // longer moving.
104 bool move_until_done_or_error(vrpn_float64 location_in_steps, double scale = 1.0);
105
107 // found, and 1 on value found. Store the result into our analog channel 0.
108 int convert_report_to_position(unsigned char *buf);
109
111 // found, and 1 on value found. Store the results of our input reads into
112 // buttons 0-3.
113 int convert_report_to_buttons(unsigned char *buf);
114
116 virtual void report_changes
117 (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
119 virtual void report
120 (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
121
125
128
131};
132
133#endif
vrpn_Analog_Output(const char *name, vrpn_Connection *c=NULL)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
Definition vrpn_Analog.C:94
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
Definition vrpn_Analog.C:71
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Button_Filter(const char *, vrpn_Connection *c=NULL)
Generic connection class not specific to the transport mechanism.
double d_initial_move
Definition vrpn_IDEA.h:81
int d_accel_rate_tics_sec_sec
Definition vrpn_IDEA.h:67
bool send_command(const char *cmd)
Appends carriage-return and then sends the command.
Definition vrpn_IDEA.C:119
struct timeval d_timestamp
Definition vrpn_IDEA.h:62
int d_high_limit_index
Definition vrpn_IDEA.h:75
int d_delay
Definition vrpn_IDEA.h:73
int d_end_speed_tics_sec
Definition vrpn_IDEA.h:66
struct timeval d_last_poll
Definition vrpn_IDEA.h:84
int d_run_current
Definition vrpn_IDEA.h:69
bool send_move_request(vrpn_float64 location_in_steps, double scale=1.0)
Request a move from the motor to the specified location.
Definition vrpn_IDEA.C:155
int d_accel_current
Definition vrpn_IDEA.h:71
int d_decel_rate_tics_sec_sec
Definition vrpn_IDEA.h:68
int d_hold_current
Definition vrpn_IDEA.h:70
int d_low_limit_index
Definition vrpn_IDEA.h:76
int d_output_3_setting
Definition vrpn_IDEA.h:79
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_IDEA.C:885
int d_run_speed_tics_sec
Definition vrpn_IDEA.h:64
int d_output_2_setting
Definition vrpn_IDEA.h:78
virtual int get_report(void)
Definition vrpn_IDEA.C:726
vrpn_IDEA(const char *name, vrpn_Connection *c, const char *port, int run_speed_tics_sec=3200, int start_speed_tics_sec=1200, int end_speed_tics_sec=2000, int accel_rate_tics_sec_sec=40000, int decel_rate_tics_sec_sec=100000, int run_current=290, int hold_current=0, int accel_current=290, int decel_current=290, int delay=50, int step=8, int high_limit_index=-1, int low_limit_index=-1, int output_1_setting=-1, int output_2_setting=-1, int output_3_setting=-1, int output_4_setting=-1, double initial_move=0, double fractional_c_a=1.0, double reset_location=0.0)
Definition vrpn_IDEA.C:31
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_IDEA.C:913
int d_step
Definition vrpn_IDEA.h:74
int convert_report_to_buttons(unsigned char *buf)
Parses an input/output report. Returns -1 on failure, 0 on no value.
Definition vrpn_IDEA.C:321
virtual int reset(void)
Definition vrpn_IDEA.C:372
int d_decel_current
Definition vrpn_IDEA.h:72
int convert_report_to_position(unsigned char *buf)
Parses a position report. Returns -1 on failure, 0 on no value.
Definition vrpn_IDEA.C:294
unsigned char d_buffer[512]
Definition vrpn_IDEA.h:59
bool move_until_done_or_error(vrpn_float64 location_in_steps, double scale=1.0)
Send a move request and then wait for the move to complete. Repeat.
Definition vrpn_IDEA.C:245
int d_output_1_setting
Definition vrpn_IDEA.h:77
unsigned d_bufcount
Definition vrpn_IDEA.h:60
double d_fractional_c_a
Definition vrpn_IDEA.h:82
double d_reset_location
Definition vrpn_IDEA.h:83
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_IDEA.C:941
int d_start_speed_tics_sec
Definition vrpn_IDEA.h:65
int d_output_4_setting
Definition vrpn_IDEA.h:80
vrpn_Serial_Analog(const char *name, vrpn_Connection *connection, const char *port, int baud=9600, int bits=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
This structure is what is passed to a vrpn_Connection message callback.
#define VRPN_API
#define VRPN_CALLBACK
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...