From: Jérémie D. <Ba...@us...> - 2011-03-29 19:07:13
|
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 0db0f51619bea9184177ca44eda4366ae6d22488 (commit) from 5d598864322684bb871d17034c47b16e123dd56b (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 0db0f51619bea9184177ca44eda4366ae6d22488 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 21:06:16 2011 +0200 [krobot_simulator] Only use angles between -pi and pi. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index d0da734..806c364 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -14,6 +14,18 @@ open Lwt_react open Krobot_config open Krobot_message +let pi = 4. *. atan 1. + +let math_mod_float a b = + let b2 = b /. 2. in + let modf = mod_float a b in + if modf > b2 then + modf -. b + else if modf < -. b2 then + modf +. b + else + modf;; + (* +-----------------------------------------------------------------+ | Types | +-----------------------------------------------------------------+ *) @@ -233,7 +245,7 @@ lwt () = sim.state <- { x = sim.state.x +. dx *. sim_step; y = sim.state.y +. dy *. sim_step; - theta = sim.state.theta +. dtheta *. sim_step; + theta = math_mod_float (sim.state.theta +. dtheta *. sim_step) (2. *. pi); }; sim.internal_state <- { theta_l = sim.internal_state.theta_l +. sim_step *. (u1 *. 4. +. u2 *. wheels_distance) /. (2. *. wheels_diameter); hooks/post-receive -- krobot |