From: Jérémie D. <Ba...@us...> - 2011-05-27 17:05:27
|
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 ac58fcf9777f7ccd645c408224c34dc2c5f3ce85 (commit) from c5fbd9bd2e6001ab07cbe63de4a8859f91ed75c8 (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 ac58fcf9777f7ccd645c408224c34dc2c5f3ce85 Author: Jérémie Dimino <je...@di...> Date: Fri May 27 19:04:35 2011 +0200 [krobot_planner] better path finding ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_planner.ml b/info/control2011/src/tools/krobot_planner.ml index d6d1796..f980c86 100644 --- a/info/control2011/src/tools/krobot_planner.ml +++ b/info/control2011/src/tools/krobot_planner.ml @@ -98,7 +98,11 @@ module Dijkstra = let sqr x = x *. x -let dist = object_radius +. robot_size /. 2. +(* Distance from borders to the robot. *) +let border_safety_distance = sqrt (sqr robot_size /. 2.) +. 0.05 + +(* Minimum distance from the center of objects to the center robot. *) +let object_safety_distance = object_radius +. robot_size /. 2. (* Test whether there is an intersection between the line (va, vb) and one of the objects. *) @@ -110,7 +114,7 @@ let rec intersection va vb objects = (* Compute coefficients of the polynomial. *) let a = sqr (distance va vb) and b = -2. *. prod (vector va vc) (vector va vb) - and c = sqr (distance va vc) -. sqr dist in + and c = sqr (distance va vc) -. sqr object_safety_distance in let delta = sqr b -. 4. *. a *. c in if delta < 0. then intersection va vb rest @@ -124,15 +128,29 @@ let rec intersection va vb objects = let find_path planner src dst = (* Build bounding boxes. *) - let r = object_radius +. robot_size in + let r1 = object_radius +. robot_size in + let r2 = object_radius +. robot_size *. 3. /. 4. in let vertices = List.fold_left (fun set obj -> - Vertice_set.add { x = obj.x; y = obj.y -. r } - (Vertice_set.add { x = obj.x +. r; y = obj.y } - (Vertice_set.add { x = obj.x; y = obj.y +. r } - (Vertice_set.add { x = obj.x -. r; y = obj.y } - set)))) + let add x y set = + if (x >= border_safety_distance + && x <= world_width -. border_safety_distance + && y >= border_safety_distance + && y <= world_height -. border_safety_distance) then + Vertice_set.add { x; y } set + else + set + in + let set = add obj.x (obj.y -. r1) set in + let set = add (obj.x +. r1) obj.y set in + let set = add obj.x (obj.y +. r1) set in + let set = add (obj.x -. r1) obj.y set in + let set = add obj.x (obj.y -. r2) set in + let set = add (obj.x +. r2) obj.y set in + let set = add obj.x (obj.y +. r2) set in + let set = add (obj.x -. r2) obj.y set in + set) Vertice_set.empty planner.objects in (* Add the source and the destination. *) hooks/post-receive -- krobot |