URG sensor Driver. More...
#include "urg_connection.h"
Go to the source code of this file.
Data Structures | |
struct | urg_t |
URG Sensor Driver. More... | |
Typedefs | |
typedef urg_measurement_type_t(* | urg_error_handler )(const char *status, void *urg) |
Enumerations | |
enum | urg_measurement_type_t { URG_DISTANCE, URG_DISTANCE_INTENSITY, URG_MULTIECHO, URG_MULTIECHO_INTENSITY, URG_STOP, URG_UNKNOWN } |
Measurement type. More... | |
enum | urg_range_data_byte_t { URG_COMMUNICATION_3_BYTE, URG_COMMUNICATION_2_BYTE } |
This function sets the number of bytes that represent the distance. More... | |
enum | { URG_SCAN_INFINITY = 0, URG_MAX_ECHO = 3 } |
Functions | |
int | urg_open (urg_t *urg, urg_connection_type_t connection_type, const char *device_or_address, long baudrate_or_port) |
Open the connection. More... | |
void | urg_close (urg_t *urg) |
Close the connection. More... | |
void | urg_set_timeout_msec (urg_t *urg, int msec) |
Set connection timeout. More... | |
int | urg_start_time_stamp_mode (urg_t *urg) |
Enter Time_adjustment mode. | |
long | urg_time_stamp (urg_t *urg) |
Retrieve Timestamp value. More... | |
int | urg_stop_time_stamp_mode (urg_t *urg) |
Leave Time_adjustment mode. | |
int | urg_start_measurement (urg_t *urg, urg_measurement_type_t type, int scan_times, int skip_scan) |
Start measurement. More... | |
int | urg_get_distance (urg_t *urg, long data[], long *time_stamp) |
Retrieve Distance data. More... | |
int | urg_get_distance_intensity (urg_t *urg, long data[], unsigned short intensity[], long *time_stamp) |
Retrieve Distance and Intensity data. More... | |
int | urg_get_multiecho (urg_t *urg, long data_multi[], long *time_stamp) |
Retrieve Distance data (Multi-echo version) More... | |
int | urg_get_multiecho_intensity (urg_t *urg, long data_multi[], unsigned short intensity_multi[], long *time_stamp) |
Retrieve Distance and Intensity data (Multi-echo version) More... | |
int | urg_stop_measurement (urg_t *urg) |
Stop measurement and turn off laser. More... | |
int | urg_set_scanning_parameter (urg_t *urg, int first_step, int last_step, int skip_step) |
Set the measurement range. More... | |
int | urg_set_communication_data_size (urg_t *urg, urg_range_data_byte_t data_byte) |
Set the size of communication data. More... | |
int | urg_laser_on (urg_t *urg) |
Turn on laser. | |
int | urg_laser_off (urg_t *urg) |
Turn off laser. | |
int | urg_reboot (urg_t *urg) |
Reboot sensor. | |
void | urg_sleep (urg_t *urg) |
センサを低消費電力の状態に遷移させる More... | |
void | urg_wakeup (urg_t *urg) |
センサを低消費電力のモードから通常の状態に遷移させる More... | |
int | urg_is_stable (urg_t *urg) |
センサが計測できる状態かを返す More... | |
const char * | urg_sensor_product_type (urg_t *urg) |
Get product type string. More... | |
const char * | urg_sensor_serial_id (urg_t *urg) |
Get Serial ID. More... | |
const char * | urg_sensor_firmware_version (urg_t *urg) |
Get firmware version. More... | |
const char * | urg_sensor_status (urg_t *urg) |
Get sensor status string. More... | |
const char * | urg_sensor_state (urg_t *urg) |
Get sensor state string. More... | |
void | urg_set_error_handler (urg_t *urg, urg_error_handler handler) |
Set error handler. More... | |
long | urg_scip_decode (const char data[], int size) |
Decode SCIP string. More... | |
URG sensor Driver.
This module provides basic functions for URG sensor.
typedef urg_measurement_type_t(* urg_error_handler)(const char *status, void *urg) |
Error handler
anonymous enum |
int urg_open | ( | urg_t * | urg, |
urg_connection_type_t | connection_type, | ||
const char * | device_or_address, | ||
long | baudrate_or_port | ||
) |
Open the connection.
Connect to the specified device, to be able to measure the distance.
[in,out] | urg | URG resource |
[in] | connection_type | connection type |
[in] | device_or_address | connection device name / IP address |
[in] | baudrate_or_port | baudrate [bps] / TCP/IP port |
0 | Success |
<0 | Error |
Connection types
Example
void urg_close | ( | urg_t * | urg | ) |
Close the connection.
Turn off the laser, and close the connection with the URG.
[in,out] | urg | URG resource |
void urg_set_timeout_msec | ( | urg_t * | urg, |
int | msec | ||
) |
Set connection timeout.
[in,out] | urg | URG resource |
[in] | msec | Timeout [msec] |
long urg_time_stamp | ( | urg_t * | urg | ) |
Retrieve Timestamp value.
[in,out] | urg | URG resource |
>=0 | Timestamp value [msec] |
<0 | Error |
Example
int urg_start_measurement | ( | urg_t * | urg, |
urg_measurement_type_t | type, | ||
int | scan_times, | ||
int | skip_scan | ||
) |
Start measurement.
Start measurement. The actual data you can get in urg_get_distance(), urg_get_distance_intensity(), urg_get_multiecho(), urg_get_multiecho_intensity().
[in,out] | urg | URG resource |
[in] | type | Measurement type |
[in] | scan_times | Measurement times |
[in] | skip_scan | Measurement interval |
0 | Success |
<0 | Error |
the argument of 'type' can specify the type of data you want to retrieve.
'scan_times' is specified by the number of zero or more times or to get the data. However, if you specify 0 or # URG_SCAN_INFINITY, you will get the data for an unlimited number of times.
Call urg_stop_measurement() to stop the measurement.
'skip_scan' means the number of rotation of the mirror, or do not want to scan many times after a single scan. the range skip_scan is [0, 9].
For example, if the rotation of the mirror is the 1 specified in skip_scan sensor of 100 [msec], data acquisition interval is 200 [msec].
Example
int urg_get_distance | ( | urg_t * | urg, |
long | data[], | ||
long * | time_stamp | ||
) |
Retrieve Distance data.
Retrieve distance data from the sensor distance. You must specify URG_DISTANCE to call urg_start_measurement() in advance.
[in,out] | urg | URG resource |
[out] | data | Distance data [mm] |
[out] | time_stamp | Timestamp [msec] |
>=0 | Number of retrieve data |
<0 | Error |
'data', the distance data obtained from the sensor is stored. 'data' must be set aside to store the data size. Number of data to be stored in the data can be obtained in urg_max_data_size().
'time_stamp', the time stamp is stored inside the sensor. Please specify NULL if you do not want to get time_stamp.
Example
int urg_get_distance_intensity | ( | urg_t * | urg, |
long | data[], | ||
unsigned short | intensity[], | ||
long * | time_stamp | ||
) |
Retrieve Distance and Intensity data.
It is a function of the distance and intensity data that can be acquired. You must call urg_start_measurement() with URG_DISTANCE_INTENSITY in advance.
[in,out] | urg | URG resource |
[out] | data | Distance data [mm] |
[out] | intensity | Intensity data [1] |
[out] | time_stamp | Timestamp [msec] |
>=0 | Number of retrieve data |
<0 | Error |
Reflection intensity waveform is used to calculate the distance and intensity data are different for each series of the sensor characteristics. By using the intensity data, you can guess the rough shading of the reflectance of the object and the environment.
'data' and 'time_stamp' is the same behavior urg_get_distance().
in 'intensity', the intensity data obtained from the sensor is stored. 'intensity' should be set aside to store the data size. Number of data to be stored in the 'intensity' can be obtained by urg_max_data_size().
Example
int urg_get_multiecho | ( | urg_t * | urg, |
long | data_multi[], | ||
long * | time_stamp | ||
) |
Retrieve Distance data (Multi-echo version)
This function is multiecho version of urg_get_distance(). You must call urg_start_measurement() with URG_MULTIECHO in advance.
[in,out] | urg | URG resource |
[out] | data_multi | Distance data (Multiecho) [mm] |
[out] | time_stamp | Timestamp [msec] |
>=0 | Number of retrieve data |
<0 | Error |
The multi-echo means multi-distance data. Multiple echoes are obtained when a plurality of distance data obtained in one laser emission.
'time_stamp' is the same behavior urg_get_distance().
'data_multi', the distance data obtained from the sensors are stored per URG_MAX_ECHO(=3) in one step. Multi-echo data value of the item does not exist, -1 is stored.
data_multi[0] ... Step n data (1st echo) data_multi[1] ... Step n data (2nd echo) data_multi[2] ... Step n data (3rd echo) data_multi[3] ... Step (n + 1) data (1st echo) data_multi[4] ... Step (n + 1) data (2nd echo) data_multi[5] ... Step (n + 1) data (3rd echo) ...
Data is stored in ascending order.
Example
int urg_get_multiecho_intensity | ( | urg_t * | urg, |
long | data_multi[], | ||
unsigned short | intensity_multi[], | ||
long * | time_stamp | ||
) |
Retrieve Distance and Intensity data (Multi-echo version)
This function is multiecho version of urg_get_distance_intensity(). You must call urg_start_measurement() with URG_MULTIECHO_INTENSITY in advance.
[in,out] | urg | URG resource |
[out] | data_multi | Distance data [mm] |
[out] | intensity_multi | Intensity data [1] |
[out] | time_stamp | Timestamp [msec] |
>=0 | Number of retrieve data |
<0 | Error |
'data_multi', 'time_stamp' is the same behavior urg_get_multiecho().
'intensity_multi' sequence data is the same as data_multi. Number of data to be stored in the 'intensity_multi' can be obtained by urg_max_data_size().
Example
int urg_stop_measurement | ( | urg_t * | urg | ) |
Stop measurement and turn off laser.
Cancel the operation of urg_start_measurement().
[in,out] | urg | URG resource |
0 | Success |
<0 | Error |
Example
int urg_set_scanning_parameter | ( | urg_t * | urg, |
int | first_step, | ||
int | last_step, | ||
int | skip_step | ||
) |
Set the measurement range.
This function specified the sensor measures range. The amount of data returned by the function of the distance data acquisition such as urg_get_distance() is limited to the extent that you specify here.
[in,out] | urg | URG resource |
[in] | first_step | first step |
[in] | last_step | last step |
[in] | skip_step | number of grouping steps |
0 | Success |
<0 | Error |
センサの step は、センサ正面を 0 とし、センサ上部から見て反時計まわりの向きが正の値となる順に割り振られます。
step の間隔と、最大値、最小値はセンサ依存です。step 値の最大値、最小値は urg_step_min_max() で取得できます。
first_step, last_step でデータの計測範囲を指定します。計測範囲は [first_step, last_step] となります。
skip_step は、計測データをグルーピングする個数を指定します。指定できる値は [0, 99] です。
skip_step は、指定された数のデータを 1 つにまとめることで、センサから受信するデータ量を減らし、距離取得を行う関数の応答性を高めるときに使います。ただし、データをまとめるため、得られるデータの分解能は減ります。
例えば以下のような距離データが得られる場合に
100, 101, 102, 103, 104, 105, 106, 107, 108, 109
skip_step に 2 を指定すると、得られるデータは以下のようになります。
100, 102, 104, 106, 108
データは、まとめるデータのうち、一番小さな値のデータが用いられます。
Example
int urg_set_communication_data_size | ( | urg_t * | urg, |
urg_range_data_byte_t | data_byte | ||
) |
Set the size of communication data.
距離データをセンサから受信の際のデータサイズを変更します。
[in,out] | urg | URG センサ管理 |
[in] | data_byte | 距離値を表現するデータのバイト数 |
0 | Success |
<0 | Error |
data_byte には
を指定できます。
初期状態では距離を 3 byte で表現するようになっています。この設定を 2 byte に設定することで、センサから受信するデータ数は 2/3 になります。ただし、取得できる距離の最大値が 4095 になるため、観測したい対象が 4 [m] 以内の範囲に存在する場合のみ利用して下さい。
void urg_sleep | ( | urg_t * | urg | ) |
センサを低消費電力の状態に遷移させる
低消費電力のモードでは、スキャナの回転が停止し計測も中断されます。
低消費電力のモードから抜けるためには urg_wakeup() 関数を呼び出して下さい。
void urg_wakeup | ( | urg_t * | urg | ) |
センサを低消費電力のモードから通常の状態に遷移させる
int urg_is_stable | ( | urg_t * | urg | ) |
センサが計測できる状態かを返す
1 | センサが計測できる状態にある |
0 | センサが計測できる状態にない |
起動直後でスキャナの回転が安定していない場合や、何らかのエラーで計測できない場合、この関数は 0 を返します。
const char* urg_sensor_product_type | ( | urg_t * | urg | ) |
Get product type string.
センサの型式を文字列で返す。返される文字列はセンサ依存となる。
[in] | urg | URG センサ管理 |
const char* urg_sensor_serial_id | ( | urg_t * | urg | ) |
Get Serial ID.
センサのシリアル ID 文字列を返す。返される文字列はセンサ依存となる。
[in] | urg | URG センサ管理 |
const char* urg_sensor_firmware_version | ( | urg_t * | urg | ) |
Get firmware version.
センサのソフトウェア・バージョン文字列を返す。返される文字列はセンサ依存となる。
[in] | urg | URG センサ管理 |
const char* urg_sensor_status | ( | urg_t * | urg | ) |
Get sensor status string.
センサのステータス文字列を返す。返される文字列はセンサ依存となる。
[in] | urg | URG センサ管理 |
const char* urg_sensor_state | ( | urg_t * | urg | ) |
Get sensor state string.
センサのステータス文字列を返す。返される文字列はセンサ依存となる。
[in] | urg | URG センサ管理 |
void urg_set_error_handler | ( | urg_t * | urg, |
urg_error_handler | handler | ||
) |
Set error handler.
エラーハンドラは Gx, Mx 系のコマンドの応答が "00" か "99" 以外のときに呼び出される。
long urg_scip_decode | ( | const char | data[], |
int | size | ||
) |
Decode SCIP string.
[in] | data | SCIP string |
[in] | data | number of data byte |
decoded | value |