This module provides useful basic facilities to use the KoreBot with the LedRangeFinder card. More...
Go to the source code of this file.
Data Structures | |
struct | urg_state_t |
Defines | |
#define | GPIO_POWER 16 |
#define | BAUDRATE 19200 |
Enumerations | |
enum | { Timeout = 800, LineLength = 16 + 64 + 1 + 1 + 1 } |
Functions | |
static int | com_connect (const char *device, long baudrate) |
static int | com_send (const char *data, int size) |
static int | com_recv (char *data, int max_size, int timeout) |
static int | urg_sendTag (const char *tag) |
static int | urg_readLine (char *buffer) |
static int | urg_sendMessage (const char *command, int timeout, int *recv_n) |
static int | urg_getParameters (urg_state_t *state) |
static int | urg_connect (urg_state_t *state, const char *port, const long baudrate) |
static int | urg_captureByGD (const urg_state_t *state) |
static int | urg_captureByMD (const urg_state_t *state, int capture_times) |
static long | urg_decode (const char *data, int data_byte) |
static int | urg_addRecvData (const char buffer[], long data[], int *filled) |
static int | urg_receiveData (urg_state_t *state, long data[], size_t max_size) |
long | kb_lrf_Get_Timestamp (void) |
void | kb_lrf_Laser_On (int LRF_DeviceHandle) |
void | kb_lrf_Laser_Off (int LRF_DeviceHandle) |
void | kb_lrf_Power_On (void) |
void | kb_lrf_Power_Off (void) |
int | kb_lrf_Init (char *LRF_DeviceName) |
void | kb_lrf_Close (int LRF_DeviceHandle) |
int | kb_lrf_GetDistances (int LRF_DeviceHandle) |
int | kb_lrf_GetDistances_Averaged (int LRF_DeviceHandle, int average) |
Variables | |
static int | HComm = -1 |
static char * | ErrorMessage = "no error." |
urg_state_t | urg_state |
long | kb_lrf_DistanceData [LRF_DATA_NB] |
long | kb_lrf_DistanceDataSensor [LRF_DATA_NB] |
long | kb_lrf_DistanceDataSum [LRF_DATA_NB] |
int | kb_lrf_DistanceGoodCounter [LRF_DATA_NB] |
This module provides useful basic facilities to use the KoreBot with the LedRangeFinder card.
Support for KoreBot Led Range Finder.
Definition in file kb_lrf.c.
#define BAUDRATE 19200 |
Definition at line 38 of file kb_lrf.c.
Referenced by kb_lrf_Init(), and main().
#define GPIO_POWER 16 |
Definition at line 36 of file kb_lrf.c.
Referenced by kb_lrf_Power_Off(), and kb_lrf_Power_On().
static int com_connect | ( | const char * | device, | |
long | baudrate | |||
) | [static] |
static int com_recv | ( | char * | data, | |
int | max_size, | |||
int | timeout | |||
) | [static] |
receive data from serial port
data | data to be sent to the port | |
max_size | max size of the data variable | |
timeout | timeout in [ms] |
Definition at line 155 of file kb_lrf.c.
References HComm.
Referenced by urg_sendMessage().
static int com_send | ( | const char * | data, | |
int | size | |||
) | [static] |
write to serial port
data | data to be sent to the port | |
size | size of the data \ |
Definition at line 136 of file kb_lrf.c.
References HComm.
Referenced by urg_sendTag().
void kb_lrf_Close | ( | int | LRF_DeviceHandle | ) |
kb_lrf_Close does powering off the LRF, the close the port device
LRF_DeviceHandle | Handle to the lrf port which as been openned by kb_lrf_openComPort or kb_lrf_init |
Definition at line 737 of file kb_lrf.c.
References kb_lrf_Laser_Off().
Referenced by ctrlc_handler(), handle_kill(), main(), and poweroff().
long kb_lrf_Get_Timestamp | ( | void | ) |
kb_lrf_get_timestamp : get the last timestep in [ms]
Definition at line 628 of file kb_lrf.c.
References urg_state_t::last_timestamp.
Referenced by lrfmeasure().
int kb_lrf_GetDistances | ( | int | LRF_DeviceHandle | ) |
kb_lrf_GetDistances is a high level function that does whole mechanism certify the link, get some distances.
LRF_DeviceHandle | Handle to the lrf port which as been openned by kb_lrf_openComPort or kb_lrf_init |
Definition at line 761 of file kb_lrf.c.
References kb_lrf_DistanceData, LRF_DATA_NB, urg_captureByMD(), and urg_receiveData().
Referenced by kb_lrf_GetDistances_Averaged(), koa_lrf_task(), lrfmeasure(), and main().
int kb_lrf_GetDistances_Averaged | ( | int | LRF_DeviceHandle, | |
int | average | |||
) |
kb_lrf_GetDistances is a high level function that does whole mechanism certify the link, get some distances, averages then receive back the data from LRF,
LRF_DeviceHandle | Handle to the lrf port which as been openned by kb_lrf_openComPort or kb_lrf_init | |
average | number of acquisitions needed for averaging |
Definition at line 797 of file kb_lrf.c.
References kb_lrf_DistanceData, kb_lrf_DistanceDataSum, kb_lrf_DistanceGoodCounter, kb_lrf_GetDistances(), and LRF_DATA_NB.
Referenced by lrfmeasure().
int kb_lrf_Init | ( | char * | LRF_DeviceName | ) |
kb_lrf_Init does openning port, turn power on the LRF then certify the link,
LRF_DeviceName | String name of the serial port device where the laser is connected |
Definition at line 701 of file kb_lrf.c.
References BAUDRATE, ErrorMessage, HComm, KB_ERROR, KB_ERROR_OPENLRF, kb_lrf_Laser_On(), and urg_connect().
Referenced by koa_lrf_task(), lrfinit(), and main().
void kb_lrf_Laser_Off | ( | int | LRF_DeviceHandle | ) |
kb_lrf_Laser_Off : set LRF laser beam OFF
Definition at line 652 of file kb_lrf.c.
References Timeout, and urg_sendMessage().
Referenced by kb_lrf_Close(), laseroff(), and poweroff().
void kb_lrf_Laser_On | ( | int | LRF_DeviceHandle | ) |
kb_lrf_Laser_On : set LRF laser beam ON
Definition at line 639 of file kb_lrf.c.
References Timeout, and urg_sendMessage().
Referenced by kb_lrf_Init(), and laseron().
void kb_lrf_Power_Off | ( | void | ) |
kb_lrf_Power_Off : power off the LRF battery supply module
Definition at line 682 of file kb_lrf.c.
References GPIO_POWER, kb_gpio_cleanup(), kb_gpio_clear(), kb_gpio_dir(), kb_gpio_function(), and kb_gpio_init().
Referenced by poweroff().
void kb_lrf_Power_On | ( | void | ) |
kb_lrf_Power_On : power on the LRF battery supply module
Definition at line 665 of file kb_lrf.c.
References GPIO_POWER, kb_gpio_cleanup(), kb_gpio_dir(), kb_gpio_function(), kb_gpio_init(), and kb_gpio_set().
Referenced by main(), and poweron().
static int urg_addRecvData | ( | const char | buffer[], | |
long | data[], | |||
int * | filled | |||
) | [static] |
Receive and decode URG distance data
buffer | buffer | |
data | array of long containing the measurement values | |
filled | ? |
Definition at line 509 of file kb_lrf.c.
References urg_decode().
Referenced by urg_receiveData().
static int urg_captureByGD | ( | const urg_state_t * | state | ) | [static] |
Data read using GD-Command : read lastest measurement; sensor should be switched on before.
state | parameters of the current LRF laser |
Definition at line 453 of file kb_lrf.c.
References urg_state_t::first, urg_state_t::last, LineLength, and urg_sendTag().
static int urg_captureByMD | ( | const urg_state_t * | state, | |
int | capture_times | |||
) | [static] |
Data read using MD-Command: captures number of scans defined by capture_times (0 = infinite) Laser is switched on and off automatically.
state | parameters of the current LRF laser | |
capture_times | number of times scans should be captured |
Definition at line 471 of file kb_lrf.c.
References urg_state_t::first, urg_state_t::last, LineLength, and urg_sendTag().
Referenced by kb_lrf_GetDistances().
static int urg_connect | ( | urg_state_t * | state, | |
const char * | port, | |||
const long | baudrate | |||
) | [static] |
Process to connect with URG
state | parameters of the current LRF laser | |
port | serial port device | |
baudrate | baudrate |
Definition at line 394 of file kb_lrf.c.
References com_connect(), ErrorMessage, HComm, urg_state_t::last_timestamp, Timeout, urg_getParameters(), and urg_sendMessage().
Referenced by kb_lrf_Init().
static long urg_decode | ( | const char * | data, | |
int | data_byte | |||
) | [static] |
Decode 6 bit data from URG
data | data | |
data_byte | size of data |
Definition at line 489 of file kb_lrf.c.
Referenced by urg_addRecvData(), and urg_receiveData().
static int urg_getParameters | ( | urg_state_t * | state | ) | [static] |
Read URG parameters
state | parameters of the current LRF laser |
Definition at line 320 of file kb_lrf.c.
References urg_state_t::area_front, urg_state_t::area_max, urg_state_t::area_min, urg_state_t::area_total, urg_state_t::distance_max, urg_state_t::distance_min, urg_state_t::first, urg_state_t::last, LineLength, urg_state_t::max_size, urg_state_t::model, urg_state_t::scan_rpm, urg_readLine(), and urg_sendTag().
Referenced by urg_connect().
static int urg_readLine | ( | char * | buffer | ) | [static] |
Definition at line 248 of file kb_lrf.c.
Referenced by urg_getParameters(), and urg_receiveData().
static int urg_receiveData | ( | urg_state_t * | state, | |
long | data[], | |||
size_t | max_size | |||
) | [static] |
Receive URG data
state | state variable of the parameters of the laser | |
data | array of long containing the measurement values | |
max_size | maximum size of the array (can be determinated by urg_state.max_size ) |
Definition at line 550 of file kb_lrf.c.
References urg_state_t::last_timestamp, LineLength, urg_addRecvData(), urg_decode(), and urg_readLine().
Referenced by kb_lrf_GetDistances().
static int urg_sendMessage | ( | const char * | command, | |
int | timeout, | |||
int * | recv_n | |||
) | [static] |
Send data (Commands) to URG and wait for reply
command | command to be sent | |
timeout | for waiting the data back (ack) | |
recv_n | number of bytes received |
Definition at line 282 of file kb_lrf.c.
References com_recv(), LineLength, and urg_sendTag().
Referenced by kb_lrf_Laser_Off(), kb_lrf_Laser_On(), and urg_connect().
static int urg_sendTag | ( | const char * | tag | ) | [static] |
Send data(Commands) to URG
tag | command to be sent |
Definition at line 230 of file kb_lrf.c.
References com_send(), and LineLength.
Referenced by urg_captureByGD(), urg_captureByMD(), urg_getParameters(), and urg_sendMessage().
char* ErrorMessage = "no error." [static] |
Definition at line 42 of file kb_lrf.c.
Referenced by kb_lrf_Init(), and urg_connect().
int HComm = -1 [static] |
Definition at line 40 of file kb_lrf.c.
Referenced by com_connect(), com_recv(), com_send(), kb_lrf_Init(), and urg_connect().
long kb_lrf_DistanceData[LRF_DATA_NB] |
Definition at line 78 of file kb_lrf.c.
Referenced by kb_lrf_GetDistances(), kb_lrf_GetDistances_Averaged(), koa_lrf_task(), lrfmeasure(), and main().
long kb_lrf_DistanceDataSensor[LRF_DATA_NB] |
long kb_lrf_DistanceDataSum[LRF_DATA_NB] |
Definition at line 81 of file kb_lrf.c.
Referenced by kb_lrf_GetDistances_Averaged().
int kb_lrf_DistanceGoodCounter[LRF_DATA_NB] |
Definition at line 82 of file kb_lrf.c.
Referenced by kb_lrf_GetDistances_Averaged().