X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fsensorboard%2Fcommands_scan.c;fp=projects%2Fmicrob2010%2Fsensorboard%2Fcommands_scan.c;h=0000000000000000000000000000000000000000;hp=e252298dc870793bf427f26cc2607a91ac09e4c8;hb=8d6a47e9e21a9a31f4bc12d32fb3d11091a4b305;hpb=821f753c0f88aff895d9feae59c442a6c446f96b diff --git a/projects/microb2010/sensorboard/commands_scan.c b/projects/microb2010/sensorboard/commands_scan.c deleted file mode 100644 index e252298..0000000 --- a/projects/microb2010/sensorboard/commands_scan.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright Droids Corporation (2009) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Revision : $Id: commands_scan.c,v 1.1 2009-05-27 20:04:07 zer0 Exp $ - * - * Olivier MATZ - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include "main.h" -#include "cmdline.h" -#include "../common/i2c_commands.h" -#include "i2c_protocol.h" -#include "actuator.h" - -#include -#include -#include - -#include "img_processing.h" -#include "scanner.h" - - - -/**********************************************************/ -/* sample ADC */ -/* -extern uint16_t sample_i; -extern float scan_offset_a; -extern float scan_offset_b; -*/ -extern struct scan_params scan_params; - -//extern uint16_t sample_tab[MAX_SAMPLE]; -/* this structure is filled when cmd_sample is parsed successfully */ -struct cmd_sample_result { - fixed_string_t arg0; - fixed_string_t arg1; - uint16_t offset_b; - float offset_a; - uint16_t dump_speed; - uint8_t filter; -}; - -extern int32_t pos_start_scan; -/* function called when cmd_sample is parsed successfully */ - -#define MAX_OBJECTS 10 -Object_bb sac_obj[MAX_OBJECTS]; -static void cmd_sample_parsed(void * parsed_result, void * data) -{ - struct cmd_sample_result * res = parsed_result; - uint16_t i; - - printf_P(PSTR("cmd sample called\r\n")); - printf_P(PSTR("arg %s %d\r\n"), res->arg1, res->offset_b); - - quadramp_set_1st_order_vars(&sensorboard.scanner.qr, res->dump_speed, res->dump_speed); /* set speed */ - - - scan_params.offset_b = (((float)res->offset_b)*M_PI/180.); - scan_params.offset_a = (((float)res->offset_a)*M_PI/180.); - scan_params.filter = res->filter; - - if (!strcmp_P(res->arg1, PSTR("start"))) { - scan_params.sample_i = MAX_SAMPLE; - scan_params.pos_start_scan = encoders_spi_get_value_scanner(SCANNER_ENC); - //printf_P(PSTR("start scan at pos %ld\r\n"), scan_params.pos_start_scan); - - memset(scan_params.sample_tab, 0xff, MAX_SAMPLE*sizeof(uint8_t)); - - - cs_set_consign(&sensorboard.scanner.cs, scan_params.pos_start_scan+SCANNER_STEP_TOUR*200L); - //printf_P(PSTR("scan dst %ld\r\n"), scan_params.pos_start_scan+SCANNER_STEP_TOUR*200L); - - scan_params.last_col_n = 0; - scan_params.last_row_n = 0; - scan_params.last_sample = 0; - - } - else if (!strcmp_P(res->arg1, PSTR("dump"))) { - printf_P(PSTR("start object detection\r\n")); - for (i=0;ispeed; - scan_params.debug = res->debug; - -} - -prog_char str_scan_params_arg0[] = "scan_params"; -parse_pgm_token_string_t cmd_scan_params_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_scan_params_result, arg0, str_scan_params_arg0); -parse_pgm_token_num_t cmd_scan_params_arg1 = TOKEN_NUM_INITIALIZER(struct cmd_scan_params_result, speed, INT16); -parse_pgm_token_num_t cmd_scan_params_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_scan_params_result, debug, UINT8); - -prog_char help_scan_params[] = "Set scanner params (speed, debug)"; -parse_pgm_inst_t cmd_scan_params = { - .f = cmd_scan_params_parsed, /* function to call */ - .data = NULL, /* 2nd arg of func */ - .help_str = help_sample, - .tokens = { /* token list, NULL terminated */ - (prog_void *)&cmd_scan_params_arg0, - (prog_void *)&cmd_scan_params_arg1, - (prog_void *)&cmd_scan_params_arg2, - NULL, - }, -}; - - - -/**********************************************************/ -/* set scanner calibration */ - -/* this structure is filled when cmd_scan_calibre is parsed successfully */ -struct cmd_scan_calibre_result { - fixed_string_t arg0; - fixed_string_t arg1; -}; - -/* function called when cmd_scan_calibre is parsed successfully */ -static void cmd_scan_calibre_parsed(void * parsed_result, void * data) -{ - struct cmd_scan_calibre_result * res = parsed_result; - - printf_P(PSTR("Starting scanner autocalibration\r\n")); - - - if (!strcmp_P(res->arg1, PSTR("mirror"))) { - scanner_calibre_mirror(); - } - else{ - scanner_calibre_laser(); - } -} - -prog_char str_scan_calibre_arg0[] = "scan_calibre"; - -prog_char str_scan_calibre_what_arg1[] = "mirror#laser"; -parse_pgm_token_string_t cmd_scan_calibre_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_scan_calibre_result, arg0, str_scan_calibre_arg0); -parse_pgm_token_string_t cmd_scan_calibre_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_scan_calibre_result, arg1, str_scan_calibre_what_arg1); - - -prog_char help_scan_calibre[] = "Scanner auto calibration (mirror|laser)"; -parse_pgm_inst_t cmd_scan_calibre = { - .f = cmd_scan_calibre_parsed, /* function to call */ - .data = NULL, /* 2nd arg of func */ - .help_str = help_scan_calibre, - .tokens = { /* token list, NULL terminated */ - (prog_void *)&cmd_scan_calibre_arg0, - (prog_void *)&cmd_scan_calibre_arg1, - NULL, - }, -}; - - - -/**********************************************************/ -/* start scan */ - -/* this structure is filled when cmd_scan_do is parsed successfully */ -struct cmd_scan_do_result { - fixed_string_t arg0; -}; - -/* function called when cmd_scan_do is parsed successfully */ -static void cmd_scan_do_parsed(void * parsed_result, void * data) -{ - printf_P(PSTR("Starting scan\r\n")); - scanner_scan_autonomous(); -} - -prog_char str_scan_do_arg0[] = "scan_do"; -parse_pgm_token_string_t cmd_scan_do_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_scan_do_result, arg0, str_scan_do_arg0); - -prog_char help_scan_do[] = "Scan zone"; -parse_pgm_inst_t cmd_scan_do = { - .f = cmd_scan_do_parsed, /* function to call */ - .data = NULL, /* 2nd arg of func */ - .help_str = help_scan_do, - .tokens = { /* token list, NULL terminated */ - (prog_void *)&cmd_scan_do_arg0, - NULL, - }, -}; - - - - -/**********************************************************/ -/* set scanner img params */ - -/* this structure is filled when cmd_scan_img is parsed successfully */ -struct cmd_scan_img_result { - fixed_string_t arg0; - uint8_t algo; - uint8_t h; - int16_t x; - int16_t y; - -}; - -/* function called when cmd_scan_img is parsed successfully */ -static void cmd_scan_img_parsed(void * parsed_result, void * data) -{ - struct cmd_scan_img_result * res = parsed_result; - - scan_params.algo = res->algo; - if (res->algo == I2C_SCANNER_ALGO_COLUMN_DROPZONE) { - scan_params.drop_zone.working_zone = res->h; - scan_params.drop_zone.center_x = res->x; - scan_params.drop_zone.center_y = res->y; - } else if (res->algo == I2C_SCANNER_ALGO_CHECK_TEMPLE) { - scan_params.check_temple.level = res->h; - scan_params.check_temple.temple_x = res->x; - scan_params.check_temple.temple_y = res->y; - } else if (res->algo == I2C_SCANNER_ALGO_TEMPLE_DROPZONE) { - scan_params.drop_zone.working_zone = res->h; - scan_params.drop_zone.center_x = res->x; - scan_params.drop_zone.center_y = res->y; - } - - - -} - -prog_char str_scan_img_arg0[] = "scan_img"; -parse_pgm_token_string_t cmd_scan_img_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_scan_img_result, arg0, str_scan_img_arg0); -parse_pgm_token_num_t cmd_scan_img_arg1 = TOKEN_NUM_INITIALIZER(struct cmd_scan_img_result, algo, UINT8); -parse_pgm_token_num_t cmd_scan_img_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_scan_img_result, h, UINT8); -parse_pgm_token_num_t cmd_scan_img_arg3 = TOKEN_NUM_INITIALIZER(struct cmd_scan_img_result, x, INT16); -parse_pgm_token_num_t cmd_scan_img_arg4 = TOKEN_NUM_INITIALIZER(struct cmd_scan_img_result, y, INT16); - - -prog_char help_scan_img[] = "Set scanner img processing params (algo, H, x, y)"; -parse_pgm_inst_t cmd_scan_img = { - .f = cmd_scan_img_parsed, /* function to call */ - .data = NULL, /* 2nd arg of func */ - .help_str = help_scan_img, - .tokens = { /* token list, NULL terminated */ - (prog_void *)&cmd_scan_img_arg0, - (prog_void *)&cmd_scan_img_arg1, - (prog_void *)&cmd_scan_img_arg2, - (prog_void *)&cmd_scan_img_arg3, - (prog_void *)&cmd_scan_img_arg4, - NULL, - }, -}; - -