This module provides useful basic examples to interface with the LedRangeFinder library for korebot. More...
Go to the source code of this file.
Defines | |
#define | NB_COLUMNS_MAX 80.0 |
#define | NB_LINES_MAX 24.0 |
#define | DEFAULT_X_FACTOR (2.0*2000.0) |
#define | DEFAULT_Y_FACTOR (2.0*2000.0) |
#define | MAX_X_FACTOR (2.0*5600.0) |
#define | MAX_Y_FACTOR (2.0*5600.0) |
#define | MIN_X_FACTOR (2.0*500.0) |
#define | MIN_Y_FACTOR (2.0*500.0) |
#define | LRF_DEVICE "/dev/ttyACM0" |
#define | ZOOM_FACTOR 1.25 |
Functions | |
static void | ctrlc_handler (int sig) |
int | laseron (int argc, char *argv[], void *data) |
int | laseroff (int argc, char *argv[], void *data) |
int | poweron (int argc, char *argv[], void *data) |
int | poweroff (int argc, char *argv[], void *data) |
void | lrfheader () |
int | setfile (int argc, char *argv[], void *data) |
int | lrfinit (int argc, char *argv[], void *data) |
int | lrfmeasure (int argc, char *argv[], void *data) |
int | lrfmeasureaverage (int argc, char *argv[], void *data) |
int | quit (int argc, char *argv[], void *data) |
int | help (int argc, char *argv[], void *data) |
int | main (int argc, char *argv[]) |
Variables | |
static int | quitReq = 0 |
static int | lrfHandle = -1 |
static FILE * | outfile |
static char | filename [256] |
static float | x_factor = DEFAULT_X_FACTOR |
static float | y_factor = DEFAULT_Y_FACTOR |
static kb_command_t | cmds [] |
static char | buf [1024] |
This module provides useful basic examples to interface with the LedRangeFinder library for korebot.
simple led range finder test executable
Definition in file klrf_test.c.
#define DEFAULT_X_FACTOR (2.0*2000.0) |
Definition at line 34 of file klrf_test.c.
#define DEFAULT_Y_FACTOR (2.0*2000.0) |
Definition at line 35 of file klrf_test.c.
#define LRF_DEVICE "/dev/ttyACM0" |
Definition at line 41 of file klrf_test.c.
#define MAX_X_FACTOR (2.0*5600.0) |
Definition at line 36 of file klrf_test.c.
#define MAX_Y_FACTOR (2.0*5600.0) |
Definition at line 37 of file klrf_test.c.
#define MIN_X_FACTOR (2.0*500.0) |
Definition at line 38 of file klrf_test.c.
#define MIN_Y_FACTOR (2.0*500.0) |
Definition at line 39 of file klrf_test.c.
#define NB_COLUMNS_MAX 80.0 |
Definition at line 30 of file klrf_test.c.
#define NB_LINES_MAX 24.0 |
Definition at line 31 of file klrf_test.c.
#define ZOOM_FACTOR 1.25 |
Definition at line 47 of file klrf_test.c.
static void ctrlc_handler | ( | int | sig | ) | [static] |
Make sure the program terminate properly on a ctrl-c
sig | signal |
Definition at line 55 of file klrf_test.c.
References filename, kb_lrf_Close(), lrfHandle, outfile, and quitReq.
Referenced by main().
int help | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Display a list of available commands.
Definition at line 429 of file klrf_test.c.
References kb_command_s::name.
int laseroff | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set laser beam off
Definition at line 94 of file klrf_test.c.
References kb_lrf_Laser_Off(), and lrfHandle.
Referenced by lrfmeasure().
int laseron | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set laser beam on
Definition at line 78 of file klrf_test.c.
References kb_lrf_Laser_On(), and lrfHandle.
void lrfheader | ( | ) |
Set header of output file for saving lrf data
Definition at line 142 of file klrf_test.c.
References outfile.
Referenced by lrfmeasure().
int lrfinit | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Initialise lrf communication
Definition at line 186 of file klrf_test.c.
References kb_lrf_Init(), LRF_DEVICE, and lrfHandle.
int lrfmeasure | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Get measures from the lrf
Definition at line 196 of file klrf_test.c.
References DEFAULT_X_FACTOR, kb_change_term_mode(), kb_clrscr(), kb_erase_line(), kb_kbhit(), kb_lrf_DistanceData, kb_lrf_Get_Timestamp(), kb_lrf_GetDistances(), kb_lrf_GetDistances_Averaged(), kb_move_cursor(), laseroff(), LRF_DATA_NB, lrfHandle, lrfheader(), MAX_X_FACTOR, MAX_Y_FACTOR, MIN_X_FACTOR, MIN_Y_FACTOR, NB_COLUMNS_MAX, NB_LINES_MAX, outfile, stop(), x_factor, y_factor, and ZOOM_FACTOR.
Referenced by lrfmeasureaverage().
int lrfmeasureaverage | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Get measures from the lrf, averaged
Definition at line 388 of file klrf_test.c.
References lrfmeasure().
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 448 of file klrf_test.c.
References buf, ctrlc_handler(), filename, kb_clrscr(), kb_init(), kb_lrf_Close(), kb_parse_command(), kb_set_debug_level(), lrfHandle, outfile, and quitReq.
int poweroff | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set power supply off, close the laser communication
Definition at line 123 of file klrf_test.c.
References kb_lrf_Close(), kb_lrf_Laser_Off(), kb_lrf_Power_Off(), and lrfHandle.
int poweron | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Set power supply on
Definition at line 113 of file klrf_test.c.
References kb_lrf_Power_On().
int quit | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
int setfile | ( | int | argc, | |
char * | argv[], | |||
void * | data | |||
) |
Open output file for saving lrf data
Definition at line 158 of file klrf_test.c.
char buf[1024] [static] |
Main program to process the command line.
Definition at line 446 of file klrf_test.c.
Referenced by main().
kb_command_t cmds[] [static] |
{ { "quit" , 0 , 0 , quit } , { "exit" , 0 , 0 , quit } , { "bye" , 0 , 0 , quit } , { "setfile" , 1 , 1 , setfile }, { "lrfinit" , 0 , 0 , lrfinit }, { "laseron" , 0 , 0 , laseron }, { "laseroff" , 0 , 0 , laseroff }, { "poweron" , 0 , 0 , poweron }, { "poweroff" , 0 , 0 , poweroff }, { "lrfmeasure" , 1 , 2 , lrfmeasure }, { "help" , 0 , 0 , help } , { NULL , 0 , 0 , NULL } }
The command table contains: command name : min number of args : max number of args : the function to call
Definition at line 411 of file klrf_test.c.
char filename[256] [static] |
Definition at line 27 of file klrf_test.c.
Referenced by ctrlc_handler(), kb_config_init(), main(), and setfile().
int lrfHandle = -1 [static] |
Definition at line 22 of file klrf_test.c.
Referenced by ctrlc_handler(), laseroff(), laseron(), lrfinit(), lrfmeasure(), main(), and poweroff().
FILE* outfile [static] |
Definition at line 25 of file klrf_test.c.
Referenced by ctrlc_handler(), lrfheader(), lrfmeasure(), main(), and setfile().
int quitReq = 0 [static] |
Definition at line 21 of file klrf_test.c.
Referenced by ctrlc_handler(), main(), and quit().
float x_factor = DEFAULT_X_FACTOR [static] |
Definition at line 44 of file klrf_test.c.
Referenced by lrfmeasure().
float y_factor = DEFAULT_Y_FACTOR [static] |
Definition at line 45 of file klrf_test.c.
Referenced by lrfmeasure().