All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Functions
include/c/urg_utils.h File Reference

URG sensor utility. More...

#include "urg_sensor.h"

Go to the source code of this file.

Functions

const char * urg_error (const urg_t *urg)
 Returns the string message for the last URG error.
void urg_distance_min_max (const urg_t *urg, long *min_distance, long *max_distance)
 Obtains the minimum and maximum distance values from sensor measurements.
void urg_step_min_max (const urg_t *urg, int *min_step, int *max_step)
 Gets the minimum and maximum step numbers.
long urg_scan_usec (const urg_t *urg)
 Returns the time [usec] for 1 scan.
int urg_max_data_size (const urg_t *urg)
 Returns the maximum size of data received from the sensor.
double urg_index2rad (const urg_t *urg, int index)
 Converts index to angle in radians.
double urg_index2deg (const urg_t *urg, int index)
 Converts index to angle in degrees.
int urg_rad2index (const urg_t *urg, double radian)
 Converts angle in radians to index.
int urg_deg2index (const urg_t *urg, double degree)
 Converts angle in degrees to index.
int urg_rad2step (const urg_t *urg, double radian)
 Converts angle in radians to step number.
int urg_deg2step (const urg_t *urg, double degree)
 Converts angle in degrees to step number.
double urg_step2rad (const urg_t *urg, int step)
 Converts step number to angle in radians.
double urg_step2deg (const urg_t *urg, int step)
 Converts step number to angle in degrees.
int urg_step2index (const urg_t *urg, int step)
 Converts step number to index.

Detailed Description

URG sensor utility.

Author:
Satofumi KAMIMURA
Id:
urg_utils.h,v e5d1719877a2 2015/05/07 04:12:14 jun

Function Documentation

void urg_distance_min_max ( const urg_t urg,
long *  min_distance,
long *  max_distance 
)

Obtains the minimum and maximum distance values from sensor measurements.

 \param[in] urg URG control structure
 \param[out] min_distance minimum distance [mm]
 \param[out] max_distance maximum distance [mm]


 Example
      long min_distance, max_distance;
      urg_distance_min_max(&urg, &min_distance, &max_distance);

      for (int i = 0; i < n; ++i) {
      long distance = data[i];
      if ((distance < min_distance) || (distance > max_distance)) {
      continue;
      }
      ...
      } 
Examples:
calculate_xy.c, get_distance.c, and sensor_parameter.c.
const char* urg_error ( const urg_t urg)

Returns the string message for the last URG error.

 \param[in] urg URG control structure

 \retval String message for the last URG error


 Example
      if (!urg_open(&urg, "/dev/ttyACM0", 115200, URG_SERIAL)) {
      printf("urg_open: %s\n", urg_error(&urg));
      return -1;
      } 
Examples:
calculate_xy.c, get_distance.c, get_distance_intensity.c, get_multiecho.c, get_multiecho_intensity.c, and sync_time_stamp.c.
double urg_index2rad ( const urg_t urg,
int  index 
)

Converts index to angle in radians.

 Index is the position of each measurement data in the array returned using urg_get_distance().
 This function applies to the last array of measurement data read from the sensor.

 \param[in] urg URG control structure
 \param[in] index index value

 \return Angle [radian]

 The index value depends on the start/end steps configuration used for measurement.

 \image html sensor_index_image.png shows the relation between start/end step configuration and index


 Example
      int n = urg_get_distance(&urg, data, NULL);
      for (int i = 0; i < n; ++i) {
      long distance = data[i];
      double radian = urg_index2rad(i);
      double x = distance * cos(radian);
      double y = distance * sin(radian);
      printf("%.1f, %.1f\n", x, y);
      } 
See also:
urg_index2deg(), urg_rad2index(), urg_deg2index()
Examples:
calculate_xy.c, and get_distance.c.
int urg_rad2step ( const urg_t urg,
double  radian 
)

Converts angle in radians to step number.

Conversion to angle (radian) is performed according to the min/max step definition using urg_step_min_max().

Parameters:
[in]urgURG control structure
[in]radianangle [radian]
Returns:
step value
sensor_angle_image.png
shows the relation between steps and angles

When the conversion from angle to step results on a fractional number, the value is rounded down towards zero (floor).

  \see urg_step_min_max(), urg_deg2step(), urg_step2rad(), urg_step2deg()
void urg_step_min_max ( const urg_t urg,
int *  min_step,
int *  max_step 
)

Gets the minimum and maximum step numbers.

 Returns the minimum step and maximum step values as configured using urg_set_scanning_parameter()

 \param[in] urg URG control structure
 \param[out] min_step minimum step
 \param[out] max_step maximum step

 As seen from the top of the sensor: the frontal step is 0, going counter-clockwise are positive values, going clockwise are negative values.

 \image html sensor_step_image.png shows the relation between sensor and steps

 The actual values for min_step, max_step change with sensor type/series.


 Example
      urg_step_min_max(&urg, &min_step, &max_step);

      printf("range first: %d [deg]\n", urg_step2deg(&urg, min_step));
      printf("range last : %d [deg]\n", urg_step2deg(&urg, max_step)); 
See also:
urg_set_scanning_parameter(), urg_step2rad(), urg_step2deg()
Examples:
angle_convert_test.c, and sensor_parameter.c.