From: Pierre C. <Ba...@us...> - 2013-04-24 23:43:30
|
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 4ea1cf29d38266053fb64d3a0279213d3f6e02d3 (commit) from 7e53c27bb7cc49869dcc77be44a3197065722367 (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 4ea1cf29d38266053fb64d3a0279213d3f6e02d3 Author: Pierre Chambart <pie...@oc...> Date: Thu Apr 25 01:42:07 2013 +0200 Better robot radius handling in pathfinder ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_config.ml b/info/control2011/src/lib/krobot_config.ml index 127b63e..be24feb 100644 --- a/info/control2011/src/lib/krobot_config.ml +++ b/info/control2011/src/lib/krobot_config.ml @@ -11,16 +11,20 @@ let sqr x = x *. x let world_height = 2. let world_width = 3. -let robot_length = 0.39 +let robot_length = 0.22 let robot_width = 0.33 let wheels_diameter = 0.098 let wheels_distance = 0.224 let wheels_position = 0.04 +let robot_radius = + let l1 = robot_length -. wheels_position in + let l2 = robot_width /. 2. in + sqrt (l1 *. l1 +. l2 *. l2) let rotary_beacon_index_pos = 0. let safety_margin = 0.01 -let beacon_radius = 0.4 +let beacon_radius = 0.2 let coin_radius = 0.06 diff --git a/info/control2011/src/lib/krobot_config.mli b/info/control2011/src/lib/krobot_config.mli index 159f59f..1f88fa2 100644 --- a/info/control2011/src/lib/krobot_config.mli +++ b/info/control2011/src/lib/krobot_config.mli @@ -32,6 +32,9 @@ val wheels_position : float (** The distance between the axe of the wheels and the back of the robot. *) +val robot_radius : float + (** distance between the point between the wheel and the farthest point *) + val rotary_beacon_index_pos : float (** The angle of the rotary beacon index angle with respect to the robot's front *) diff --git a/info/control2011/src/lib/krobot_path.ml b/info/control2011/src/lib/krobot_path.ml index 679581a..49b2311 100644 --- a/info/control2011/src/lib/krobot_path.ml +++ b/info/control2011/src/lib/krobot_path.ml @@ -21,12 +21,12 @@ let rec prev_last = function let find ~src ~dst ~beacon = let fixed_objects = List.map (fun { pos; size } -> pos, - size +. Krobot_config.robot_width /. 2. +. 0.01) + size +. Krobot_config.robot_radius +. 0.01) Krobot_config.fixed_obstacles in (* do that in a better way when we have time... *) let init_coins = List.map (fun pos -> pos, - Krobot_config.coin_radius +. Krobot_config.robot_width /. 2. +. 0.01) + Krobot_config.coin_radius +. Krobot_config.robot_radius +. 0.01) Krobot_config.initial_coins in let l = fixed_objects @ init_coins in @@ -35,22 +35,23 @@ let find ~src ~dst ~beacon = | (Some v, None) | (None, Some v) -> ignore (Lwt_log.info_f "One beacon %f %f" v.x v.y); - (v, beacon_radius +. safety_margin) :: l + (v, beacon_radius +. safety_margin +. Krobot_config.robot_radius) :: l | (Some v1, Some v2) -> ignore (Lwt_log.info_f "Two beacons (%f,%f) (%f,%f)" v1.x v1.y v2.x v2.y); - (v1, beacon_radius +. safety_margin) - :: (v2, beacon_radius +. safety_margin) + (v1, beacon_radius +. safety_margin +. Krobot_config.robot_radius) + :: (v2, beacon_radius +. safety_margin +. Krobot_config.robot_radius) :: l | (None, None) -> ignore (Lwt_log.info_f "no beacon"); l in let l = List.map (fun (v,s) -> (v, min s (distance v src -. 0.1))) l in + let min_distance = Krobot_config.robot_radius +. safety_margin in Krobot_pathfinding.find_path ~src ~dst - ({ x = safety_margin; - y = safety_margin}, - { x = world_width -. safety_margin; - y = world_height -. safety_margin}) + ({ x = min_distance; + y = min_distance}, + { x = world_width -. min_distance; + y = world_height -. min_distance}) l (* let goto_object ~src ~dst ~beacon = diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 81c0ef4..900d9b3 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -287,6 +287,13 @@ let draw viewer = Krobot_config.fixed_obstacles in + (* Draw the robot bounding circle *) + + Cairo.arc ctx viewer.state.pos.x viewer.state.pos.y + Krobot_config.robot_radius 0. (2. *. pi); + Cairo.set_source_rgba ctx 1. 1. 1. 0.5; + Cairo.fill ctx; + (* Draw the robot and the ghost *) List.iter (fun (state, (r,g,b,alpha)) -> hooks/post-receive -- krobot |