Enumerations | Functions | Variables
urg_sensor.c File Reference
#include "urg_c/urg_sensor.h"
#include "urg_c/urg_errno.h"
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for urg_sensor.c:

Go to the source code of this file.

Enumerations

enum  {
  URG_FALSE = 0, URG_TRUE = 1, BUFFER_SIZE = 64 + 2 + 6, EXPECTED_END = -1,
  RECEIVE_DATA_TIMEOUT, RECEIVE_DATA_COMPLETE, PP_RESPONSE_LINES = 10, VV_RESPONSE_LINES = 7,
  II_RESPONSE_LINES = 9, MAX_TIMEOUT = 140
}
 URG センサ制御 More...

Functions

static int change_sensor_baudrate (urg_t *urg, long current_baudrate, long next_baudrate)
static int connect_urg_device (urg_t *urg, long baudrate)
static char * copy_token (char *dest, char *receive_buffer, const char *start_str, const char *end_ch, int lines)
static void ignore_receive_data (urg_t *urg, int timeout)
static void ignore_receive_data_with_qt (urg_t *urg, int timeout)
static urg_measurement_type_t parse_distance_echoback (urg_t *urg, const char echoback[])
static urg_measurement_type_t parse_distance_parameter (urg_t *urg, const char echoback[])
static int parse_parameter (const char *parameter, int size)
static const char * receive_command_response (urg_t *urg, char *buffer, int buffer_size, const char *command, int response_lines)
static int receive_data (urg_t *urg, long data[], unsigned short intensity[], long *time_stamp, unsigned long long *system_time_stamp)
 距離データの取得
static int receive_length_data (urg_t *urg, long length[], unsigned short intensity[], urg_measurement_type_t type, char buffer[])
static int receive_parameter (urg_t *urg)
static char scip_checksum (const char buffer[], int size)
 チェックサムの計算
static int scip_response (urg_t *urg, const char *command, const int expected_ret[], int timeout, char *receive_buffer, int receive_buffer_max_size)
static int send_distance_command (urg_t *urg, int scan_times, int skip_scan, char single_scan_ch, char continuous_scan_ch, char scan_type_ch)
static int set_errno_and_return (urg_t *urg, int urg_errno)
void urg_close (urg_t *urg)
int urg_get_distance (urg_t *urg, long data[], long *time_stamp, unsigned long long *system_time_stamp)
int urg_get_distance_intensity (urg_t *urg, long data[], unsigned short intensity[], long *time_stamp, unsigned long long *system_time_stamp)
int urg_get_multiecho (urg_t *urg, long data_multi[], long *time_stamp, unsigned long long *system_time_stamp)
int urg_get_multiecho_intensity (urg_t *urg, long data_multi[], unsigned short intensity_multi[], long *time_stamp, unsigned long long *system_time_stamp)
int urg_is_stable (urg_t *urg)
int urg_laser_off (urg_t *urg)
int urg_laser_on (urg_t *urg)
int urg_open (urg_t *urg, urg_connection_type_t connection_type, const char *device_or_address, long baudrate_or_port)
int urg_reboot (urg_t *urg)
long urg_scip_decode (const char data[], int size)
 SCIP 文字列のデコード
const char * urg_sensor_firmware_date (urg_t *urg)
const char * urg_sensor_firmware_version (urg_t *urg)
const char * urg_sensor_product_type (urg_t *urg)
const char * urg_sensor_protocol_version (urg_t *urg)
 returns the protocol version
const char * urg_sensor_serial_id (urg_t *urg)
const char * urg_sensor_state (urg_t *urg)
const char * urg_sensor_status (urg_t *urg)
const char * urg_sensor_vendor (urg_t *urg)
 returns the vendor name
int urg_set_connection_data_size (urg_t *urg, urg_range_data_byte_t data_byte)
void urg_set_error_handler (urg_t *urg, urg_error_handler handler)
int urg_set_scanning_parameter (urg_t *urg, int first_step, int last_step, int skip_step)
void urg_set_timeout_msec (urg_t *urg, int msec)
 タイムアウト時間の設定
void urg_sleep (urg_t *urg)
int urg_start_measurement (urg_t *urg, urg_measurement_type_t type, int scan_times, int skip_scan)
int urg_start_time_stamp_mode (urg_t *urg)
int urg_stop_measurement (urg_t *urg)
int urg_stop_time_stamp_mode (urg_t *urg)
long urg_time_stamp (urg_t *urg)
void urg_wakeup (urg_t *urg)

Variables

static const char NOT_CONNECTED_MESSAGE [] = "not connected."
static const char RECEIVE_ERROR_MESSAGE [] = "receive error."

Enumeration Type Documentation

anonymous enum

URG センサ制御

