R2R
Utilities.h
Go to the documentation of this file.
1 
13 #ifndef UTILITIES_H_
14 #define UTILITIES_H_
15 
16 #define DECIMATION 10 // Decimate the data if necessary
17 #define REFERENCE_DATA 10000 // Reference data for trajectory tracking
18 #define BUFLEN 10000 // Actual data; sent to client using circular buffer
19 
23 typedef enum {
24  IDLE,
25  PWM,
26  HOLD,
32  } mode; // define data structure containing modes
33 
34 
38 typedef struct {
39  int refPos[REFERENCE_DATA];
40  int actPos[BUFLEN];
41  int u[BUFLEN];
43 
51 void setNclient(int n);
52 
61 int boundInt(int a, int n);
62 
71 int maxInt(int a, int b);
72 
81 mode getMODE();
82 
91 void setMODE(mode newMODE);
92 
93 
102 void setN(void);
103 
112 int getN(void);
113 
114 
125 void write_refPos(int position, int index, int motor);
126 
136 int get_refPos(int index, int motor);
137 
146 int buffer_empty(void);
147 
156 int buffer_full(void);
157 
166 int buffer_read_position(int motor);
167 
176 int buffer_read_u(int motor);
177 
185 void buffer_read_increment(void);
186 
197 void buffer_write(int M1_actPos, int M2_actPos, int M1_u, int M2_u);
198 
206 void send_data(void);
207 
208 
209 #endif /* UTILITIES_H_ */
int maxInt(int a, int b)
returns the large value of the two
Definition: Utilities.c:158
Definition: Utilities.h:31
void setMODE(mode newMODE)
Sets the Mode of the robot.
Definition: Utilities.c:24
int get_refPos(int index, int motor)
Gets the reference position.
Definition: Utilities.c:60
int buffer_full(void)
Returns true if the buffer is full.
Definition: Utilities.c:78
Definition: Utilities.h:25
int boundInt(int a, int n)
Bounds a given input to a range of values.
Definition: Utilities.c:144
Definition: Utilities.h:38
void write_refPos(int position, int index, int motor)
Writes the reference position.
Definition: Utilities.c:48
void setN(void)
Receive number N of samples to save into data buffer.
Definition: Utilities.c:32
Definition: Utilities.h:24
Definition: Utilities.h:27
int getN(void)
Returns the number of samples.
Definition: Utilities.c:44
Definition: Utilities.h:29
void setNclient(int n)
Recieve number of values to store in position data arrays from client.
Definition: Utilities.c:39
Definition: Utilities.h:30
Definition: Utilities.h:28
int buffer_empty(void)
Returns true if the buffer is empty.
Definition: Utilities.c:74
void buffer_write(int M1_actPos, int M2_actPos, int M1_u, int M2_u)
Write data to buffer.
Definition: Utilities.c:116
int buffer_read_u(int motor)
Reads current value from current buffer location.
Definition: Utilities.c:95
mode
Definition: Utilities.h:23
int buffer_read_position(int motor)
Reads position from the current buffer location.
Definition: Utilities.c:82
mode getMODE()
Return the Mode of the robot.
Definition: Utilities.c:28
void buffer_read_increment(void)
Increments the buffer read index.
Definition: Utilities.c:109
void send_data(void)
Send data to client when it becomes available.
Definition: Utilities.c:129
Definition: Utilities.h:26