All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
get_parameters.c
1 
13 #include "urg_ctrl.h"
14 #include "detect_os.h"
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 
19 static void urg_exit(urg_t *urg, const char *message)
20 {
21  printf("%s: %s\n", message, urg_error(urg));
22  urg_disconnect(urg);
23 
24 #ifdef MSC
25  getchar();
26 #endif
27  exit(1);
28 }
29 
30 
32 int main(int argc, char *argv[])
33 {
34  //const char device[] = "COM3"; /* Example for Windows */
35  const char device[] = "/dev/ttyACM0"; /* Example for Linux */
36 
37  urg_t urg;
38  urg_parameter_t parameters;
39  int ret;
40 
41  /* Connection */
42  ret = urg_connect(&urg, device, 115200);
43  if (ret < 0) {
44  urg_exit(&urg, "urg_connect()");
45  }
46 
47  /* Get sensor parameter */
48  ret = urg_parameters(&urg, &parameters);
49  printf("urg_getParameters: %s\n", urg_error(&urg));
50  if (ret < 0) {
51  urg_disconnect(&urg);
52  exit(1);
53  }
54 
55  /* Connection */
56  printf("distance_min: %ld\n", parameters.distance_min_);
57  printf("distance_max: %ld\n", parameters.distance_max_);
58  printf("area_total: %d\n", parameters.area_total_);
59  printf("area_min: %d\n", parameters.area_min_);
60  printf("area_max: %d\n", parameters.area_max_);
61  printf("area_front: %d\n", parameters.area_front_);
62  printf("scan_rpm: %d\n", parameters.scan_rpm_);
63  printf("\n");
64 
65  /* Display information from URG structure ( same resource as above) */
66  printf("urg_getDistanceMax(): %ld\n", urg_maxDistance(&urg));
67  printf("urg_getDistanceMin(): %ld\n", urg_minDistance(&urg));
68  printf("urg_getScanMsec(): %d\n", urg_scanMsec(&urg));
69  printf("urg_getDataMax(): %d\n", urg_dataMax(&urg));
70 
71  return 0;
72 }