convert_xy.c
Go to the documentation of this file.
00001 #include "urg_sensor.h"
00002 #include "urg_utils.h"
00003 #include <stdio.h>
00004 #include <math.h>
00005 
00006 int main(void)
00007 {
00008 urg_t urg;
00009 long *length_data = NULL;
00010 int length_data_size;
00011 int i;
00012 // 距離データを X-Y 座標系に変換して表示する
00013 
00014 length_data_size = urg_get_distance(&urg, length_data, NULL);
00015 for (i = 0; i < length_data_size; ++i) {
00016     // その距離データのラジアン角度を求め、X, Y の座標値を計算する
00017     double radian;
00018     long length;
00019     long x;
00020     long y;
00021 
00022     radian = urg_index2rad(&urg, i);
00023     length = length_data[i];
00024     // \todo check length is valid
00025 
00026     x = (long)(length * cos(radian));
00027     y = (long)(length * sin(radian));
00028     printf("(%ld, %ld), ", x, y);
00029 }
00030 printf("\n");
00031 return 0;
00032 }


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Wed Aug 26 2015 16:38:27