12 bool load_buf(GCon g,
const std::vector<int>& positions_A,
13 const std::vector<int>& positions_B,
int capacity,
int& cmd);
16 GReturn
contour(GCon g,
char* fileA,
char* fileB)
18 char buf[G_SMALL_BUFFER];
21 int positionA = 0, positionB = 0;
33 e(GCmd(g,
"PA 0, 0"));
34 e(GMotionComplete(g,
"AB"));
45 if (positions_A.size() != positions_B.size())
47 cout <<
"Error: The two datasets are not the same size\n";
48 return GALIL_EXAMPLE_ERROR;
57 e(GCmdI(g,
"CM?", &capacity));
59 }
while (
load_buf(g, positions_A, positions_B, capacity, cmd));
61 e(GCmd(g,
"CD 0,0=0"));
66 return GALIL_EXAMPLE_OK;
70 bool load_buf(GCon g,
const std::vector<int>& positions_A,
71 const std::vector<int>& positions_B,
int capacity,
int& cmd)
73 char buf[G_SMALL_BUFFER];
74 for (capacity; capacity > 0; capacity--)
77 if (cmd + 1 < positions_A.size())
80 int cdA = positions_A[cmd + 1] - positions_A[cmd];
83 int cdB = positions_B[cmd + 1] - positions_B[cmd];
85 sprintf(buf,
"CD %d,%d", cdA, cdB);
100 std::vector<int> positions;
103 char position[G_SMALL_BUFFER];
106 is.getline(position, 16,
',');
110 int i_position = strtol(position, &end, 10);
111 positions.push_back(i_position);
bool load_buf(GCon g, const std::vector< int > &positions_A, const std::vector< int > &positions_B, int capacity, int &cmd)
Loads contour buffer with commands from the given text file.
std::vector< int > csv_to_vector(ifstream &is)
Converts a file of comma separated values to a vector.
GReturn record_position(GCon g, char *fileA, char *fileB)
Record user's training and saves to a text file.
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
GReturn contour(GCon g, char *fileA, char *fileB)
Record user's training and plays back training through contour mode.