PTUFree.cpp
Go to the documentation of this file.
1 #include "driver/PTUFree.h"
2 
3 namespace ptu_free {
4 
5  PTUFree::PTUFree():ptu_io_service(), timer_io_service(), ptu_port(ptu_io_service) {
6 
7  }
8  PTUFree::PTUFree(boost::asio::io_service& io): timer_io_service(), ptu_port(io) {
9 
10  }
11 
12  bool PTUFree::setBaudRate(int baud) {
13  printf("Setting baud rate\n");
14  boost::system::error_code set_option_error_code;
15  ptu_port.set_option(boost::asio::serial_port_base::baud_rate(baud), set_option_error_code);
16  if(set_option_error_code.value() != boost::system::errc::success) {
17  std::string error_reason = getErrorString(set_option_error_code);
18  printf("Setting baud to %d failed with error message: %s\n", baud, error_reason.c_str());
19  return false;
20  }
21  else {
22  printf("Success\n");
23  return true;
24  }
25  }
26 
27  bool PTUFree::setNewSerialConnection(std::string port, int baud)
28  {
29  printf("Setting new Connection\n");
30  if(ptu_port.is_open()) {
31  printf("Closing current Serial Port Connection\n");
33  }
34 
35  boost::system::error_code open_error_code;
36  ptu_port.open(port, open_error_code);
37  if(open_error_code.value() != boost::system::errc::success) {
38  std::string error_reason = getErrorString(open_error_code);
39  printf("Opening port %s failed with error message: %s", port.c_str(), error_reason.c_str());
40  return false;
41  }
42  //PTU sends some data at the beginning, eg. distrubuter and model name. This sleep command makes sure that everything has been send before buffer is cleared
43  sleep(2);
44  //To get rid of possible remaing stuff in the buffer of the new port used (from possible former usage, e.g. through other program)
45  tcflush(ptu_port.lowest_layer().native_handle(), TCIOFLUSH);
46 
47  ptu_port.set_option(boost::asio::serial_port_base::baud_rate(9600));
48  ptu_port.set_option(boost::asio::serial_port_base::character_size(8));
49  ptu_port.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
50  ptu_port.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
51  ptu_port.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));
52 
53  communicate("ed ");
54  reset();
55  //Are those neccesary or rather bad because it works against the defaults if set? NOTE: temporarily solved by comments in the method documentation
59  //necessary to get initial values for the internal variables
64  return true;
65  }
66 
68  ptu_port.close();
69  }
70 
71  std::string PTUFree::communicate(std::string request) {
72  boost::asio::write(ptu_port, boost::asio::buffer(request.c_str(), request.size()));
73  std::string response = readPTUResponse();
74  return response;
75  }
76 
77 
78 
79  std::string PTUFree::readPTUResponse() {
80  std::string recieved_message;
81  char current_letter;
82  while(true) {
83  boost::asio::read(ptu_port, boost::asio::buffer(&current_letter,1));
84  if(current_letter == '\n') {
85  //HOTFIX solution: Asynchronous responses in successfull messages get cut out. In unsuccessfull messages they stay in because they gonna return false/ERROR later on anyway
86  //Only printf message can be messed up in error case a little bit. Since that error does not occure often it is tolerated for the moment.
87  size_t start_pos = recieved_message.find('*');
88  if(start_pos != std::string::npos) {
89  recieved_message = recieved_message.substr(start_pos);
90  }
91  return recieved_message;
92  }
93  else {
94  recieved_message.push_back(current_letter);
95  }
96  }
97  }
98 
99  std::vector<std::string> PTUFree::evaluateResponse(std::string response) {
100  std::vector<std::string> result;
101  result.push_back(response.substr(0, 1));
102  if(response.at(0) == '*') {
103  result.push_back(response.substr(1, response.length() - 1));
104  int start_position = 10000;
105  int end_position = 0;
106  size_t first_found_position = 0;
107  size_t last_found_position = 0;
108  for (int i = 0; i < 10; i++) {
109  first_found_position = response.find(boost::lexical_cast<std::string>(i));
110  if(first_found_position != std::string::npos) {
111  if((int) first_found_position < start_position) {
112  start_position = first_found_position;
113  }
114  }
115  last_found_position = response.rfind(boost::lexical_cast<std::string>(i));
116  if( last_found_position != std::string::npos) {
117  if((int) last_found_position > end_position) {
118  end_position = last_found_position;
119  }
120  }
121  }
122  if(start_position <= end_position) {
123  if(response.at(start_position - 1) == '-') {
124  start_position -= 1;
125  }
126  result.push_back(response.substr(start_position, end_position - start_position + 1));
127  }
128  }
129  //In this case the first character is '!'
130  else {
131  //First character identifies if it was successfull or not and therefore is not needed here.
132  result.push_back(response.substr(1, response.length() - 1));
133  }
134  return result;
135  }
136 
137 
138 
139  bool PTUFree::setDesiredPanPositionAbsolute(short int position) {
140  std::string command = "pp" + boost::lexical_cast<std::string>(position) + " ";
141  std::string response = communicate(command);
142  std::vector<std::string> response_parts = evaluateResponse(response);
143  if(response_parts[0].at(0) == '*') {
144  return true;
145  }
146  else {
147  printf("Error while setting desired absolute pan position to %d: %s\n", position, response_parts[1].c_str());
148  return false;
149  }
150  }
151 
152  bool PTUFree::setDesiredPanPositionRelative(short int position_offset) {
153  std::string command = "po" + boost::lexical_cast<std::string>(position_offset) + " ";
154  std::string response = communicate(command);
155  std::vector<std::string> response_parts = evaluateResponse(response);
156  if(response_parts[0].at(0) == '*') {
157  return true;
158  }
159  else {
160  printf("Error while adding desired pan position offset of %d: %s\n", position_offset, response_parts[1].c_str());
161  return false;
162  }
163  }
164 
165  bool PTUFree::setDesiredPanSpeedAbsolute(short int speed) {
166  std::string command = "ps" + boost::lexical_cast<std::string>(speed) + " ";
167  std::string response = communicate(command);
168  std::vector<std::string> response_parts = evaluateResponse(response);
169  if(response_parts[0].at(0) == '*') {
170  return true;
171  }
172  else {
173  printf("Error while setting desired absolute pan speed to %d: %s\n", speed, response_parts[1].c_str());
174  return false;
175  }
176  }
177 
178  //WARNING: OFFSET FROM CURRENT (NOT DESIRED) SPEED IS SET TO DESIRED SPEED (Example: Current speed = 0, Desired Speed = 500. set_desired_pan_speed_realtive(100) will result in
179  //current speed being 0 and desired speed being 0 + 100 = 100
180  bool PTUFree::setDesiredPanSpeedRelative(short int speed_offset) {
181  std::string command = "pd" + boost::lexical_cast<std::string>(speed_offset) + " ";
182  std::string response = communicate(command);
183  std::vector<std::string> response_parts = evaluateResponse(response);
184  if(response_parts[0].at(0) == '*') {
185  return true;
186  }
187  else {
188  printf("Error while setting desired pan speed offset to %d: %s\n", speed_offset, response_parts[1].c_str());
189  return false;
190  }
191  }
192 
193  bool PTUFree::setDesiredPanAccelerationAbsolute(short int acceleration) {
194  std::string command = "pa" + boost::lexical_cast<std::string>(acceleration) + " ";
195  std::string response = communicate(command);
196  std::vector<std::string> response_parts = evaluateResponse(response);
197  if(response_parts[0].at(0) == '*') {
198  return true;
199  }
200  else {
201  printf("Error while setting absolute pan acceleration to %d: %s\n", acceleration, response_parts[1].c_str());
202  return false;
203  }
204  }
205 
206 
207  //WARNING: TAKES EXTREMLY LONG OR DOES NOT WORK. ACCORDING TO MANUAL THIS DOES NOT WORK ON THE FLY, IN TESTING EVEN 300 SECONDS WERE NOT ENOUGH. THEREFORE NOT SUCCESSFULLY TESTED, DO NOT USE
208  bool PTUFree::setDesiredPanUpperSpeedLimit(short int upper_speed_limit) {
209  std::string command = "pu" + boost::lexical_cast<std::string>(upper_speed_limit) + " ";
210  std::string response = communicate(command);
211  std::vector<std::string> response_parts = evaluateResponse(response);
212  if(response_parts[0].at(0) == '*') {
213  return true;
214  }
215  else {
216  printf("Error while setting absolute pan base speed to %d: %s\n", upper_speed_limit, response_parts[1].c_str());
217  return false;
218  }
219  }
220 
221 
222  //WARNING: MUST BE 0 or >= 57 (last value depending on ptu)
223  //WARNING: Consumes a lot of time (usually >6 seconds) until changes are in place (not possible on the fly)
224  bool PTUFree::setDesiredPanLowerSpeedLimit(short int lower_speed_limit) {
225  std::string command = "pl" + boost::lexical_cast<std::string>(lower_speed_limit) + " ";
226  std::string response = communicate(command);
227  std::vector<std::string> response_parts = evaluateResponse(response);
228  if(response_parts[0].at(0) == '*') {
229  return true;
230  }
231  else {
232  printf("Error while setting absolute lower speed limit to %d: %s\n", lower_speed_limit, response_parts[1].c_str());
233  return false;
234  }
235  }
236 
237  bool PTUFree::setPanBaseSpeed(short int base_speed) {
238  std::string command = "pb" + boost::lexical_cast<std::string>(base_speed) + " ";
239  std::string response = communicate(command);
240  std::vector<std::string> response_parts = evaluateResponse(response);
241  if(response_parts[0].at(0) == '*') {
242  return true;
243  }
244  else {
245  printf("Error while setting pan base speed to %d: %s\n", base_speed, response_parts[1].c_str());
246  return false;
247  }
248  }
249 
250 
251 
253  std::string command = "pp ";
254  std::string response = communicate(command);
255  std::vector<std::string> response_parts = evaluateResponse(response);
256  if(response_parts[0].at(0) == '*') {
257  return boost::lexical_cast<long>(response_parts[2]);
258  }
259  else {
260  printf("Error while getting current pan position: %s\n", response_parts[1].c_str());
261  return LONG_MIN;
262  }
263  }
264 
266  std::string command = "pd ";
267  std::string response = communicate(command);
268  std::vector<std::string> response_parts = evaluateResponse(response);
269  if(response_parts[0].at(0) == '*') {
270  return boost::lexical_cast<long>(response_parts[2]);
271  }
272  else {
273  printf("Error while getting current pan speed: %s\n", response_parts[1].c_str());
274  return LONG_MIN;
275  }
276  }
277 
278 
279 
280 
282  std::string command = "pu ";
283  std::string response = communicate(command);
284  std::vector<std::string> response_parts = evaluateResponse(response);
285  if(response_parts[0].at(0) == '*') {
286  return boost::lexical_cast<long>(response_parts[2]);
287  }
288  else {
289  printf("Error while getting current pan upper speed limit: %s\n", response_parts[1].c_str());
290  return LONG_MIN;
291  }
292  }
293 
295  std::string command = "pl ";
296  std::string response = communicate(command);
297  std::vector<std::string> response_parts = evaluateResponse(response);
298  if(response_parts[0].at(0) == '*') {
299  return boost::lexical_cast<long>(response_parts[2]);
300  }
301  else {
302  printf("Error while getting curent pan lower speed limit: %s\n", response_parts[1].c_str());
303  return LONG_MIN;
304  }
305  }
306 
308  std::string command = "pr ";
309  std::string response = communicate(command);
310  std::vector<std::string> response_parts = evaluateResponse(response);
311  if(response_parts[0].at(0) == '*') {
312  return boost::lexical_cast<double>(response_parts[2]);
313  }
314  else {
315  printf("Error while getting pan resolution: %s\n", response_parts[1].c_str());
316  return -1.0;
317  }
318  }
319 
321  std::string command = "po ";
322  std::string response = communicate(command);
323  std::vector<std::string> response_parts = evaluateResponse(response);
324  if(response_parts[0].at(0) == '*') {
325  return boost::lexical_cast<long>(response_parts[2]);
326  }
327  else {
328  printf("Error while getting desired pan position: %s\n", response_parts[1].c_str());
329  return LONG_MIN;
330  }
331  }
332 
334  std::string command = "ps ";
335  std::string response = communicate(command);
336  std::vector<std::string> response_parts = evaluateResponse(response);
337  if(response_parts[0].at(0) == '*') {
338  return boost::lexical_cast<long>(response_parts[2]);
339  }
340  else {
341  printf("Error while getting desired pan speed: %s\n", response_parts[1].c_str());
342  return LONG_MIN;
343  }
344  }
345 
347  std::string command = "pa ";
348  std::string response = communicate(command);
349  std::vector<std::string> response_parts = evaluateResponse(response);
350  if(response_parts[0].at(0) == '*') {
351  return boost::lexical_cast<long>(response_parts[2]);
352  }
353  else {
354  printf("Error while getting desired pan acceleration (desired == current in this case): %s\n", response_parts[1].c_str());
355  return LONG_MIN;
356  }
357  }
358 
360  std::string command = "pb ";
361  std::string response = communicate(command);
362  std::vector<std::string> response_parts = evaluateResponse(response);
363  if(response_parts[0].at(0) == '*') {
364  return boost::lexical_cast<long>(response_parts[2]);
365  }
366  else {
367  printf("Error while getting desired pan base speed: %s\n", response_parts[1].c_str());
368  return LONG_MIN;
369  }
370  }
371 
372 
373 
374 
375  bool PTUFree::setDesiredTiltPositionAbsolute(short int position) {
376  std::string command = "tp" + boost::lexical_cast<std::string>(position) + " ";
377  std::string response = communicate(command);
378  std::vector<std::string> response_parts = evaluateResponse(response);
379  if(response_parts[0].at(0) == '*') {
380  return true;
381  }
382  else {
383  printf("Error while setting desired absolute tilt position to %d: %s\n", position, response_parts[1].c_str());
384  return false;
385  }
386  }
387 
388  bool PTUFree::setDesiredTiltPositionRelative(short int position_offset) {
389  std::string command = "to" + boost::lexical_cast<std::string>(position_offset) + " ";
390  std::string response = communicate(command);
391  std::vector<std::string> response_parts = evaluateResponse(response);
392  if(response_parts[0].at(0) == '*') {
393  return true;
394  }
395  else {
396  printf("Error while adding desired tilt position offset of %d: %s\n", position_offset, response_parts[1].c_str());
397  return false;
398  }
399  }
400 
401  bool PTUFree::setDesiredTiltSpeedAbsolute(short int speed) {
402  std::string command = "ts" + boost::lexical_cast<std::string>(speed) + " ";
403  std::string response = communicate(command);
404  std::vector<std::string> response_parts = evaluateResponse(response);
405  if(response_parts[0].at(0) == '*') {
406  return true;
407  }
408  else {
409  printf("Error while setting desired absolute tilt speed to %d: %s\n", speed, response_parts[1].c_str());
410  return false;
411  }
412  }
413 
414  //WARNING: OFFSET FROM CURRENT (NOT DESIRED) SPEED IS SET TO DESIRED SPEED (Example: Current speed = 0, Desired Speed = 500. setDesiredTiltSpeedRelative(100) will result in
415  //current speed being 0 and desired speed being 0 + 100 = 100
416  bool PTUFree::setDesiredTiltSpeedRelative(short int speed_offset) {
417  std::string command = "td" + boost::lexical_cast<std::string>(speed_offset) + " ";
418  std::string response = communicate(command);
419  std::vector<std::string> response_parts = evaluateResponse(response);
420  if(response_parts[0].at(0) == '*') {
421  return true;
422  }
423  else {
424  printf("Error while setting desired tilt speed offset to %d: %s\n", speed_offset, response_parts[1].c_str());
425  return false;
426  }
427  }
428 
429  bool PTUFree::setDesiredTiltAccelerationAbsolute(short int acceleration) {
430  std::string command = "ta" + boost::lexical_cast<std::string>(acceleration) + " ";
431  std::string response = communicate(command);
432  std::vector<std::string> response_parts = evaluateResponse(response);
433  if(response_parts[0].at(0) == '*') {
434  return true;
435  }
436  else {
437  printf("Error while setting absolute tilt acceleration to %d: %s\n", acceleration, response_parts[1].c_str());
438  return false;
439  }
440  }
441 
442 
443  //WARNING: TAKES EXTREMLY LONG OR DOES NOT WORK. ACCORDING TO MANUAL THIS DOES NOT WORK ON THE FLY, IN TESTING EVEN 300 SECONDS WERE NOT ENOUGH. THEREFORE NOT SUCCESSFULLY TESTED, DO NOT USE
444  bool PTUFree::setDesiredTiltUpperSpeedLimit(short int upper_speed_limit) {
445  std::string command = "tu" + boost::lexical_cast<std::string>(upper_speed_limit) + " ";
446  std::string response = communicate(command);
447  std::vector<std::string> response_parts = evaluateResponse(response);
448  if(response_parts[0].at(0) == '*') {
449  return true;
450  }
451  else {
452  printf("Error while setting desired tilt base speed to %d: %s\n", upper_speed_limit, response_parts[1].c_str());
453  return false;
454  }
455  }
456 
457 
458  //WARNING: MUST BE 0 or >= 57 (last value depending on ptu)
459  //WARNING: Consumes a lot of time (usually >6 seconds) until changes are in place (not possible on the fly)
460  bool PTUFree::setDesiredTiltLowerSpeedLimit(short int lower_speed_limit) {
461  std::string command = "tl" + boost::lexical_cast<std::string>(lower_speed_limit) + " ";
462  std::string response = communicate(command);
463  std::vector<std::string> response_parts = evaluateResponse(response);
464  if(response_parts[0].at(0) == '*') {
465  return true;
466  }
467  else {
468  printf("Error while setting desired tilt lower speed limit to %d: %s\n", lower_speed_limit, response_parts[1].c_str());
469  return false;
470  }
471  }
472 
473  bool PTUFree::setTiltBaseSpeed(short int base_speed) {
474  std::string command = "tb" + boost::lexical_cast<std::string>(base_speed) + " ";
475  std::string response = communicate(command);
476  std::vector<std::string> response_parts = evaluateResponse(response);
477  if(response_parts[0].at(0) == '*') {
478  return true;
479  }
480  else {
481  printf("Error while setting tilt base speed to %d: %s\n", base_speed, response_parts[1].c_str());
482  return false;
483  }
484  }
485 
486 
487 
489  std::string command = "tp ";
490  std::string response = communicate(command);
491  std::vector<std::string> response_parts = evaluateResponse(response);
492  if(response_parts[0].at(0) == '*') {
493  return boost::lexical_cast<long>(response_parts[2]);
494  }
495  else {
496  printf("Error while getting current tilt position: %s\n", response_parts[1].c_str());
497  return LONG_MIN;
498  }
499  }
500 
502  std::string command = "td ";
503  std::string response = communicate(command);
504  std::vector<std::string> response_parts = evaluateResponse(response);
505  if(response_parts[0].at(0) == '*') {
506  return boost::lexical_cast<long>(response_parts[2]);
507  }
508  else {
509  printf("Error while getting current tilt speed: %s\n", response_parts[1].c_str());
510  return LONG_MIN;
511  }
512  }
513 
514 
515 
516 
518  std::string command = "tu ";
519  std::string response = communicate(command);
520  std::vector<std::string> response_parts = evaluateResponse(response);
521  if(response_parts[0].at(0) == '*') {
522  return boost::lexical_cast<long>(response_parts[2]);
523  }
524  else {
525  printf("Error while getting current tilt upper speed limit: %s\n", response_parts[1].c_str());
526  return LONG_MIN;
527  }
528  }
529 
531  std::string command = "tl ";
532  std::string response = communicate(command);
533  std::vector<std::string> response_parts = evaluateResponse(response);
534  if(response_parts[0].at(0) == '*') {
535  return boost::lexical_cast<long>(response_parts[2]);
536  }
537  else {
538  printf("Error while getting curent tilt lower speed limit: %s\n", response_parts[1].c_str());
539  return LONG_MIN;
540  }
541  }
542 
544  std::string command = "tr ";
545  std::string response = communicate(command);
546  std::vector<std::string> response_parts = evaluateResponse(response);
547  if(response_parts[0].at(0) == '*') {
548  return boost::lexical_cast<double>(response_parts[2]);
549  }
550  else {
551  printf("Error while getting tilt resolution: %s\n", response_parts[1].c_str());
552  return -1.0;
553  }
554  }
555 
557  std::string command = "to ";
558  std::string response = communicate(command);
559  std::vector<std::string> response_parts = evaluateResponse(response);
560  if(response_parts[0].at(0) == '*') {
561  return boost::lexical_cast<long>(response_parts[2]);
562  }
563  else {
564  printf("Error while getting desired tilt position: %s\n", response_parts[1].c_str());
565  return LONG_MIN;
566  }
567  }
568 
570  std::string command = "ts ";
571  std::string response = communicate(command);
572  std::vector<std::string> response_parts = evaluateResponse(response);
573  if(response_parts[0].at(0) == '*') {
574  return boost::lexical_cast<long>(response_parts[2]);
575  }
576  else {
577  printf("Error while getting desired tilt speed: %s\n", response_parts[1].c_str());
578  return LONG_MIN;
579  }
580  }
581 
583  std::string command = "ta ";
584  std::string response = communicate(command);
585  std::vector<std::string> response_parts = evaluateResponse(response);
586  if(response_parts[0].at(0) == '*') {
587  return boost::lexical_cast<long>(response_parts[2]);
588  }
589  else {
590  printf("Error while getting desired tilt acceleration (desired == current in this case): %s\n", response_parts[1].c_str());
591  return LONG_MIN;
592  }
593  }
594 
596  std::string command = "tb ";
597  std::string response = communicate(command);
598  std::vector<std::string> response_parts = evaluateResponse(response);
599  if(response_parts[0].at(0) == '*') {
600  return boost::lexical_cast<long>(response_parts[2]);
601  }
602  else {
603  printf("Error while getting desired tilt base speed: %s\n", response_parts[1].c_str());
604  return LONG_MIN;
605  }
606  }
607 
608 
609  //WARNING: USER_DEFINED_LIMITS_ENABLED NOT SUPPORTED IN OLDER PTU VERSIONS, CASE WITH THAT LIMIT MODE NOT TESTED (PTU VERSION TOO OLD)
611  std::string command;
612  if(enable == FACTORY_LIMITS_ENABLED) {
613  command = "le ";
614  }
615  else if (enable == USER_DEFINED_LIMITS_ENABLED) {
616  command = "lu ";
617  }
618  else if (enable == LIMITS_DISABLED) {
619  command = "ld ";
620  }
621  else {
622  printf("Error while setting limit enforcement mode: Unknown mode\n");
623  return false;
624  }
625  std::string response = communicate(command);
626  std::vector<std::string> response_parts = evaluateResponse(response);
627  if(response_parts[0].at(0) == '*') {
628  return true;
629  }
630  else {
631  printf("Error while setting limit enforcement: %s\n", response_parts[1].c_str());
632  return false;
633  }
634  }
635 
636  bool PTUFree::setMinimumPanPositionLimit(short int position) {
637  std::string command = "pn" + boost::lexical_cast<std::string>(position) + " ";
638  std::string response = communicate(command);
639  std::vector<std::string> response_parts = evaluateResponse(response);
640  if(response_parts[0].at(0) == '*') {
641  return true;
642  }
643  else {
644  printf("Error while setting minimum user pan position limit to %d: %s\n", position, response_parts[1].c_str());
645  return false;
646  }
647  }
648  bool PTUFree::setMaximumPanPositionLimit(short int position) {
649  std::string command = "px" + boost::lexical_cast<std::string>(position) + " ";
650  std::string response = communicate(command);
651  std::vector<std::string> response_parts = evaluateResponse(response);
652  if(response_parts[0].at(0) == '*') {
653  return true;
654  }
655  else {
656  printf("Error while setting maximum user pan position limit to %d: %s\n", position, response_parts[1].c_str());
657  return false;
658  }
659  }
660  bool PTUFree::setMinimumTiltPositionLimit(short int position) {
661  std::string command = "tn" + boost::lexical_cast<std::string>(position) + " ";
662  std::string response = communicate(command);
663  std::vector<std::string> response_parts = evaluateResponse(response);
664  if(response_parts[0].at(0) == '*') {
665  return true;
666  }
667  else {
668  printf("Error while setting minimum user tilt position limit to %d: %s\n", position, response_parts[1].c_str());
669  return false;
670  }
671  }
672  bool PTUFree::setMaximumTiltPositionLimit(short int position) {
673  std::string command = "tx" + boost::lexical_cast<std::string>(position) + " ";
674  std::string response = communicate(command);
675  std::vector<std::string> response_parts = evaluateResponse(response);
676  if(response_parts[0].at(0) == '*') {
677  return true;
678  }
679  else {
680  printf("Error while setting maximum user tilt position limit to %d: %s\n", position, response_parts[1].c_str());
681  return false;
682  }
683  }
684 
685  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
687  std::string command = "pnu ";
688  std::string response = communicate(command);
689  std::vector<std::string> response_parts = evaluateResponse(response);
690  if(response_parts[0].at(0) == '*') {
691  return boost::lexical_cast<long>(response_parts[2]);
692  }
693  else {
694  printf("Error while getting minimum user pan position limit: %s\n", response_parts[1].c_str());
695  return ERROR;
696  }
697  }
698 
699  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
701  std::string command = "pxu ";
702  std::string response = communicate(command);
703  std::vector<std::string> response_parts = evaluateResponse(response);
704  if(response_parts[0].at(0) == '*') {
705  return boost::lexical_cast<long>(response_parts[2]);
706  }
707  else {
708  printf("Error while getting maximum user pan position limit: %s\n", response_parts[1].c_str());
709  return ERROR;
710  }
711  }
712 
713  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
715  std::string command = "tnu ";
716  std::string response = communicate(command);
717  std::vector<std::string> response_parts = evaluateResponse(response);
718  if(response_parts[0].at(0) == '*') {
719  return boost::lexical_cast<long>(response_parts[2]);
720  }
721  else {
722  printf("Error while getting minimum user tilt position limit: %s\n", response_parts[1].c_str());
723  return ERROR;
724  }
725  }
726 
727  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
729  std::string command = "txu ";
730  std::string response = communicate(command);
731  std::vector<std::string> response_parts = evaluateResponse(response);
732  if(response_parts[0].at(0) == '*') {
733  return boost::lexical_cast<long>(response_parts[2]);
734  }
735  else {
736  printf("Error while getting maximum user tilt position limit: %s\n", response_parts[1].c_str());
737  return ERROR;
738  }
739  }
740  //Needed because there is no specific command to always get the factory limits, only a command to get the limits depending on selected mode
742  return factory_pan_min;
743  }
745  return factory_pan_max;
746  }
748  return factory_tilt_min;
749  }
751  return factory_tilt_max;
752  }
754  std::string command = "pn ";
755  std::string response = communicate(command);
756  std::vector<std::string> response_parts = evaluateResponse(response);
757  if(response_parts[0].at(0) == '*') {
758  return boost::lexical_cast<long>(response_parts[2]);
759  }
760  else {
761  printf("Error while getting currently used minimum pan position limit: %s\n", response_parts[1].c_str());
762  return ERROR;
763  }
764  }
766  std::string command = "px ";
767  std::string response = communicate(command);
768  std::vector<std::string> response_parts = evaluateResponse(response);
769  if(response_parts[0].at(0) == '*') {
770  return boost::lexical_cast<long>(response_parts[2]);
771  }
772  else {
773  printf("Error while getting currently used maximum pan position limit: %s\n", response_parts[1].c_str());
774  return ERROR;
775  }
776  }
778  std::string command = "tn ";
779  std::string response = communicate(command);
780  std::vector<std::string> response_parts = evaluateResponse(response);
781  if(response_parts[0].at(0) == '*') {
782  return boost::lexical_cast<long>(response_parts[2]);
783  }
784  else {
785  printf("Error while getting currently used minimum tilt position limit: %s\n", response_parts[1].c_str());
786  return ERROR;
787  }
788  }
790  std::string command = "tx ";
791  std::string response = communicate(command);
792  std::vector<std::string> response_parts = evaluateResponse(response);
793  if(response_parts[0].at(0) == '*') {
794  return boost::lexical_cast<long>(response_parts[2]);
795  }
796  else {
797  printf("Error while getting currently used maximum tilt position limit: %s\n", response_parts[1].c_str());
798  return ERROR;
799  }
800  }
801 
802 
803 
805  std::string command = "l ";
806  std::string response = communicate(command);
807  std::vector<std::string> response_parts = evaluateResponse(response);
808  if(response.at(0) == '*') {
809  if(response_parts[1].find("DISABLED") != std::string::npos) {
810  return LIMITS_DISABLED;
811  }
812  else if (response_parts[1].find("user") != std::string::npos) {
814  }
815  else {
816  return FACTORY_LIMITS_ENABLED;
817  }
818  }
819  else {
820  printf("Error while getting currently used limit enforcement mode, %s\n", response_parts[1].c_str());
821  return ERROR;
822  }
823  }
824 
826  std::string command;
827  long new_mode;
829  command = "i ";
831  }
832  else if (mode == SLAVED_POSITION_EXECUTION_MODE) {
833  command = "s ";
835  }
836  else {
837  printf("Error while setting position execution mode: Unknown mode\n");
838  return false;
839  }
840  std::string response = communicate(command);
841  std::vector<std::string> response_parts = evaluateResponse(response);
842  if(response_parts[0].at(0) == '*') {
843  position_execution_mode = new_mode;
844  return true;
845  }
846  else {
847  printf("Error while setting position execution mode: %s\n", response_parts[1].c_str());
848  return false;
849  }
850  }
851 
852 
853  //no method found on ptu interface to get this mode
856  }
857 
858  //PTU waits until last position command is fully executed
860  std::string command = "a ";
861  std::string response = communicate(command);
862  std::vector<std::string> response_parts = evaluateResponse(response);
863  if(response_parts[0].at(0) == '*') {
864  return true;
865  }
866  else {
867  printf("Error while awaiting command completion: %s\n", response_parts[1].c_str());
868  return false;
869  }
870  }
871 
872  bool PTUFree::halt(long axis) {
873  std::string command;
874  if(axis == HALT_PAN_ONLY) {
875  command = "hp ";
876  }
877  else if (axis == HALT_TILT_ONLY) {
878  command = "ht ";
879  }
880  else if (axis == HALT_BOTH) {
881  command = "h ";
882  }
883  else {
884  printf("Error while halting axis: Unknown mode\n");
885  return false;
886  }
887  std::string response = communicate(command);
888  std::vector<std::string> response_parts = evaluateResponse(response);
889  if(response_parts[0].at(0) == '*') {
890  return true;
891  }
892  else {
893  printf("Error while halting axis: %s\n", response_parts[1].c_str());
894  return false;
895  }
896  }
897 
898  //Typical errors (e.g. pan/tilt out of bounds) get handled properly, untypical errors can not be handled really well due to the usage of serial port, in that case false is returned to indicate the error
899  //and the functions print the kind of error to console.
900  bool PTUFree::setDesiredPanTiltPositionAbsoluteSlaved(short int pan, short int tilt) {
901  long previous_mode = getPositionExecutionMode();
903  if(!worked) {
904  return false;
905  }
906  short int prev_pan = getDesiredPanPosition();
907  worked = setDesiredPanPositionAbsolute(pan);
908  if(!worked) {
909  setPositionExecutionMode(previous_mode);
910  return false;
911  }
912  short int prev_tilt = getDesiredTiltPosition();
913  worked = setDesiredTiltPositionAbsolute(tilt);
914  if(!worked) {
916  setPositionExecutionMode(previous_mode);
917  return false;
918  }
920  if(!worked) {
923  setPositionExecutionMode(previous_mode);
924  return false;
925  }
926  worked = setPositionExecutionMode(previous_mode);
927  if(!worked) {
928  return false;
929  }
930  return true;
931  }
932 
933 
934 
935  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
936  bool PTUFree::setPreset(int preset_index, short int pan, short int tilt) {
937  short int prev_pan = getDesiredPanPosition();
939  return false;
940  }
941  if(!setDesiredTiltPositionAbsolute(tilt)) {
943  return false;
944  }
946  return setPreset(preset_index);
947 
948  }
949 
950 
951  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
952  bool PTUFree::setPreset(int preset_index) {
953  if((0 > preset_index) || (preset_index > 32)) {
954  return false;
955  }
956  std::string command = "xs" + boost::lexical_cast<std::string>(preset_index) + " ";
957  std::string response = communicate(command);
958  std::vector<std::string> response_parts = evaluateResponse(response);
959  if(response_parts[0].at(0) == '*') {
960  return true;
961  }
962  else {
963  printf("Error while setting position preset: %s\n", response_parts[1].c_str());
964  return false;
965  }
966  }
967 
968  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
969  bool PTUFree::gotoPreset(int preset_index) {
970  std::string command = "xg" + boost::lexical_cast<std::string>(preset_index) + " ";
971  std::string response = communicate(command);
972  std::vector<std::string> response_parts = evaluateResponse(response);
973  if(response_parts[0].at(0) == '*') {
974  return true;
975  }
976  else {
977  printf("Error while going to position preset: %s\n", response_parts[1].c_str());
978  return false;
979  }
980  }
981 
982  //WARNING: NOT SUPPORTED IN OLDER PTU VERSIONS, NOT TESTED (PTU VERSION TOO OLD)
984  std::string command = "xc ";
985  std::string response = communicate(command);
986  std::vector<std::string> response_parts = evaluateResponse(response);
987  if(response_parts[0].at(0) == '*') {
988  return true;
989  }
990  else {
991  printf("Error while clearing position presets: %s\n", response_parts[1].c_str());
992  return false;
993  }
994  }
995 
997  std::string command;
998  if(mode == INDEPENDENT_SPEED_MODE) {
999  command = "ci ";
1000  }
1001  else if (mode == PURE_VELOCITY_CONTROL_MODE) {
1002  command = "cv ";
1003  }
1004  else {
1005  printf("Error while setting speed control mode: Unknown command\n");
1006  return false;
1007  }
1008  std::string response = communicate(command);
1009  std::vector<std::string> response_parts = evaluateResponse(response);
1010  if(response_parts[0].at(0) == '*') {
1011  return true;
1012  }
1013  else {
1014  printf("Error while setting speed control mode: %s\n", response_parts[1].c_str());
1015  return false;
1016  }
1017  }
1018 
1019 
1021  std::string command = "c ";
1022  std::string response = communicate(command);
1023  std::vector<std::string> response_parts = evaluateResponse(response);
1024  if(response_parts[0].at(0) == '*') {
1025  if(response_parts[1].find("independent") != std::string::npos) {
1026  return INDEPENDENT_SPEED_MODE;
1027  }
1028  else {
1030  }
1031  }
1032  else {
1033  printf("Error while getting speed control mode: %s\n", response_parts[1].c_str());
1034  return ERROR;
1035  }
1036  }
1037 
1039  std::string command = "r ";
1040  std::string response = communicate(command);
1041  printf("RESET MESSAGE: %s\n", response.c_str());
1042  std::vector<std::string> response_parts = evaluateResponse(response);
1043  if(response_parts[0].at(0) == '*') {
1044  return true;
1045  }
1046  else {
1047  printf("Error while resetting the ptu unit: %s\n", response_parts[1].c_str());
1048  return false;
1049  }
1050  }
1051 
1052  bool PTUFree::setResetMode(long mode) {
1053  std::string command;
1054  if(mode == NO_RESET_MODE) {
1055  command = "rd ";
1056  }
1057  else if (mode == PAN_ONLY_RESET_MODE) {
1058  command = "rp ";
1059  }
1060  else if (mode == TILT_ONLY_RESET_MODE) {
1061  command = "rt ";
1062  }
1063  else if (mode == BOTH_RESET_MODE) {
1064  command = "re ";
1065  }
1066  else {
1067  printf("Error while setting reset mode: Unknown command\n");
1068  return false;
1069  }
1070  std::string response = communicate(command);
1071  std::vector<std::string> response_parts = evaluateResponse(response);
1072  if(response_parts[0].at(0) == '*') {
1073  return true;
1074  }
1075  else {
1076  printf("Error while setting reset mode: %s\n", response_parts[1].c_str());
1077  return false;
1078  }
1079  }
1080 
1082  std::string command = "ds ";
1083  std::string response = communicate(command);
1084  std::vector<std::string> response_parts = evaluateResponse(response);
1085  if(response_parts[0].at(0) == '*') {
1086  return true;
1087  }
1088  else {
1089  printf("Error while saving current axis settings as default: %s\n", response_parts[1].c_str());
1090  return false;
1091  }
1092  }
1093 
1095  std::string command = "dr ";
1096  std::string response = communicate(command);
1097  std::vector<std::string> response_parts = evaluateResponse(response);
1098  if(response_parts[0].at(0) == '*') {
1099  return true;
1100  }
1101  else {
1102  printf("Error while restoring default axis settings: %s\n", response_parts[1].c_str());
1103  return false;
1104  }
1105  }
1106 
1108  std::string command = "df ";
1109  std::string response = communicate(command);
1110  std::vector<std::string> response_parts = evaluateResponse(response);
1111  if(response_parts[0].at(0) == '*') {
1112  return true;
1113  }
1114  else {
1115  printf("Error while restoring factory default axis settings: %s\n", response_parts[1].c_str());
1116  return false;
1117  }
1118  }
1119 
1121  std::string command;
1122  if(mode == REGULAR_HOLD_POWER_MODE) {
1123  command = "phr ";
1124  }
1125  else if (mode == LOW_HOLD_POWER_MODE) {
1126  command = "phl ";
1127  }
1128  else if (mode == OFF_HOLD_POWER_MODE) {
1129  command = "pho ";
1130  }
1131  else {
1132  printf("Error while setting pan stationary power mode: Unknown command\n");
1133  return false;
1134  }
1135  std::string response = communicate(command);
1136  std::vector<std::string> response_parts = evaluateResponse(response);
1137  if(response_parts[0].at(0) == '*') {
1138  return true;
1139  }
1140  else {
1141  printf("Error while setting pan stationary power mode: %s\n", response_parts[1].c_str());
1142  return false;
1143  }
1144  }
1145 
1147  std::string command;
1148  if(mode == REGULAR_HOLD_POWER_MODE) {
1149  command = "thr ";
1150  }
1151  else if (mode == LOW_HOLD_POWER_MODE) {
1152  command = "thl ";
1153  }
1154  else if (mode == OFF_HOLD_POWER_MODE) {
1155  command = "tho ";
1156  }
1157  else {
1158  printf("Error while setting pan stationary power mode: Unknown command\n");
1159  return false;
1160  }
1161  std::string response = communicate(command);
1162  std::vector<std::string> response_parts = evaluateResponse(response);
1163  if(response_parts[0].at(0) == '*') {
1164  return true;
1165  }
1166  else {
1167  printf("Error while setting pan stationary power mode: %s\n", response_parts[1].c_str());
1168  return false;
1169  }
1170  }
1171 
1173  std::string command = "ph ";
1174  std::string response = communicate(command);
1175  std::vector<std::string> response_parts = evaluateResponse(response);
1176  if(response_parts[0].at(0) == '*') {
1177  if(response_parts[1].find("REGULAR") != std::string::npos) {
1178  return REGULAR_HOLD_POWER_MODE;
1179  }
1180  if(response_parts[1].find("LOW") != std::string::npos) {
1181  return LOW_HOLD_POWER_MODE;
1182  }
1183  else {
1184  return OFF_HOLD_POWER_MODE;
1185  }
1186  }
1187  else {
1188  printf("Error while getting pan stationary power mode: %s\n", response_parts[1].c_str());
1189  return ERROR;
1190  }
1191  }
1193  std::string command = "th ";
1194  std::string response = communicate(command);
1195  std::vector<std::string> response_parts = evaluateResponse(response);
1196  if(response_parts[0].at(0) == '*') {
1197  if(response_parts[1].find("REGULAR") != std::string::npos) {
1198  return REGULAR_HOLD_POWER_MODE;
1199  }
1200  if(response_parts[1].find("LOW") != std::string::npos) {
1201  return LOW_HOLD_POWER_MODE;
1202  }
1203  else {
1204  return OFF_HOLD_POWER_MODE;
1205  }
1206  }
1207  else {
1208  printf("Error while getting tilt stationary power mode: %s\n", response_parts[1].c_str());
1209  return ERROR;
1210  }
1211  }
1212 
1214  std::string command;
1215  if(mode == HIGH_MOVE_POWER_MODE) {
1216  command = "pmh ";
1217  }
1218  else if (mode == REGULAR_MOVE_POWER_MODE) {
1219  command = "pmr ";
1220  }
1221  else if (mode == LOW_MOVE_POWER_MODE) {
1222  command = "pml ";
1223  }
1224  else {
1225  printf("Error while setting pan in-motion power mode: Unknown command\n");
1226  return false;
1227  }
1228  std::string response = communicate(command);
1229  std::vector<std::string> response_parts = evaluateResponse(response);
1230  if(response_parts[0].at(0) == '*') {
1231  return true;
1232  }
1233  else {
1234  printf("Error while setting pan in-motion power mode: %s\n", response_parts[1].c_str());
1235  return false;
1236  }
1237  }
1239  std::string command;
1240  if(mode == HIGH_MOVE_POWER_MODE) {
1241  command = "tmh ";
1242  }
1243  else if (mode == REGULAR_MOVE_POWER_MODE) {
1244  command = "tmr ";
1245  }
1246  else if (mode == LOW_MOVE_POWER_MODE) {
1247  command = "tml ";
1248  }
1249  else {
1250  printf("Error while setting tilt in-motion power mode: Unknown command\n");
1251  return false;
1252  }
1253  std::string response = communicate(command);
1254  std::vector<std::string> response_parts = evaluateResponse(response);
1255  if(response_parts[0].at(0) == '*') {
1256  return true;
1257  }
1258  else {
1259  printf("Error while setting tilt in-motion power mode: %s\n", response_parts[1].c_str());
1260  return false;
1261  }
1262  }
1263 
1265  std::string command = "pm ";
1266  std::string response = communicate(command);
1267  std::vector<std::string> response_parts = evaluateResponse(response);
1268  if(response_parts[0].at(0) == '*') {
1269  if(response_parts[1].find("REGULAR") != std::string::npos) {
1270  return REGULAR_MOVE_POWER_MODE;
1271  }
1272  if(response_parts[1].find("LOW") != std::string::npos) {
1273  return LOW_MOVE_POWER_MODE;
1274  }
1275  else {
1276  return HIGH_MOVE_POWER_MODE;
1277  }
1278  }
1279  else {
1280  printf("Error while getting pan in-motion power mode: %s\n", response_parts[1].c_str());
1281  return ERROR;
1282  }
1283  }
1285  std::string command = "tm ";
1286  std::string response = communicate(command);
1287  std::vector<std::string> response_parts = evaluateResponse(response);
1288  if(response_parts[0].at(0) == '*') {
1289  if(response_parts[1].find("REGULAR") != std::string::npos) {
1290  return REGULAR_MOVE_POWER_MODE;
1291  }
1292  if(response_parts[1].find("LOW") != std::string::npos) {
1293  return LOW_MOVE_POWER_MODE;
1294  }
1295  else {
1296  return HIGH_MOVE_POWER_MODE;
1297  }
1298  }
1299  else {
1300  printf("Error while getting tilt in-motion power mode: %s\n", response_parts[1].c_str());
1301  return ERROR;
1302  }
1303  }
1304 
1305  std::string PTUFree::getErrorString(boost::system::error_code error) {
1306  switch (error.value()) {
1307  case boost::system::errc::success: {
1308  return "success";
1309  }
1310  break;
1311  case boost::system::errc::address_family_not_supported: {
1312  return "address_family_not_supported | EAFNOSUPPORT";
1313  }
1314  break;
1315  case boost::system::errc::address_in_use: {
1316  return "address_in_use | EADDRINUSE";
1317  }
1318  break;
1319  case boost::system::errc::address_not_available: {
1320  return "address_not_available | EADDRNOTAVAIL";
1321  }
1322  break;
1323  case boost::system::errc::already_connected: {
1324  return "already_connected | EISCONN";
1325  }
1326  break;
1327  case boost::system::errc::argument_list_too_long: {
1328  return "argument_list_too_long | E2BIG";
1329  }
1330  break;
1331  case boost::system::errc::argument_out_of_domain: {
1332  return "argument_out_of_domain | EDOM";
1333  }
1334  break;
1335  case boost::system::errc::bad_address: {
1336  return "bad_address | EFAULT";
1337  }
1338  break;
1339  case boost::system::errc::bad_file_descriptor: {
1340  return "bad_file_descriptor | EBADF";
1341  }
1342  break;
1343  case boost::system::errc::bad_message: {
1344  return "bad_message | EBADMSG";
1345  }
1346  break;
1347  case boost::system::errc::broken_pipe: {
1348  return "broken_pipe | EPIPE";
1349  }
1350  break;
1351  case boost::system::errc::connection_aborted: {
1352  return "connection_aborted | ECONNABORTED";
1353  }
1354  break;
1355  case boost::system::errc::connection_already_in_progress: {
1356  return "connection_already_in_progress | EALREADY";
1357  }
1358  break;
1359  case boost::system::errc::connection_refused: {
1360  return "connection_refused | ECONNREFUSED";
1361  }
1362  break;
1363  case boost::system::errc::connection_reset: {
1364  return "connection_reset | ECONNRESET";
1365  }
1366  break;
1367  case boost::system::errc::cross_device_link: {
1368  return "cross_device_link | EXDEV";
1369  }
1370  break;
1371  case boost::system::errc::destination_address_required: {
1372  return "destination_address_required | EDESTADDRREQ";
1373  }
1374  break;
1375  case boost::system::errc::device_or_resource_busy: {
1376  return "device_or_resource_busy | EBUSY";
1377  }
1378  break;
1379  case boost::system::errc::directory_not_empty: {
1380  return "directory_not_empty | ENOTEMPTY";
1381  }
1382  break;
1383  case boost::system::errc::executable_format_error: {
1384  return "executable_format_error | ENOEXEC";
1385  }
1386  break;
1387  case boost::system::errc::file_exists: {
1388  return "file_exists | EEXIST";
1389  }
1390  break;
1391  case boost::system::errc::file_too_large: {
1392  return "file_too_large | EFBIG";
1393  }
1394  break;
1395  case boost::system::errc::filename_too_long: {
1396  return "filename_too_long | ENAMETOOLONG";
1397  }
1398  break;
1399  case boost::system::errc::function_not_supported: {
1400  return "function_not_supported | ENOSYS";
1401  }
1402  break;
1403  case boost::system::errc::host_unreachable: {
1404  return "host_unreachable | EHOSTUNREACH";
1405  }
1406  break;
1407  case boost::system::errc::identifier_removed: {
1408  return "identifier_removed | EIDRM";
1409  }
1410  break;
1411  case boost::system::errc::illegal_byte_sequence: {
1412  return "illegal_byte_sequence | EILSEQ";
1413  }
1414  break;
1415  case boost::system::errc::inappropriate_io_control_operation: {
1416  return "inappropriate_io_control_operation | ENOTTY";
1417  }
1418  break;
1419  case boost::system::errc::interrupted: {
1420  return "interrupted | EINTR";
1421  }
1422  break;
1423  case boost::system::errc::invalid_argument: {
1424  return "invalid_argument | EINVAL";
1425  }
1426  break;
1427  case boost::system::errc::invalid_seek: {
1428  return "invalid_seek | ESPIPE";
1429  }
1430  break;
1431  case boost::system::errc::io_error: {
1432  return "io_error | EIO";
1433  }
1434  break;
1435  case boost::system::errc::is_a_directory: {
1436  return "is_a_directory | EISDIR";
1437  }
1438  break;
1439  case boost::system::errc::message_size: {
1440  return "message_size | EMSGSIZE";
1441  }
1442  break;
1443  case boost::system::errc::network_down: {
1444  return "network_down | ENETDOWN";
1445  }
1446  break;
1447  case boost::system::errc::network_reset: {
1448  return "network_reset | ENETRESET";
1449  }
1450  break;
1451  case boost::system::errc::network_unreachable: {
1452  return "network_unreachable | ENETUNREACH";
1453  }
1454  break;
1455  case boost::system::errc::no_buffer_space: {
1456  return "no_buffer_space | ENOBUFS";
1457  }
1458  break;
1459  case boost::system::errc::no_child_process: {
1460  return "no_child_process | ECHILD";
1461  }
1462  break;
1463  case boost::system::errc::no_link: {
1464  return "no_link | ENOLINK";
1465  }
1466  break;
1467  case boost::system::errc::no_lock_available: {
1468  return "no_lock_available | ENOLCK";
1469  }
1470  break;
1471  case boost::system::errc::no_message_available: {
1472  return "no_message_available | ENODATA";
1473  }
1474  break;
1475  case boost::system::errc::no_message: {
1476  return "no_message | ENOMSG";
1477  }
1478  break;
1479  case boost::system::errc::no_protocol_option: {
1480  return "no_protocol_option | ENOPROTOOPT";
1481  }
1482  break;
1483  case boost::system::errc::no_space_on_device: {
1484  return "no_space_on_device | ENOSPC";
1485  }
1486  break;
1487  case boost::system::errc::no_stream_resources: {
1488  return "no_stream_resources | ENOSR";
1489  }
1490  break;
1491  case boost::system::errc::no_such_device_or_address: {
1492  return "no_such_device_or_address | ENXIO";
1493  }
1494  break;
1495  case boost::system::errc::no_such_device: {
1496  return "no_such_device | ENODEV";
1497  }
1498  break;
1499  case boost::system::errc::no_such_file_or_directory: {
1500  return "no_such_file_or_directory | ENOENT";
1501  }
1502  break;
1503  case boost::system::errc::no_such_process: {
1504  return "no_such_process | ESRCH";
1505  }
1506  break;
1507  case boost::system::errc::not_a_directory: {
1508  return "not_a_directory | ENOTDIR";
1509  }
1510  break;
1511  case boost::system::errc::not_a_socket: {
1512  return "not_a_socket | ENOTSOCK";
1513  }
1514  break;
1515  case boost::system::errc::not_a_stream: {
1516  return "not_a_stream | ENOSTR";
1517  }
1518  break;
1519  case boost::system::errc::not_connected: {
1520  return "not_connected | ENOTCONN";
1521  }
1522  break;
1523  case boost::system::errc::not_enough_memory: {
1524  return "not_enough_memory | ENOMEM";
1525  }
1526  break;
1527  case boost::system::errc::not_supported: {
1528  return "not_supported | ENOTSUP";
1529  }
1530  break;
1531  case boost::system::errc::operation_canceled: {
1532  return "operation_canceled | ECANCELED";
1533  }
1534  break;
1535  case boost::system::errc::operation_in_progress: {
1536  return "operation_in_progress | EINPROGRESS";
1537  }
1538  break;
1539  case boost::system::errc::operation_not_permitted: {
1540  return "operation_not_permitted | EPERM";
1541  }
1542  break;
1543  //Uses internal same error code as operation_not_supported
1544  //case boost::system::errc::operation_not_supported: {
1545  // return "operation_not_supported | EOPNOTSUPP";
1546  //}
1547  //break;
1548  //Uses internal same error code as recources_unavailable_try_again
1549  //case boost::system::errc::operation_would_block: {
1550  // return "operation_would_block | EWOULDBLOCK";
1551  //}
1552  //break;
1553  case boost::system::errc::owner_dead: {
1554  return "owner_dead | EOWNERDEAD";
1555  }
1556  break;
1557  case boost::system::errc::permission_denied: {
1558  return "permission_denied | EACCES";
1559  }
1560  break;
1561  case boost::system::errc::protocol_error: {
1562  return "protocol_error | EPROTO";
1563  }
1564  break;
1565  case boost::system::errc::protocol_not_supported: {
1566  return "protocol_not_supported | EPROTONOSUPPORT";
1567  }
1568  break;
1569  case boost::system::errc::read_only_file_system: {
1570  return "read_only_file_system | EROFS";
1571  }
1572  break;
1573  case boost::system::errc::resource_deadlock_would_occur: {
1574  return "resource_deadlock_would_occur | EDEADLK";
1575  }
1576  break;
1577  case boost::system::errc::resource_unavailable_try_again: {
1578  return "resource_unavailable_try_again | EAGAIN";
1579  }
1580  break;
1581  case boost::system::errc::result_out_of_range: {
1582  return "result_out_of_range | ERANGE";
1583  }
1584  break;
1585  case boost::system::errc::state_not_recoverable: {
1586  return "state_not_recoverable | ENOTRECOVERABLE";
1587  }
1588  break;
1589  case boost::system::errc::stream_timeout: {
1590  return "stream_timeout | ETIME";
1591  }
1592  break;
1593  case boost::system::errc::text_file_busy: {
1594  return "text_file_busy | ETXTBSY";
1595  }
1596  break;
1597  case boost::system::errc::timed_out: {
1598  return "timed_out | ETIMEDOUT";
1599  }
1600  break;
1601  case boost::system::errc::too_many_files_open_in_system: {
1602  return "too_many_files_open_in_system | ENFILE";
1603  }
1604  break;
1605  case boost::system::errc::too_many_files_open: {
1606  return "too_many_files_open | EMFILE";
1607  }
1608  break;
1609  case boost::system::errc::too_many_links: {
1610  return "too_many_links | EMLINK";
1611  }
1612  break;
1613  //Most likely not available in current boost version (compiler error)
1614  //case boost::system::errc::too_many_synbolic_link_levels: {
1615  // return "too_many_synbolic_link_levels | ELOOP";
1616  //}
1617  //break;
1618  case boost::system::errc::value_too_large: {
1619  return "value_too_large | EOVERFLOW";
1620  }
1621  break;
1622  case boost::system::errc::wrong_protocol_type: {
1623  return "wrong_protocol_type | EPROTOTYPE";
1624  }
1625  break;
1626  default: {
1627  return "unknown error";
1628  }
1629  break;
1630  }
1631  }
1632 
1633  void PTUFree::test() {
1634 
1635  long pan_pos = getCurrentPanPosition();
1636  if(pan_pos != 0) {
1637  printf("Error getting initial pan position. Expected 0, got %ld\n", pan_pos);
1638  return;
1639  }
1640 
1641  if(!setDesiredPanPositionAbsolute(300)) {
1642  printf("Error while setting pan position to 300");
1643  return;
1644  }
1645 
1646  long desired_pan_position = getDesiredPanPosition();
1647  if(desired_pan_position != 300) {
1648  printf("Error while setting or getting (desired) pan position. Expected 300, desired %ld", desired_pan_position);
1649  return;
1650  }
1651 
1652  pan_pos = getCurrentPanPosition();
1653  if((pan_pos < 0) || (pan_pos >= 300)) {
1654  printf("Error getting pan position while ptu is moving position. Expected value between 0 and 300, got %ld\n", pan_pos);
1655  if(pan_pos == 300) {
1656  printf("Pan Position was 300 but it should not be at the moment. This can also happen due to to slow serial port or sceduling, testing will be continued therefore.");
1657  }
1658  else {
1659  return;
1660  }
1661  }
1662 
1663  pan_pos = getCurrentPanPosition();
1664  if((pan_pos < 0) || (pan_pos >= 300)) {
1665  printf("Error getting pan position while ptu is moving position. Expected value between 0 and 300, got %ld\n", pan_pos);
1666  if(pan_pos == 300) {
1667  printf("Pan Position was 300 but it should not be at the moment. This can also happen due to to slow serial port or sceduling, testing will be continued therefore.");
1668  }
1669  else {
1670  return;
1671  }
1672  }
1673 
1675  printf("Execution of await command failed");
1676  return;
1677  }
1678 
1679  pan_pos = getCurrentPanPosition();
1680  if((pan_pos != 300)) {
1681  printf("Setting pan position, getting pan position or await command failed. Expected pan position 300, but got %ld\n", pan_pos);
1682  return;
1683  }
1684 
1685  long tilt_pos = getCurrentTiltPosition();
1686  if(tilt_pos != 0) {
1687  printf("Error getting initial tilt position. Expected 0, got %ld\n", tilt_pos);
1688  return;
1689  }
1690 
1691  if(!setDesiredTiltPositionAbsolute(-350)) {
1692  printf("Error while setting tilt position to -350");
1693  return;
1694  }
1695 
1696  long desired_tilt_position = getDesiredTiltPosition();
1697  if(desired_tilt_position != -350) {
1698  printf("Error while setting or getting (desired) tilt position. Expected -350, desired %ld", desired_tilt_position);
1699  return;
1700  }
1701 
1702 
1703  tilt_pos = getCurrentTiltPosition();
1704  if((tilt_pos > 0) || (tilt_pos <= -350)) {
1705  printf("Error getting tilt position while ptu is moving position. Expected value between 0 and -350, got %ld\n", tilt_pos);
1706  if(pan_pos == -350) {
1707  printf("Tilt Position was -350 but it should not be at the moment. This can also happen due to to slow serial port or sceduling, testing will be continued therefore.");
1708  }
1709  else {
1710  return;
1711  }
1712  }
1713 
1714  tilt_pos = getCurrentTiltPosition();
1715  if((tilt_pos > 0) || (tilt_pos <= -350)) {
1716  printf("Error getting tilt position while ptu is moving position. Expected value between 0 and -350, got %ld\n", tilt_pos);
1717  if(tilt_pos == -350) {
1718  printf("Tilt Position was -350 but it should not be at the moment. This can also happen due to to slow serial port or sceduling, testing will be continued therefore.");
1719  }
1720  else {
1721  return;
1722  }
1723  }
1724 
1726  printf("Execution of await command failed");
1727  return;
1728  }
1729 
1730  tilt_pos = getCurrentTiltPosition();
1731  if((tilt_pos != -350)) {
1732  printf("Setting tilt position, getting tilt position or await command failed. Expected tilt position -350, but got %ld\n", tilt_pos);
1733  return;
1734  }
1735 
1736  if(!setDesiredPanPositionRelative(100)) {
1737  printf("Setting pan position realtiv failed.");
1738  return;
1739  }
1740 
1742  printf("Execution of await command failed");
1743  return;
1744  }
1745 
1746  pan_pos = getCurrentPanPosition();
1747  if(pan_pos != 400) {
1748  printf("After setting relative pan position, position == 400 was expected, but position was %ld\n", pan_pos);
1749  }
1750 
1751 
1752  if(!setDesiredTiltPositionRelative(100)) {
1753  printf("Setting pan position realtiv failed.");
1754  return;
1755  }
1756 
1758  printf("Execution of await command failed");
1759  return;
1760  }
1761 
1762  tilt_pos = getCurrentTiltPosition();
1763  if(tilt_pos != -250) {
1764  printf("After setting relative pan position, position == -250 was expected, but position was %ld\n", tilt_pos);
1765  }
1766 
1767 
1768 
1769  printf("SUCCESS: Setting pan and tilt testing successfull\n");
1770 
1771 
1772 
1774  printf("Setting position limit enforcement to factory limits enabled failed\n");
1775  return;
1776  }
1777  //some of those methods can take a while
1778  sleep(6);
1779  long limit_enforcement_mode = getPositionLimitEnforcementMode();
1780  if(limit_enforcement_mode != FACTORY_LIMITS_ENABLED) {
1781  if(limit_enforcement_mode == USER_DEFINED_LIMITS_ENABLED) {
1782  printf("setPositionLimitEnforcementMode or the corresponding get method failed. FACOTRY_LIMITS_ENABLED was expected, USER_DEFINED_LIMITS_ENABLE was retrieved\n");
1783  }
1784  else if (limit_enforcement_mode == LIMITS_DISABLED) {
1785  printf("setPositionLimitEnforcementMode or the corresponding get method failed. FACOTRY_LIMITS_ENABLED was expected, LIMITS_DISABLED was retrieved\n");
1786  }
1787  else if(limit_enforcement_mode == ERROR) {
1788  printf("getPositionLimitEnforcementMode failed with ERROR\n");
1789  }
1790  else {
1791  printf("get_posiion_limit_enforcement_mode returned unexpected value after setting FACTORY_LIMITS_ENABLED\n");
1792  }
1793  return;
1794  }
1795 
1796 
1797  long pan_upper_limit = getFactoryMaximumPanPositionLimit();
1798  long pan_lower_limit = getFactoryMinimumPanPositionLimit();
1799  long tilt_upper_limit = getFactoryMaximumTiltPositionLimit();
1800  long tilt_lower_limit = getFactoryMinimumTiltPositionLimit();
1801 
1802  //The following also tells if the get_current methods with Factory Limits work, because the values returned by get_factory... are recieved from that function at launch
1803  if(pan_upper_limit == ERROR) {
1804  printf("Function getCurrentUsedMaximumPanPositionLimit returned ERROR when used in FACTORY_LIMITS_ENABLES position enforcement mode\n");
1805  return;
1806  }
1807  if(pan_lower_limit == ERROR) {
1808  printf("Function getCurrentUsedMinimumPanPositionLimit returned ERROR when used in FACTORY_LIMITS_ENABLES position enforcement mode\n");
1809  return;
1810  }
1811  if(tilt_upper_limit == ERROR) {
1812  printf("Function getCurrentUsedMaximumTiltPositionLimit returned ERROR when used in FACTORY_LIMITS_ENABLES position enforcement mode\n");
1813  return;
1814  }
1815  if(tilt_lower_limit == ERROR) {
1816  printf("Function getCurrentUsedMinimumTiltPositionLimit returned ERROR when used in FACTORY_LIMITS_ENABLES position enforcement mode\n");
1817  return;
1818  }
1819 
1820  if(setDesiredPanPositionAbsolute(pan_upper_limit + 1)) {
1821  printf("FACTORY_LIMITS_ENABLED mode or any of the get functions did not work properly. Trying to move pan unit over the upper limit did not result in error\n");
1822  return;
1823  }
1824  if(setDesiredPanPositionAbsolute(pan_lower_limit - 1)) {
1825  printf("FACTORY_LIMITS_ENABLED mode or any of the get functions did not work properly. Trying to move pan unit over the lower limit did not result in error\n");
1826  return;
1827  }
1828  if(setDesiredTiltPositionAbsolute(tilt_upper_limit + 1)) {
1829  printf("FACTORY_LIMITS_ENABLED mode or any of the get functions did not work properly. Trying to move tilt unit over the upper limit did not result in error\n");
1830  return;
1831  }
1832  if(setDesiredTiltPositionAbsolute(tilt_lower_limit - 1)) {
1833  printf("FACTORY_LIMITS_ENABLED mode or any of the get functions did not work properly. Trying to move tilt unit over the lower limit did not result in error\n");
1834  return;
1835  }
1836 
1837  sleep(6);
1838  //Does not work on older ptus
1839  /*
1840  if(!setMaximumPanPositionLimit(1000)) {
1841  printf("Error while setting maximum_pan_position_limit to 1000\n");
1842  return;
1843  }
1844  if(!setMinimumPanPositionLimit(-1000)) {
1845  printf("Error while setting minimum_pan_position_limit to -1000\n");
1846  return;
1847  }
1848  if(!setMinimumTiltPositionLimit(-300)) {
1849  printf("Error while setting minimum_tilt_position_limit to -300\n");
1850  return;
1851  }
1852  if(!setMaximumTiltPositionLimit(300)) {
1853  printf("Error while setting maximum_tilt_position_limit to 300\n");
1854  return;
1855  }
1856 
1857  sleep(6);
1858 
1859  long min_user_pan_limit = getUserMinimumPanPositionLimit();
1860  long max_user_pan_limit = getUserMaximumPanPositionLimit();
1861  long min_user_tilt_limit = getUserMinimumTiltPositionLimit();
1862  long max_user_tilt_limit = getUserMaximumTiltPositionLimit();
1863  if(min_user_pan_limit != -1000) {
1864  printf("Error while getting minimum user pan position limit: -1000 expected, got %ld\n", min_user_pan_limit);
1865  return;
1866  }
1867  if(max_user_pan_limit != 1000) {
1868  printf("Error while getting maximum user pan position limit: 1000 expected, got %ld\n", max_user_pan_limit);
1869  return;
1870  }
1871  if(min_user_tilt_limit != -300) {
1872  printf("Error while getting minimum user tilt position limit: -300 expected, got %ld\n", min_user_tilt_limit);
1873  return;
1874  }
1875  if(max_user_tilt_limit != 300) {
1876  printf("Error while getting maximum user tilt position limit: 300 expected, got %ld\n", max_user_tilt_limit);
1877  return;
1878  }
1879 
1880  if(!setPositionLimitEnforcementMode(USER_DEFINED_LIMITS_ENABLED)) {
1881  printf("Setting position limit enforcement mode to USER_DEFINED_LIMITS_ENABLED failed");
1882  return;
1883  }
1884  limit_enforcement_mode = getPositionLimitEnforcementMode();
1885 
1886  if(limit_enforcement_mode != USER_DEFINED_LIMITS_ENABLED) {
1887  printf("Getting position limit enforcement mode failed. Expected: USER_DEFINED_LIMITS_ENABLED, Got: %ld\n", limit_enforcement_mode);
1888  return;
1889  }
1890 
1891  long min_current_pan_limit = getCurrentUsedMinimumPanPositionLimit();
1892  long max_current_pan_limit = getCurrentUsedMaximumPanPositionLimit();
1893  long min_current_tilt_limit = getCurrentUsedMinimumTiltPositionLimit();
1894  long max_current_tilt_limit = getCurrentUsedMaximumTiltPositionLimit();
1895  if(min_current_pan_limit != -1000) {
1896  printf("Error while getting minimum current used pan position limit: -1000 expected, got %ld\n", min_current_pan_limit);
1897  return;
1898  }
1899  if(max_current_pan_limit != 1000) {
1900  printf("Error while getting maximum current used pan position limit: 1000 expected, got %ld\n", max_current_pan_limit);
1901  return;
1902  }
1903  if(min_current_tilt_limit != -300) {
1904  printf("Error while getting minimum current used tilt position limit: -300 expected, got %ld\n", min_current_tilt_limit);
1905  return;
1906  }
1907  if(max_current_tilt_limit != 300) {
1908  printf("Error while getting maximum current used tilt position limit: 300 expected, got %ld\n", max_current_tilt_limit);
1909  return;
1910  }
1911 
1912 
1913  */
1915  printf("Setting position limit enforcement mode to LIMITS_DISABLED failed");
1916  return;
1917  }
1918 
1919  limit_enforcement_mode = getPositionLimitEnforcementMode();
1920 
1921  if(limit_enforcement_mode != LIMITS_DISABLED) {
1922  printf("Getting position limit enforcement mode failed. Expected: LIMITS_DISABLED, Got: %ld\n", limit_enforcement_mode);
1923  return;
1924  }
1925 
1926  if(!setDesiredPanPositionAbsolute(4000)) {
1927  printf("Setting position out of limits with LIMITS_DISABLED failed\n");
1928  return;
1929  }
1930 
1931  sleep(6);
1932 
1934 
1935  sleep(6);
1936 
1937  printf("Testing Limit Enforcement succeeded\n");
1938 
1939 
1942 
1943 
1944  long cur_pan_speed = getCurrentPanSpeed();
1945  long cur_tilt_speed = getCurrentTiltSpeed();
1946  if(cur_pan_speed != 0) {
1947  printf("Error while getting current pan speed. 0 expected but got %ld\n", cur_pan_speed);
1948  return;
1949  }
1950  if(cur_tilt_speed != 0) {
1951  printf("Error while getting current tilt speed. 0 expected but got %ld\n", cur_tilt_speed);
1952  return;
1953  }
1954 
1955  long des_pan_speed = getDesiredPanSpeed();
1956  long des_tilt_speed = getDesiredTiltSpeed();
1957  if(des_pan_speed <= 0) {
1958  printf("Error while getting desired pan speed. Value >= 0 expected but got %ld\n", des_pan_speed);
1959  return;
1960  }
1961  if(des_tilt_speed <= 0) {
1962  printf("Error while getting desired tilt speed. Value >= 0 expected but got %ld\n", des_tilt_speed);
1963  return;
1964  }
1965 
1966  if(!setDesiredPanSpeedAbsolute((des_pan_speed - 1))) {
1967  printf("Error while setting desired pan speed absolute\n");
1968  return;
1969  }
1970 
1971  long mod_desired_pan_speed = getDesiredPanSpeed();
1972  if(mod_desired_pan_speed != (des_pan_speed - 1)) {
1973  printf("Error while getting or setting desired pan speed (absolute set). Expected %ld - 1, but got %ld\n", des_pan_speed, mod_desired_pan_speed);
1974  return;
1975  }
1976 
1977  if(!setDesiredTiltSpeedAbsolute((des_tilt_speed - 2))) {
1978  printf("Error while setting desired tilt speed absolute\n");
1979  return;
1980  }
1981 
1982  long mod_desired_tilt_speed = getDesiredTiltSpeed();
1983  if(mod_desired_tilt_speed != (des_tilt_speed - 2)) {
1984  printf("Error while getting or setting desired tilt speed (absolute set). Expected %ld - 2, but got %ld\n", des_tilt_speed, mod_desired_tilt_speed);
1985  return;
1986  }
1987 
1988  //WARNING: OFFSET FROM CURRENT (NOT DESIRED) SPEED IS SET TO DESIRED SPEED (Example: Current speed = 0, Desired Speed = 500. setDesiredPanSpeedRelative will result in
1989  //current speed being 0 and desired speed being 0 + 100 = 100
1990  if(!setDesiredPanSpeedRelative(des_pan_speed - 2)) {
1991  printf("Error while setting desired pan speed realtive\n");
1992  return;
1993  }
1994 
1995  mod_desired_pan_speed = getDesiredPanSpeed();
1996  if(mod_desired_pan_speed != (des_pan_speed - 2)) {
1997  printf("Error while getting or setting desired pan speed (realtive set). Expected %ld - 2, but got %ld\n", des_pan_speed, mod_desired_pan_speed);
1998  return;
1999  }
2000 
2001  if(!setDesiredTiltSpeedRelative(des_tilt_speed - 4)) {
2002  printf("Error while setting desired tilt speed relative\n");
2003  return;
2004  }
2005 
2006  mod_desired_tilt_speed = getDesiredTiltSpeed();
2007  if(mod_desired_tilt_speed != (des_tilt_speed - 4)) {
2008  printf("Error while getting or setting desired tilt speed (relative set). Expected %ld - 4, but got %ld\n", des_tilt_speed, mod_desired_tilt_speed);
2009  return;
2010  }
2011 
2012  long upper_limit_pan = getPanUpperSpeedLimit();
2013  long lower_limit_pan = getPanLowerSpeedLimit();
2014  long upper_limit_tilt = getTiltUpperSpeedLimit();
2015  long lower_limit_tilt = getTiltLowerSpeedLimit();
2016 
2017  if(upper_limit_pan == ERROR) {
2018  printf("Error while getting upper speed limit pan.\n");
2019  return;
2020  }
2021  if(lower_limit_pan == ERROR) {
2022  printf("Error while getting lower speed limit pan.\n");
2023  return;
2024  }
2025  if(upper_limit_tilt == ERROR) {
2026  printf("Error while getting upper speed limit tilt.\n");
2027  return;
2028  }
2029  if(lower_limit_tilt == ERROR) {
2030  printf("Error while getting lower speed limit tilt.\n");
2031  return;
2032  }
2033 
2034  if(!setDesiredPanUpperSpeedLimit(upper_limit_pan - 1)) {
2035  printf("Error while setting upper speed limit pan\n");
2036  return;
2037  }
2038  if(!setDesiredPanLowerSpeedLimit(57)) {
2039  printf("Error while setting lower speed limit pan\n");
2040  return;
2041  }
2042  if(!setDesiredTiltUpperSpeedLimit(upper_limit_tilt - 2)) {
2043  printf("Error while setting upper speed limit tilt\n");
2044  return;
2045  }
2047  printf("Error while setting lower speed limit tilt\n");
2048  return;
2049  }
2050 
2051  //Changing speed bounds is not possible on the fly, needs long break
2052  sleep(6);
2053 
2054  //long mod_upper_limit_pan = getPanUpperSpeedLimit();
2055  long mod_lower_limit_pan = getPanLowerSpeedLimit();
2056  //long mod_upper_limit_tilt = getTiltUpperSpeedLimit();
2057  long mod_lower_limit_tilt = getTiltLowerSpeedLimit();
2058  /*
2059  if(mod_upper_limit_pan != (upper_limit_pan - 1)) {
2060  printf("Error while getting or setting upper speed limit pan. Expected %ld - 1, but got %ld\n", upper_limit_pan, mod_upper_limit_pan);
2061  return;
2062  }
2063  */
2064  if(mod_lower_limit_pan != (57)) {
2065  printf("Error while getting or setting lower speed limit pan. Expected 57, but got %ld\n", mod_lower_limit_pan);
2066  return;
2067  }
2068  /*
2069  if(mod_upper_limit_tilt != (upper_limit_tilt - 2)) {
2070  printf("Error while getting or setting upper speed limit tilt. Expected %ld - 2, but got %ld\n", upper_limit_tilt, mod_upper_limit_tilt);
2071  return;
2072  }
2073  */
2074  if(mod_lower_limit_tilt != (58)) {
2075  printf("Error while getting or setting lower speed limit tilt. Expected 58, but got %ld\n", mod_lower_limit_tilt);
2076  return;
2077  }
2078 
2079  long pan_base_speed = getPanBaseSpeed();
2080  long tilt_base_speed = getTiltBaseSpeed();
2081  if(pan_base_speed <= 0) {
2082  printf("Error while getting pan_base_speed\n");
2083  return;
2084  }
2085  if(tilt_base_speed <= 0) {
2086  printf("Error while getting tilt_base_speed\n");
2087  return;
2088  }
2089  if(!setPanBaseSpeed((pan_base_speed - 1))) {
2090  printf("Error while setting pan_base_speed\n");
2091  return;
2092  }
2093  if(!setTiltBaseSpeed((tilt_base_speed - 1))) {
2094  printf("Error while setting tilt_base_speed\n");
2095  return;
2096  }
2097  long mod_pan_base_speed = getPanBaseSpeed();
2098  long mod_tilt_base_speed = getTiltBaseSpeed();
2099  if((pan_base_speed - 1) != mod_pan_base_speed) {
2100  printf("Error while getting pan_base_speed. Expected %ld - 1, got %ld\n", pan_base_speed, mod_pan_base_speed);
2101  return;
2102  }
2103  if((tilt_base_speed - 1) != mod_tilt_base_speed) {
2104  printf("Error while getting tilt_base_speed. Expected %ld - 1, got %ld\n", tilt_base_speed, mod_tilt_base_speed);
2105  return;
2106  }
2107 
2108  long pan_accel = getPanAcceleartion();
2109  long tilt_accel = getTiltAcceleartion();
2110  if(pan_accel <= 0) {
2111  printf("Error while getting pan acceleration\n");
2112  return;
2113  }
2114  if(tilt_accel <= 0) {
2115  printf("Error while getting tilt acceleration\n");
2116  return;
2117  }
2118  if(!setDesiredPanAccelerationAbsolute((pan_accel - 1))) {
2119  printf("Setting desired pan acceleration absolute failed\n");
2120  return;
2121  }
2122  if(!setDesiredTiltAccelerationAbsolute((tilt_accel - 1))) {
2123  printf("Setting desired pan acceleration absolute failed\n");
2124  return;
2125  }
2126  long mod_pan_accel = getPanAcceleartion();
2127  long mod_tilt_accel = getTiltAcceleartion();
2128  if((pan_accel - 1) != mod_pan_accel) {
2129  printf("Error while getting pan acceleration. Expected %ld - 1, got %ld\n", pan_accel, mod_pan_accel);
2130  return;
2131  }
2132  if((tilt_accel - 1) != mod_tilt_accel) {
2133  printf("Error while getting tilt acceleration. Expected %ld - 1, got %ld\n", tilt_accel, mod_tilt_accel);
2134  return;
2135  }
2136 
2137  printf("Speed testing successfull\n");
2138 
2139  double pan_res = getPanResolution();
2140  double tilt_res = getTiltResolution();
2141 
2142  if(pan_res <= 0.0) {
2143  printf("Error while getting pan resolution");
2144  return;
2145  }
2146  if(tilt_res <= 0.0) {
2147  printf("Error while getting tilt resolution");
2148  return;
2149  }
2150 
2151  printf("Resolution testing successfull with Pan Resolution %f und Tilt Resolution %f\n", pan_res, tilt_res);
2152 
2153 
2155  printf("Error while setting position execution mode to SLAVED_POSITION_EXECUTION_MODE\n");
2156  return;
2157  }
2158  long pos_ex_mode = getPositionExecutionMode();
2159  if(pos_ex_mode != SLAVED_POSITION_EXECUTION_MODE) {
2160  printf("Error while getting or setting position execution mode. SLAVED_POSITION_EXECUTION_MODE expected, got %ld\n", pos_ex_mode);
2161  return;
2162  }
2164  printf("Error while setting position execution mode to IMMEDIATE_POSITION_EXECUTION_MODE\n");
2165  return;
2166  }
2167  pos_ex_mode = getPositionExecutionMode();
2168  if(pos_ex_mode != IMMEDIATE_POSITION_EXECUTION_MODE) {
2169  printf("Error while getting or setting position execution mode. IMMEDIATE_POSITION_EXECUTION_MODE expected, got %ld\n", pos_ex_mode);
2170  return;
2171  }
2172 
2173 
2174 
2175  if(!halt(HALT_BOTH)) {
2176  printf("Error while executing halt command with HALT_BOTH\n");
2177  return;
2178  }
2179  if(!halt(HALT_PAN_ONLY)) {
2180  printf("Error while executing halt command with HALT_PAN_ONLY\n");
2181  return;
2182  }
2183  if(!halt(HALT_TILT_ONLY)) {
2184  printf("Error while executing halt command with HALT_TILT_ONLY\n");
2185  return;
2186  }
2187 
2189  printf("Problem while setting preset with current location\n");
2190  return;
2191  }
2193  long cur_pan_pos = getCurrentPanPosition();
2194  long cur_tilt_pos = getCurrentTiltPosition();
2195  if(cur_pan_pos != 300 || cur_tilt_pos != 300) {
2196  printf("Synchronous setting of pan and tilt axis in setDesiredPanTiltPositionAbsoluteSlaved did not work properly, false position was set\n");
2197  return;
2198  }
2199  /*
2200  if(!setPreset(1)) {
2201  printf("Problem with setting implicit preset\n");
2202  return;
2203  }
2204  setDesiredTiltPositionAbsolute(0);
2205  sleep(6);
2206  if(getCurrentTiltPosition()!= 0) {
2207  printf("Probably problem after setting pan_tilt synchronous with setDesiredPanTiltPositionAbsoluteSlaved. Next regular pan only setting command returned wrong result or was not executed\n");
2208  return;
2209  }
2210  if(!setPreset(2, -300, -300)) {
2211  printf("Problem while setting preset with explizit pan and tilt pasing\n");
2212  return;
2213  }
2214  if(!gotoPreset(1)) {
2215  printf("Error while going to preset with Number 1\n");
2216  return;
2217  }
2218  awaitPositionCommandCompletion();
2219  cur_pan_pos = getCurrentPanPosition();
2220  cur_tilt_pos = getCurrentTiltPosition();
2221  if(cur_pan_pos != 300 || cur_tilt_pos != 300) {
2222  printf("setPreset did not work properly. When going to preset 1 wrong position is loaded\n");
2223  return;
2224  }
2225  if(!gotoPreset(2)) {
2226  printf("Error while going to preset with Number 1\n");
2227  return;
2228  }
2229  awaitPositionCommandCompletion();
2230  cur_pan_pos = getCurrentPanPosition();
2231  cur_tilt_pos = getCurrentTiltPosition();
2232  if(cur_pan_pos != -300 || cur_tilt_pos != -300) {
2233  printf("setPreset did not work properly. When going to preset 2 wrong position is loaded\n");
2234  return;
2235  }
2236 
2237  clearPreset();
2238 
2239  if(gotoPreset(1)) {
2240  printf("Goto preset 1 after clearing preset worked but it should not have worked\n");
2241  return;
2242  }
2243  */
2244 
2246  printf("Error while setting speed control mode to PURE_VELOCITY_CONTROL_MODE\n");
2247  return;
2248  }
2249  long cur_speed_control_mode = getSpeedControlMode();
2250  if(cur_speed_control_mode != PURE_VELOCITY_CONTROL_MODE) {
2251  printf("Error while getting or setting speed controle mode. Expected PURE_VELOCITY_CONTROL_MODE, got %ld\n", cur_speed_control_mode);
2252  return;
2253  }
2254 
2256  printf("Error while setting speed control mode to INDEPENDENT_SPEED_MODE\n");
2257  return;
2258  }
2259  cur_speed_control_mode = getSpeedControlMode();
2260  if(cur_speed_control_mode != INDEPENDENT_SPEED_MODE) {
2261  printf("Error while getting or setting speed controle mode. Expected INDEPENDENT_SPEED_MODE, got %ld\n", cur_speed_control_mode);
2262  return;
2263  }
2264 
2265 
2266  //NOTE: Only visual check on reset modes they are written to eeprom and there is no way to query the current mode.
2267  //Folowing commented out functions where also only visually checked (code review)
2268  //bool setResetMode(long mode);
2269  //bool saveDefault();
2270  //bool restoreDefault();
2271  //bool restoreFactoryDefault();
2272 
2273  long prev_pan_stat_power_mode = getPanStationaryPowerMode();
2274  long prev_tilt_stat_power_mode = getTiltStationaryPowerMode();
2276  printf("Error while setting pan stationary power mode to REGULAR_HOLD_POWER_MODE\n");
2277  return;
2278  }
2280  printf("Error while setting tilt stationary power mode to REGULAR_HOLD_POWER_MODE\n");
2281  return;
2282  }
2283  long cur_pan_stat_power_mode = getPanStationaryPowerMode();
2284  long cur_tilt_stat_power_mode = getTiltStationaryPowerMode();
2285  if(cur_pan_stat_power_mode != REGULAR_HOLD_POWER_MODE) {
2286  printf("Error while getting or setting pan stationary power mode. Expected: REGULAR_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2287  return;
2288  }
2289  if(cur_tilt_stat_power_mode != REGULAR_HOLD_POWER_MODE) {
2290  printf("Error while getting or setting tilt stationary power mode. Expected: REGULAR_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2291  return;
2292  }
2293 
2295  printf("Error while setting pan stationary power mode to LOW_HOLD_POWER_MODE\n");
2296  return;
2297  }
2299  printf("Error while setting tilt stationary power mode to LOW_HOLD_POWER_MODE\n");
2300  return;
2301  }
2302  cur_pan_stat_power_mode = getPanStationaryPowerMode();
2303  cur_tilt_stat_power_mode = getTiltStationaryPowerMode();
2304  if(cur_pan_stat_power_mode != LOW_HOLD_POWER_MODE) {
2305  printf("Error while getting or setting pan stationary power mode. Expected: LOW_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2306  return;
2307  }
2308  if(cur_tilt_stat_power_mode != LOW_HOLD_POWER_MODE) {
2309  printf("Error while getting or setting tilt stationary power mode. Expected: LOW_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2310  return;
2311  }
2312 
2314  printf("Error while setting pan stationary power mode to OFF_HOLD_POWER_MODE\n");
2315  return;
2316  }
2318  printf("Error while setting tilt stationary power mode to OFF_HOLD_POWER_MODE\n");
2319  return;
2320  }
2321  cur_pan_stat_power_mode = getPanStationaryPowerMode();
2322  cur_tilt_stat_power_mode = getTiltStationaryPowerMode();
2323  if(cur_pan_stat_power_mode != OFF_HOLD_POWER_MODE) {
2324  printf("Error while getting or setting pan stationary power mode. Expected: OFF_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2325  return;
2326  }
2327  if(cur_tilt_stat_power_mode != OFF_HOLD_POWER_MODE) {
2328  printf("Error while getting or setting tilt stationary power mode. Expected: OFF_HOLD_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2329  return;
2330  }
2331 
2332  setPanStationaryPowerMode(prev_pan_stat_power_mode);
2333  setTiltStationaryPowerMode(prev_tilt_stat_power_mode);
2334 
2335  long prev_pan_move_power_mode = getPanInMotionPowerMode();
2336  long prev_tilt_move_power_mode = getTiltInMotionPowerMode();
2338  printf("Error while setting pan in_motion power mode to REGULAR_MOVE_POWER_MODE\n");
2339  return;
2340  }
2342  printf("Error while setting tilt in_motion power mode to REGULAR_MOVE_POWER_MODE\n");
2343  return;
2344  }
2345  long cur_pan_move_power_mode = getPanInMotionPowerMode();
2346  long cur_tilt_move_power_mode = getTiltInMotionPowerMode();
2347  if(cur_pan_move_power_mode != REGULAR_MOVE_POWER_MODE) {
2348  printf("Error while getting or setting pan in_motion power mode. Expected: REGULAR_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2349  return;
2350  }
2351  if(cur_tilt_move_power_mode != REGULAR_MOVE_POWER_MODE) {
2352  printf("Error while getting or setting tilt in_motion power mode. Expected: REGULAR_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2353  return;
2354  }
2355 
2357  printf("Error while setting pan in_motion power mode to LOW_MOVE_POWER_MODE\n");
2358  return;
2359  }
2361  printf("Error while setting tilt in_motion power mode to LOW_MOVE_POWER_MODE\n");
2362  return;
2363  }
2364  cur_pan_move_power_mode = getPanInMotionPowerMode();
2365  cur_tilt_move_power_mode = getTiltInMotionPowerMode();
2366  if(cur_pan_move_power_mode != LOW_MOVE_POWER_MODE) {
2367  printf("Error while getting or setting pan in_motion power mode. Expected: LOW_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2368  return;
2369  }
2370  if(cur_tilt_move_power_mode != LOW_MOVE_POWER_MODE) {
2371  printf("Error while getting or setting tilt in_motion power mode. Expected: LOW_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2372  return;
2373  }
2374 
2376  printf("Error while setting pan in_motion power mode to HIGH_MOVE_POWER_MODE\n");
2377  return;
2378  }
2380  printf("Error while setting tilt in_motion power mode to HIGH_MOVE_POWER_MODE\n");
2381  return;
2382  }
2383  cur_pan_move_power_mode = getPanInMotionPowerMode();
2384  cur_tilt_move_power_mode = getTiltInMotionPowerMode();
2385  if(cur_pan_move_power_mode != HIGH_MOVE_POWER_MODE) {
2386  printf("Error while getting or setting pan in_motion power mode. Expected: HIGH_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2387  return;
2388  }
2389  if(cur_tilt_move_power_mode != HIGH_MOVE_POWER_MODE) {
2390  printf("Error while getting or setting tilt in_motion power mode. Expected: HIGH_MOVE_POWER_MODE, got %ld\n", cur_pan_stat_power_mode);
2391  return;
2392  }
2393 
2394  setPanInMotionPowerMode(prev_pan_move_power_mode);
2395  setTiltInMotionPowerMode(prev_tilt_move_power_mode);
2396 
2397 
2398  printf("Testing successfull\n");
2399  }
2400 
2402  return ptu_port.is_open();
2403  }
2404 }
long getFactoryMaximumPanPositionLimit()
getFactoryMaximumPanPositionLimit Method to get the factory defined maximum pan position.
Definition: PTUFree.cpp:744
void test()
test Method to test the methods of this program, for DEBUG/DEVELOPMENT purpose, changes PTU settings ...
Definition: PTUFree.cpp:1633
long getCurrentPanSpeed()
getCurrentPanSpeed Method that queries the current pan speed
Definition: PTUFree.cpp:265
bool setDesiredTiltUpperSpeedLimit(short int upper_speed_limit)
setDesiredTiltUpperSpeedLimit Method that sets the upper speed limit for tilt (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:444
bool setDesiredPanSpeedAbsolute(short int speed)
setDesiredPanSpeedAbsolute Method that sets absolute pan speed (position/second)
Definition: PTUFree.cpp:165
bool setDesiredTiltPositionRelative(short int position_offset)
setDesiredTiltPositionRelative Method that sets current tilt position by offset (current pos + offset...
Definition: PTUFree.cpp:388
#define BOTH_RESET_MODE
Definition: PTUFree.h:29
long getUserMinimumTiltPositionLimit()
getUserMinimumTiltPositionLimit Method to get the user defined minimum tilt position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:714
#define IMMEDIATE_POSITION_EXECUTION_MODE
Definition: PTUFree.h:19
long getCurrentUsedMaximumTiltPositionLimit()
getCurrentUsedMaximumTiltPositionLimit Method to get the currently used maximum tilt position...
Definition: PTUFree.cpp:789
long getSpeedControlMode()
getSpeedControlMode Method to get the currently used sped control mode of the ptu.
Definition: PTUFree.cpp:1020
long getDesiredTiltSpeed()
getDesiredTiltSpeed Method that queries the desired tilt speed
Definition: PTUFree.cpp:569
bool setResetMode(long mode)
setResetMode Method to set the reset mode of the ptu. Saved to EEPROM, do not use too often...
Definition: PTUFree.cpp:1052
double getTiltResolution()
getTiltResolution Method that queries the tilt resolution (seconds/arc per position). Divide by 3600 to get Degree.
Definition: PTUFree.cpp:543
bool setDesiredTiltPositionAbsolute(short int position)
setDesiredTiltPositionAbsolute Method that sets absolute tilt position
Definition: PTUFree.cpp:375
#define OFF_HOLD_POWER_MODE
Definition: PTUFree.h:32
bool setDesiredPanLowerSpeedLimit(short int lower_speed_limit)
setDesiredPanLowerSpeedLimit Method that sets the lower speed limit for pan (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:224
long getCurrentUsedMinimumPanPositionLimit()
getCurrentUsedMinimumPanPositionLimit Method to get the currently used minimum pan position...
Definition: PTUFree.cpp:753
#define LIMITS_DISABLED
Definition: PTUFree.h:17
std::string readPTUResponse()
readPTUResponse Method that reads from the PTU until delimitor (&#39; &#39;) appears. Then the read data is r...
Definition: PTUFree.cpp:79
long getFactoryMaximumTiltPositionLimit()
getFactoryMaximumTiltPositionLimit Method to get the factory defined maximum tilt position...
Definition: PTUFree.cpp:750
long getTiltAcceleartion()
getTiltAcceleartion Method that queries the tilt acceleration (no current or desired here) ...
Definition: PTUFree.cpp:582
long getPanInMotionPowerMode()
getPanInMotionPowerMode Method to get the move power mode for pan axis.
Definition: PTUFree.cpp:1264
void closeSerialConnection()
closeSerialConnection Closes currently used serial port
Definition: PTUFree.cpp:67
#define SLAVED_POSITION_EXECUTION_MODE
Definition: PTUFree.h:20
#define HIGH_MOVE_POWER_MODE
Definition: PTUFree.h:33
bool isOpen()
isOpen Method to determine if used port is open or closed.
Definition: PTUFree.cpp:2401
#define USER_DEFINED_LIMITS_ENABLED
Definition: PTUFree.h:16
long factory_pan_max
Definition: PTUFree.h:585
long factory_tilt_max
Definition: PTUFree.h:587
long getCurrentTiltSpeed()
getCurrentTiltSpeed Method that queries the current tilt speed
Definition: PTUFree.cpp:501
bool setTiltBaseSpeed(short int base_speed)
setTiltBaseSpeed Method that sets the base speed for tilt (position/second)
Definition: PTUFree.cpp:473
#define HALT_BOTH
Definition: PTUFree.h:23
long getTiltUpperSpeedLimit()
getTiltUpperSpeedLimit Method that queries the tilt upper speed limit WARNING: This Method consumes e...
Definition: PTUFree.cpp:517
long getUserMaximumTiltPositionLimit()
getUserMaximumTiltPositionLimit Method to get the user defined maximum tilt position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:728
#define INDEPENDENT_SPEED_MODE
Definition: PTUFree.h:24
std::string getErrorString(boost::system::error_code error)
Definition: PTUFree.cpp:1305
long getCurrentUsedMinimumTiltPositionLimit()
getCurrentUsedMinimumTiltPositionLimit Method to get the currently used minimum tilt position...
Definition: PTUFree.cpp:777
long getDesiredPanSpeed()
getDesiredPanSpeed Method that queries the desired pan speed
Definition: PTUFree.cpp:333
long getUserMaximumPanPositionLimit()
getUserMaximumPanPositionLimit Method to get the user defined maximum pan position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:700
bool setDesiredPanUpperSpeedLimit(short int upper_speed_limit)
setDesiredPanUpperSpeedLimit Method that sets the upper speed limit for pan (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:208
#define HALT_TILT_ONLY
Definition: PTUFree.h:22
#define FACTORY_LIMITS_ENABLED
Definition: PTUFree.h:15
bool setNewSerialConnection(std::string port, int baud)
setNewSerialConnection Establishes a new connection via serial port specified by &#39;port&#39; to a target d...
Definition: PTUFree.cpp:27
bool setPanStationaryPowerMode(long mode)
setPanStationaryPowerMode Method to set the stationary power mode for pan axis.
Definition: PTUFree.cpp:1120
PTUFree()
PTUFree Constructor for PTUFree object. Not connected to any port.
Definition: PTUFree.cpp:5
long getTiltStationaryPowerMode()
getTiltStationaryPowerMode Method to get the stationary power mode for tilt axis. ...
Definition: PTUFree.cpp:1192
bool setDesiredPanAccelerationAbsolute(short int acceleration)
setDesiredPanAccelerationAbsolute Method that sets the absolute pan acceleration (position/second^2) ...
Definition: PTUFree.cpp:193
long getFactoryMinimumTiltPositionLimit()
getFactoryMinimumTiltPositionLimit Method to get the factory defined minimum tilt position...
Definition: PTUFree.cpp:747
long getPositionLimitEnforcementMode()
getPositionLimitEnforcementMode Method to get the currently used position limit enforcement mode...
Definition: PTUFree.cpp:804
bool setMaximumPanPositionLimit(short int position)
setMaximumPanPositionLimit Method that is used to set a user defined maximum pan position limit...
Definition: PTUFree.cpp:648
std::vector< std::string > evaluateResponse(std::string response)
evaluateResponse Method that preprocesses the answer of the PTU. Splits the PTU to a maximum of 3 par...
Definition: PTUFree.cpp:99
std::string communicate(std::string request)
communicate Method to send a command &#39;request&#39; to the serial port (and the device) and recieve the an...
Definition: PTUFree.cpp:71
long factory_pan_min
Definition: PTUFree.h:584
bool clearPreset()
clearPreset Method to delete all existing presets. WARNING: Does not work on older PTUs and is not te...
Definition: PTUFree.cpp:983
bool setDesiredTiltSpeedRelative(short int speed_offset)
setDesiredTiltSpeedRelative Method that sets the desired tilt speed relative to the CURRENT (not the ...
Definition: PTUFree.cpp:416
bool setDesiredTiltAccelerationAbsolute(short int acceleration)
setDesiredTiltAccelerationAbsolute Method that sets the absolute tilt acceleration (position/second^2...
Definition: PTUFree.cpp:429
bool setPreset(int preset_index, short int pan, short int tilt)
setPreset Method that allows to associate a pan and tilt position with a preset index. Moves to the pan and tilt position and saves the position as a preset. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:936
bool setDesiredPanPositionRelative(short int position_offset)
setDesiredPanPositionRelative Method that sets current pan position by offset (current pos + offset =...
Definition: PTUFree.cpp:152
bool setPanBaseSpeed(short int base_speed)
setPanBaseSpeed Method that sets the base speed for pan (position/second)
Definition: PTUFree.cpp:237
bool setPositionExecutionMode(long mode)
setPositionExecutionMode Method to set the position execution mode.
Definition: PTUFree.cpp:825
long getTiltInMotionPowerMode()
getTiltInMotionPowerMode Method to get the move power mode for tilt axis.
Definition: PTUFree.cpp:1284
ROSLIB_DECL std::string command(const std::string &cmd)
long getPanLowerSpeedLimit()
getPanLowerSpeedLimit Method that queries the pan lower speed limit. WARNING: This Method consumes ei...
Definition: PTUFree.cpp:294
#define HALT_PAN_ONLY
Definition: PTUFree.h:21
bool setSpeedControlMode(long mode)
setSpeedControlMode Method to set the sped control mode of the ptu.
Definition: PTUFree.cpp:996
long getPanAcceleartion()
getPanAcceleartion Method that queries the pan acceleration (no current or desired here) ...
Definition: PTUFree.cpp:346
bool setMinimumPanPositionLimit(short int position)
setMinimumPanPositionLimit Method that is used to set a user defined minimum pan position limit...
Definition: PTUFree.cpp:636
bool gotoPreset(int preset_index)
gotoPreset Method that moves the ptu to a existing preset of pan and tilt corrdiantes. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:969
long getPanUpperSpeedLimit()
getPanUpperSpeedLimit Method that queries the pan upper speed limit WARNING: This Method consumes eit...
Definition: PTUFree.cpp:281
long position_execution_mode
Definition: PTUFree.h:588
long getTiltBaseSpeed()
getTiltBaseSpeed Returns the current tilt base speed
Definition: PTUFree.cpp:595
long getDesiredPanPosition()
getDesiredPanPosition Method that queries the desired pan position
Definition: PTUFree.cpp:320
boost::asio::io_service timer_io_service
Definition: PTUFree.h:581
long getCurrentPanPosition()
getCurrentPanPosition Method that queries the current pan position
Definition: PTUFree.cpp:252
#define NO_RESET_MODE
Definition: PTUFree.h:26
#define ERROR
Definition: PTUFree.h:12
bool setDesiredPanSpeedRelative(short int speed_offset)
setDesiredPanSpeedRelative Method that sets the desired pan speed relative to the CURRENT (not the de...
Definition: PTUFree.cpp:180
bool halt(long axis)
halt Method that halts movement on specified axis.
Definition: PTUFree.cpp:872
bool restoreFactoryDefault()
restoreFactoryDefault Method to set default settings to factory defaults. Saved to EEPROM...
Definition: PTUFree.cpp:1107
double getPanResolution()
getPanResolution Method that queries the pan resolution (seconds/arc per position). Divide by 3600 to get Degree.
Definition: PTUFree.cpp:307
long getPanBaseSpeed()
getPanBaseSpeed Returns the current pan base speed
Definition: PTUFree.cpp:359
bool awaitPositionCommandCompletion()
awaitPositionCommandCompletion Method to wait for the completion of the last issued pan and tilt posi...
Definition: PTUFree.cpp:859
#define PAN_ONLY_RESET_MODE
Definition: PTUFree.h:27
#define LOW_HOLD_POWER_MODE
Definition: PTUFree.h:31
bool restoreDefault()
restoreDefault Method to restore default settings. WARNING: Not tested.
Definition: PTUFree.cpp:1094
long getPanStationaryPowerMode()
getPanStationaryPowerMode Method to get the stationary power mode for pan axis.
Definition: PTUFree.cpp:1172
long getTiltLowerSpeedLimit()
getTiltLowerSpeedLimit Method that queries the tilt lower speed limit. WARNING: This Method consumes ...
Definition: PTUFree.cpp:530
#define REGULAR_HOLD_POWER_MODE
Definition: PTUFree.h:30
bool setDesiredPanTiltPositionAbsoluteSlaved(short int pan, short int tilt)
setDesiredPanTiltPositionAbsoluteSlaved Method that allows a movement of pan and tilt axis to specifi...
Definition: PTUFree.cpp:900
long getFactoryMinimumPanPositionLimit()
getFactoryMinimumPanPositionLimit Method to get the factory defined minimum pan position.
Definition: PTUFree.cpp:741
#define LOW_MOVE_POWER_MODE
Definition: PTUFree.h:35
bool setBaudRate(int baud)
setBaudRate Sets the baud rate for the serial port that is used. Only use of serial connection is est...
Definition: PTUFree.cpp:12
long getCurrentUsedMaximumPanPositionLimit()
getCurrentUsedMaximumPanPositionLimit Method to get the currently used maximum pan position...
Definition: PTUFree.cpp:765
bool setMinimumTiltPositionLimit(short int position)
setMinimumTiltPositionLimit Method that is used to set a user defined minimum tilt position limit...
Definition: PTUFree.cpp:660
bool setPositionLimitEnforcementMode(long enable)
setPositionLimitEnforcementMode Method to set the position limit enforcement mode. Warning: USER_DEFINED_LIMITS_ENABLED does not work on older PTUs and setting of this value is not tested.
Definition: PTUFree.cpp:610
bool setDesiredPanPositionAbsolute(short int position)
setDesiredPanPositionAbsolute Method that sets absolute pan position
Definition: PTUFree.cpp:139
bool saveDefault()
saveDefault Method to save the current axis settings as default at power up. Note: This class sets th...
Definition: PTUFree.cpp:1081
#define REGULAR_MOVE_POWER_MODE
Definition: PTUFree.h:34
#define PURE_VELOCITY_CONTROL_MODE
Definition: PTUFree.h:25
bool setDesiredTiltLowerSpeedLimit(short int lower_speed_limit)
setDesiredTiltLowerSpeedLimit Method that sets the lower speed limit for tilt (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:460
boost::asio::serial_port ptu_port
Definition: PTUFree.h:582
bool setTiltStationaryPowerMode(long mode)
setTiltStationaryPowerMode Method to set the stationary power mode for tilt axis. ...
Definition: PTUFree.cpp:1146
bool setMaximumTiltPositionLimit(short int position)
setMaximumTiltPositionLimit Method that is used to set a user defined maximum tilt position limit...
Definition: PTUFree.cpp:672
bool setTiltInMotionPowerMode(long mode)
setTiltInMotionPowerMode Method to set the move power mode for tilt axis.
Definition: PTUFree.cpp:1238
#define TILT_ONLY_RESET_MODE
Definition: PTUFree.h:28
bool reset()
reset Method to reset the ptu (pan and/or tilt axis depending on reset mode)
Definition: PTUFree.cpp:1038
long factory_tilt_min
Definition: PTUFree.h:586
long getCurrentTiltPosition()
getCurrentTiltPosition Method that queries the current tilt position
Definition: PTUFree.cpp:488
long getUserMinimumPanPositionLimit()
getUserMinimumPanPositionLimit Method to get the user defined minimum pan position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:686
bool setDesiredTiltSpeedAbsolute(short int speed)
setDesiredTiltSpeedAbsolute Method that sets absolute tilt speed (position/second) ...
Definition: PTUFree.cpp:401
bool setPanInMotionPowerMode(long mode)
setPanInMotionPowerMode Method to set the move power mode for pan axis.
Definition: PTUFree.cpp:1213
long getDesiredTiltPosition()
getDesiredTiltPosition Method that queries the desired tilt position
Definition: PTUFree.cpp:556
long getPositionExecutionMode()
getPositionExecutionMode Method to get the currently used position execution mode. Can return IMMEDIATE_POSITION_EXECUTION_MODE or SLAVED_POSITION_EXECUTION_MODE.
Definition: PTUFree.cpp:854


asr_flir_ptu_driver
Author(s): Valerij Wittenbeck, Joachim Gehrung, Pascal Meißner, Patrick Schlosser
autogenerated on Mon Dec 2 2019 03:15:17