Author:
Satofumi KAMIMURA
Id:
urg_sensor.c,v 66816edea765 2011/05/03 06:53:52 satofumi
Todo:
Mx 計測中に他の Mx コマンドを送信したときに、適切に動作するようにする
Enumerator:
URG_FALSE 
URG_TRUE 
BUFFER_SIZE 
EXPECTED_END 
RECEIVE_DATA_TIMEOUT 
RECEIVE_DATA_COMPLETE 

データを正常に受信

PP_RESPONSE_LINES 
VV_RESPONSE_LINES 
II_RESPONSE_LINES 
MAX_TIMEOUT 

Definition at line 23 of file urg_sensor.c.


Function Documentation

static int change_sensor_baudrate ( urg_t urg,
long  current_baudrate,
long  next_baudrate 
) [static]

Definition at line 177 of file urg_sensor.c.

static int connect_urg_device ( urg_t urg,
long  baudrate 
) [static]

Definition at line 213 of file urg_sensor.c.

static char* copy_token ( char *  dest,
char *  receive_buffer,
const char *  start_str,
const char *  end_ch,
int  lines 
) [static]

Definition at line 1129 of file urg_sensor.c.

static void ignore_receive_data ( urg_t urg,
int  timeout 
) [static]

Definition at line 146 of file urg_sensor.c.

static void ignore_receive_data_with_qt ( urg_t urg,
int  timeout 
) [static]

Definition at line 164 of file urg_sensor.c.

static urg_measurement_type_t parse_distance_echoback ( urg_t urg,
const char  echoback[] 
) [static]

Definition at line 425 of file urg_sensor.c.

static urg_measurement_type_t parse_distance_parameter ( urg_t urg,
const char  echoback[] 
) [static]

Definition at line 390 of file urg_sensor.c.

static int parse_parameter ( const char *  parameter,
int  size 
) [static]

Definition at line 379 of file urg_sensor.c.

static const char* receive_command_response ( urg_t urg,
char *  buffer,
int  buffer_size,
const char *  command,
int  response_lines 
) [static]

Definition at line 1158 of file urg_sensor.c.

static int receive_data ( urg_t urg,
long  data[],
unsigned short  intensity[],
long *  time_stamp,
unsigned long long *  system_time_stamp 
) [static]

距離データの取得

Definition at line 568 of file urg_sensor.c.

static int receive_length_data ( urg_t urg,
long  length[],
unsigned short  intensity[],
urg_measurement_type_t  type,
char  buffer[] 
) [static]

Definition at line 448 of file urg_sensor.c.

static int receive_parameter ( urg_t urg) [static]

Definition at line 294 of file urg_sensor.c.

static char scip_checksum ( const char  buffer[],
int  size 
) [static]

チェックサムの計算

Definition at line 47 of file urg_sensor.c.

static int scip_response ( urg_t urg,
const char *  command,
const int  expected_ret[],
int  timeout,
char *  receive_buffer,
int  receive_buffer_max_size 
) [static]

Definition at line 69 of file urg_sensor.c.

static int send_distance_command ( urg_t urg,
int  scan_times,
int  skip_scan,
char  single_scan_ch,
char  continuous_scan_ch,
char  scan_type_ch 
) [static]

Definition at line 832 of file urg_sensor.c.

static int set_errno_and_return ( urg_t urg,
int  urg_errno 
) [static]

Definition at line 61 of file urg_sensor.c.

void urg_close ( urg_t urg)
See also:
urg_open()

Definition at line 745 of file urg_sensor.c.

int urg_get_distance ( urg_t urg,
long  data[],
long *  time_stamp,
unsigned long long *  system_time_stamp 
)
See also:
urg_start_measurement(), urg_max_data_size()

Definition at line 934 of file urg_sensor.c.

int urg_get_distance_intensity ( urg_t urg,
long  data[],
unsigned short  intensity[],
long *  time_stamp,
unsigned long long *  system_time_stamp 
)

Example

      int data_size = urg_max_data_size(&urg);
      long *data = malloc(data_size * sizeof(long));
      long *intensity = malloc(data_size * sizeof(unsigned short));

      ...

      urg_start_measurement(&urg, URG_DISTANCE_INTENSITY, 1, 0);
      int n = urg_get_distance_intensity(&urg, data, intesnity, NULLL); 
See also:
urg_start_measurement(), urg_max_data_size()

Definition at line 943 of file urg_sensor.c.

int urg_get_multiecho ( urg_t urg,
long  data_multi[],
long *  time_stamp,
unsigned long long *  system_time_stamp 
)

Example

      long *data_multi = malloc(3 * urg_max_data_size(&urg) * sizeof(long));

      ...

      urg_start_measurement(&urg, URG_MULTIECHO, 1, 0);
      int n = urg_get_distance_intensity(&urg, data_multi, NULLL); 
See also:
urg_start_measurement(), urg_max_data_size()

Definition at line 955 of file urg_sensor.c.

int urg_get_multiecho_intensity ( urg_t urg,
long  data_multi[],
unsigned short  intensity_multi[],
long *  time_stamp,
unsigned long long *  system_time_stamp 
)

