From: Xavier L. <Ba...@us...> - 2011-03-31 13:47:49
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via a51709e923cc4020fdae14ea2ab455f132fc7c45 (commit) from 3d188dae29a66f3d1e491bd210699469799dfd2f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a51709e923cc4020fdae14ea2ab455f132fc7c45 Author: Xavier Lagorce <Xav...@cr...> Date: Thu Mar 31 15:46:53 2011 +0200 [Controller_Motor_STM32] Added a tc_goto_speed function This function provides a simple way to change the speed with a given acceleration. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c index 6186796..a74dd55 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c @@ -124,6 +124,7 @@ void acc_stop_callback(command_generator_t *generator) { // Stopping acceleration adjust_speed(&cont->speed, 0.); + adjust_value(&cont->speed, cont->aut.speed); cont->working = 0; } @@ -254,6 +255,28 @@ void tc_goto(uint8_t motor, float angle, float speed, float acceleration) { cont->working = 1; } +void tc_goto_speed(uint8_t motor, float speed, float acceleration) { + trajectory_controller_t *cont; + + // Verify parameters + if (acceleration <= 0) + return; + + // Get the controller and verifies it is enabled + cont = &controllers[get_motor_index(motor)]; + if (!cont->enabled) + return; + + cont->aut.speed = speed; + cont->aut.dir = SIGN(speed - cont->speed.type.last_output); + // Set acceleration sign depending on the current speed + cont->aut.acceleration = cont->aut.dir * acceleration; + adjust_speed(&cont->speed, cont->aut.acceleration); + add_callback(&cont->speed, SELECT_THRESHOLD(cont->aut.dir), cont->aut.speed, acc_stop_callback); + + cont->working = 1; +} + void tc_move(tc_robot_t *robot, float distance, float speed, float acceleration) { float dis_s, spe_s, acc_s; diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h index 77b73e9..8c1eef6 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h @@ -64,6 +64,11 @@ uint8_t tc_is_working(uint8_t motors); */ void tc_goto(uint8_t motor, float angle, float speed, float acceleration); +/* Accelerates or brakes the robot to the given speed + * + */ +void tc_goto_speed(uint8_t motor, float speed, float acceleration); + /* Moves along a line * - robot : pointer to a structure describing the robot configuration * - distance : distance to move of (in meters), can be positive (forward) hooks/post-receive -- krobot |