Struct GraphSearch

Source
pub struct GraphSearch {
    pub path_: Vec<State>,
    pub turnings: Vec<(i32, i32, i32)>,
    pub fmap_: Option<HashSet<(i32, i32, i32)>>,
    pub omap_: HashSet<(i32, i32, i32)>,
    pub xbound: [i32; 2],
    pub ybound: [i32; 2],
    pub zbound: [i32; 2],
    pub goal: (i32, i32, i32),
    pub use_jps_: bool,
    /* private fields */
}
Expand description

GraphSearch is the struct type for path finding.

pq_ : a Priorty Queue for saving possible nodes.

hm_ : a HashMap for saving nodes that have been visited.

path_: the path in the forward order, i.e. from start to goal.

turnings : the turning points along the path in the forward order, including start and goal. turnings can be differenced for constructing lines, e.g. line[k] := (turnings[k], turnings[k+1])

ns_ : all neighbors in terms of relative position.

jn3d_: all jps neighbors.

fmap_: HashSet containing all free grids.

omap : HashSet containing all occupied grids.

Fields§

§path_: Vec<State>

the path in the forward order, i.e. from start to goal.

§turnings: Vec<(i32, i32, i32)>

the turning points along the path in the forward order, including start and goal.

turnings can be differenced for constructing lines, e.g. line[k] := (turnings[k], turnings[k+1])

§fmap_: Option<HashSet<(i32, i32, i32)>>

free map. if it’s None, a grid will be free as long as it is within the box defined by xdim × ydim × zdim.

otherwise, when it’s Some, the check for being contained in the free map is additionally needed to check whether a grid is free.

§omap_: HashSet<(i32, i32, i32)>

occupied map

§xbound: [i32; 2]

x-, y-, z- dimensions

§ybound: [i32; 2]§zbound: [i32; 2]§goal: (i32, i32, i32)

goal

§use_jps_: bool

use_jps

Implementations§

Source§

impl GraphSearch

Source

pub fn new_v1( fmap_: Option<HashSet<(i32, i32, i32)>>, omap_: HashSet<(i32, i32, i32)>, xbound: [i32; 2], ybound: [i32; 2], zbound: [i32; 2], eps_: f32, ) -> Self

create a GraphSearch instance, with maps given in terms of HashMap.

fmap_ : free map, containing all coordinates of free grids.

omap_ : occupied map, containing all coordinates of occupied grids.

xdim : upper boundary on x-axis.

ydim : upper boundary on y-axis.

zdim : upper boundary on z-axis.

eps_ : a scalar in calculating the costs.

Source

pub fn new_v2( map: &[bool], xbound: [i32; 2], ybound: [i32; 2], zbound: [i32; 2], eps_: f32, ) -> Self

create a GraphSearch instance, with the map given in terms of binary-valued array.

map : the map that is reshaped into 1d array, true means occupied, false means free.

xdim : upper boundary on x-axis.

ydim : upper boundary on y-axis.

zdim : upper boundary on z-axis.

eps_ : a scalar in calculating the costs.

Source§

impl GraphSearch

Source

pub fn plan( &mut self, start: (i32, i32, i32), goal: (i32, i32, i32), usejps: bool, max_expand: i32, ) -> bool

the main entry for planning.

start : starting grid

goal : goal grid

usejps: true for using jps, false for using A*

max_expand : max number of the depth in searching.

Trait Implementations§

Source§

impl Debug for GraphSearch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GraphSearch

Source§

fn default() -> GraphSearch

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.