From da78eed17f4ca0950f4b5a8cd6686c93ade2f899 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Sun, 20 Apr 2008 16:07:10 +0200 Subject: * digital/io/src - add the goto an absolute position and goto an absolute angle commands to the asserv module. --- digital/io/src/asserv.c | 22 ++++++++++++++-------- digital/io/src/asserv.h | 9 ++++----- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'digital') diff --git a/digital/io/src/asserv.c b/digital/io/src/asserv.c index eaa14f6f..4f132f3d 100644 --- a/digital/io/src/asserv.c +++ b/digital/io/src/asserv.c @@ -355,14 +355,15 @@ asserv_move_angularly (int16_t angle) asserv_twi_send_command ('a', 2); } -/* Move the bot to a specific angle. */ +/* Make the bot turn of an absolute angle. */ void asserv_goto_angle (int16_t angle) { /* Put angle as parameter */ asserv_twi_buffer_param[0] = v16_to_v8 (angle, 1); asserv_twi_buffer_param[1] = v16_to_v8 (angle, 0); - /* TODO */ + /* Sent the got to an absolute angle command to the asserv board */ + asserv_twi_send_command ('y', 2); } /* Go to the wall (moving backward). */ @@ -469,15 +470,20 @@ asserv_set_speed (uint8_t linear_high, uint8_t angular_high, asserv_twi_send_command ('p', 5); } -/** - * Go to the position provided in parameters. Those points shall be in the - * table. - * @param x the x position on the table. - * @param y the y position on the table. - */ +/* Go to an absolute position in (X, Y). */ void asserv_goto (uint32_t x, uint32_t y) { + /* Put X as parameter */ + asserv_twi_buffer_param[0] = v32_to_v8 (x, 2); + asserv_twi_buffer_param[1] = v32_to_v8 (x, 1); + asserv_twi_buffer_param[2] = v32_to_v8 (x, 0); + /* Put distance as parameter */ + asserv_twi_buffer_param[3] = v32_to_v8 (y, 2); + asserv_twi_buffer_param[4] = v32_to_v8 (y, 1); + asserv_twi_buffer_param[5] = v32_to_v8 (y, 0); + /* Send the got to an absolute position command to the asserv board */ + asserv_twi_send_command ('x', 6); } /* Notify get samples FSM when the arm reach desired position. */ diff --git a/digital/io/src/asserv.h b/digital/io/src/asserv.h index 1a5011fc..531fad09 100644 --- a/digital/io/src/asserv.h +++ b/digital/io/src/asserv.h @@ -177,7 +177,7 @@ void asserv_move_angularly (int16_t angle); /** - * Move the bot to a specific angle. + * Make the bot turn of an absolute angle. * The angle is absolute and not a difference with the current one. * @param a the absolute angle in degrees */ @@ -256,10 +256,9 @@ asserv_set_speed (uint8_t linear_high, uint8_t angular_high, uint8_t linear_low, uint8_t angular_low); /** - * Go to the position provided in parameters. Those points shall be in the - * table. - * @param x the x position on the table. - * @param y the y position on the table. + * Go to an absolute position in (X, Y). + * @param x the x position on the table. + * @param y the y position on the table. */ void asserv_goto (uint32_t x, uint32_t y); -- cgit v1.2.3