/// <summary> /// constructor /// </summary> /// <param name="navigable_space">2D binary array of navigable (probably vacant) space</param> /// <param name="cellSize_mm">size of each occupancy grid cell in millimetres</param> /// <param name="OccupancyGridCentre_x_mm">location of the centre of the occupancy grid in millimetres</param> /// <param name="OccupancyGridCentre_y_mm">location of the centre of the occupancy grid in millimetres</param> public pathplanner(bool[][] navigable_space, int cellSize_mm, float OccupancyGridCentre_x_mm, float OccupancyGridCentre_y_mm) { this.cellSize_mm = cellSize_mm; init(navigable_space, OccupancyGridCentre_x_mm, OccupancyGridCentre_y_mm); // for efficiency reasons the dimension of the navigable // safety grid must be a power of 2 int safe_dimension = 1; int i = 0; bool finished = false; while ((i < 100) && (!finished)) { int dimension = (int)Math.Pow(2, i); int diff = dimension - navigable_space.GetLength(0); if (diff >= 0) { safe_dimension = dimension; safety_offset = diff / 2; finished = true; } i++; } // create a safety array, to remain friendly navigable_safety = new Byte[safe_dimension][]; for (int j = 0; j < navigable_safety.Length; j++) { navigable_safety[j] = new Byte[safe_dimension]; } pathfinder = new AStar_PathFinderFast(navigable_safety); }
/// <summary> /// constructor /// </summary> /// <param name="navigable_space">2D binary array of navigable (probably vacant) space</param> /// <param name="cellSize_mm">size of each occupancy grid cell in millimetres</param> /// <param name="OccupancyGridCentre_x_mm">location of the centre of the occupancy grid in millimetres</param> /// <param name="OccupancyGridCentre_y_mm">location of the centre of the occupancy grid in millimetres</param> public pathplanner(bool[][] navigable_space, int cellSize_mm, float OccupancyGridCentre_x_mm, float OccupancyGridCentre_y_mm) { this.cellSize_mm = cellSize_mm; init(navigable_space, OccupancyGridCentre_x_mm, OccupancyGridCentre_y_mm); // for efficiency reasons the dimension of the navigable // safety grid must be a power of 2 int safe_dimension = 1; int i = 0; bool finished = false; while ((i < 100) && (!finished)) { int dimension = (int)Math.Pow(2, i); int diff = dimension - navigable_space.GetLength(0); if (diff >= 0) { safe_dimension = dimension; safety_offset = diff / 2; finished = true; } i++; } // create a safety array, to remain friendly navigable_safety = new Byte[safe_dimension][]; for (int j = 0; j < navigable_safety.Length; j++) navigable_safety[j] = new Byte[safe_dimension]; pathfinder = new AStar_PathFinderFast(navigable_safety); }