Example

      int data_size = urg_max_data_size(&urg);
      long *data_multi = malloc(3 * data_size * sizeof(long));
      long *intensity_multi = malloc(3 * data_size * sizeof(unsigned short));

      ...

      urg_start_measurement(&urg, URG_DISTANCE_INTENSITY, 1, 0);
      int n = urg_get_multiecho_intensity(&urg, data_multi,
      intesnity_multi, NULLL); 
See also:
urg_start_measurement(), urg_max_data_size()

Definition at line 965 of file urg_sensor.c.

int urg_is_stable ( urg_t urg)

Definition at line 1122 of file urg_sensor.c.

int urg_laser_off ( urg_t urg)

Definition at line 1070 of file urg_sensor.c.

int urg_laser_on ( urg_t urg)

Definition at line 1046 of file urg_sensor.c.

int urg_open ( urg_t urg,
urg_connection_type_t  connection_type,
const char *  device_or_address,
long  baudrate_or_port 
)
See also:
urg_close()

Definition at line 684 of file urg_sensor.c.

int urg_reboot ( urg_t urg)

Definition at line 1076 of file urg_sensor.c.

long urg_scip_decode ( const char  data[],
int  size 
)

SCIP 文字列のデコード

Definition at line 364 of file urg_sensor.c.

const char* urg_sensor_firmware_date ( urg_t urg)

Definition at line 1268 of file urg_sensor.c.

const char* urg_sensor_firmware_version ( urg_t urg)

Definition at line 1244 of file urg_sensor.c.

const char* urg_sensor_product_type ( urg_t urg)

Definition at line 1180 of file urg_sensor.c.

const char* urg_sensor_protocol_version ( urg_t urg)

returns the protocol version

Parameters:
[in]URG
Returns:
The current protocol version

Definition at line 1300 of file urg_sensor.c.

const char* urg_sensor_serial_id ( urg_t urg)

Definition at line 1201 of file urg_sensor.c.

const char* urg_sensor_state ( urg_t urg)

Definition at line 1350 of file urg_sensor.c.

const char* urg_sensor_status ( urg_t urg)

Definition at line 1325 of file urg_sensor.c.

const char* urg_sensor_vendor ( urg_t urg)

returns the vendor name

Parameters:
[in]URG
Returns:
The vendor name

Definition at line 1221 of file urg_sensor.c.

Definition at line 1028 of file urg_sensor.c.

void urg_set_error_handler ( urg_t urg,
urg_error_handler  handler 
)

Definition at line 1375 of file urg_sensor.c.

int urg_set_scanning_parameter ( urg_t urg,
int  first_step,
int  last_step,
int  skip_step 
)

Example

      urg_set_scanning_parameter(&urg, urg_deg2step(&urg, -45),
      urg_deg2step(&urg, +45), 1);
      urg_start_measurement(&urg, URG_DISTANCE, 0);
      int n = urg_get_distance(&urg, data, NULL);
      for (int i = 0; i < n; ++i) {
      printf("%d [mm], %d [deg]\n", data[i], urg_index2deg(&urg, i));
      } 
See also:
urg_step_min_max(), urg_rad2step(), urg_deg2step()

Definition at line 1009 of file urg_sensor.c.

void urg_set_timeout_msec ( urg_t urg,
int  msec 
)

タイムアウト時間の設定

Parameters:
[in,out]urgURG センサ管理
[in]msecタイムアウトする時間 [msec]
Attention:
urg_open() を呼び出すと timeout の設定値はデフォルト値に初期化されるため、この関数は urg_open() 後に呼び出すこと。

Definition at line 755 of file urg_sensor.c.

void urg_sleep ( urg_t urg)

Definition at line 1101 of file urg_sensor.c.

int urg_start_measurement ( urg_t urg,
urg_measurement_type_t  type,
int  scan_times,
int  skip_scan 
)

Definition at line 761 of file urg_sensor.c.

int urg_stop_measurement ( urg_t urg)

Example

      urg_start_measurement(&urg, URG_DISTANCE, URG_SCAN_INFINITY, 0);
      for (int i = 0; i < 10; ++i) {
      urg_get_distance(&urg, data, NULL);
      }
      urg_stop_measurement(&urg); 
See also:
urg_start_measurement()

Definition at line 978 of file urg_sensor.c.

Definition at line 813 of file urg_sensor.c.

long urg_time_stamp ( urg_t urg)

Definition at line 780 of file urg_sensor.c.

void urg_wakeup ( urg_t urg)

Definition at line 1116 of file urg_sensor.c.


Variable Documentation

const char NOT_CONNECTED_MESSAGE[] = "not connected." [static]

Definition at line 42 of file urg_sensor.c.

const char RECEIVE_ERROR_MESSAGE[] = "receive error." [static]

Definition at line 43 of file urg_sensor.c.



urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Thu Jun 6 2019 19:06:57