From: Xavier L. <Ba...@us...> - 2010-12-29 01:01:15
|
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 b26ac612d8276f4984ee60936f4ba2081497c3cd (commit) from b09fef0025a8f5221b555c937790bf4e43143399 (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 b26ac612d8276f4984ee60936f4ba2081497c3cd Author: Xavier Lagorce <Xav...@cr...> Date: Wed Dec 29 01:59:37 2010 +0100 Improved speed profile generation * Take into account the case of a triangle (not enough distance to accelerate to full speed) * Renamed t1 into t_acc for readability ----------------------------------------------------------------------- Changes: diff --git a/info/control/simulator/krobot_env.ml b/info/control/simulator/krobot_env.ml index 8d7a735..3c9bcdf 100644 --- a/info/control/simulator/krobot_env.ml +++ b/info/control/simulator/krobot_env.ml @@ -17,8 +17,8 @@ type state = { type command = | Speed of float * float * float * float (* start_time, end_time, left_velocity, right_velocity *) - | Turn of float * float * float * float (* start_time, t1, end_time, velocity *) - | Move of float * float * float * float (* start_time, t1, end_time, velocity *) + | Turn of float * float * float * float (* start_time, t_acc, end_time, velocity *) + | Move of float * float * float * float (* start_time, t_acc, end_time, velocity *) type color = | Black @@ -48,24 +48,24 @@ let velocities_of_command cmd time = (0., 0.) else ((l_v +. r_v) *. wheels_diam /. 4., (l_v -. r_v) *. wheels_diam /. wheels_dist) - | Turn (start, t1, tend, vel) -> + | Turn (start, t_acc, tend, vel) -> if time < start || time > tend then (0., 0.) - else if time < (start +. t1) then - (0., vel *. (time -. start) /. t1) - else if time < (tend -. t1) then + else if time < (start +. t_acc) then + (0., vel *. (time -. start) /. t_acc) + else if time < (tend -. t_acc) then (0., vel) else - (0., vel *. (tend -. time) /. t1) - | Move (start, t1, tend, vel) -> + (0., vel *. (tend -. time) /. t_acc) + | Move (start, t_acc, tend, vel) -> if time < start || time > tend then (0., 0.) - else if time < (start +. t1) then - (vel *. (time -. start) /. t1, 0.) - else if time < (tend -. t1) then + else if time < (start +. t_acc) then + (vel *. (time -. start) /. t_acc, 0.) + else if time < (tend -. t_acc) then (vel, 0.) else - (vel *. (tend -. time) /. t1, 0.) + (vel *. (tend -. time) /. t_acc, 0.) let rec simu_loop env = time := !time +. sim_step; @@ -90,14 +90,32 @@ let create state = env let move env distance velocity acceleration = - let t1 = velocity /. acceleration in + let t_acc = velocity /. acceleration in let t_end = (velocity *. velocity +. distance *. acceleration) /. (velocity *. acceleration) in - env.command <- Move (!time, t1, !time +. t_end, velocity) + env.command <- + if t_end > 2. *. t_acc + then + Move (!time, t_acc, !time +. t_end, velocity) + else begin + let t_acc = sqrt (distance /. acceleration) in + let t_end = 2. *. t_acc in + let velocity = acceleration *. t_acc in + Move (!time, t_acc, !time +. t_end, velocity) + end let turn env angle velocity acceleration = - let t1 = velocity /. acceleration in + let t_acc = velocity /. acceleration in let t_end = (velocity *. velocity +. angle *. acceleration) /. (velocity *. acceleration) in - env.command <- Turn (!time, t1, !time +. t_end, velocity) + env.command <- + if t_end > 2. *. t_acc + then + Turn (!time, t_acc, !time +. t_end, velocity) + else begin + let t_acc = sqrt (angle /. acceleration) in + let t_end = 2. *. t_acc in + let velocity = acceleration *. t_acc in + Turn (!time, t_acc, !time +. t_end, velocity) + end let set_velocities env left_velocity right_velocity duration = env.command <- Speed (!time, !time +. duration, left_velocity, right_velocity) hooks/post-receive -- krobot |