Skip to main content

OccupancyGrid

Struct OccupancyGrid 

Source
pub struct OccupancyGrid { /* private fields */ }
Expand description

A fixed-size log-odds occupancy grid over an axis-aligned world rectangle.

Implementations§

Source§

impl OccupancyGrid

Source

pub fn new( min: Vector2<f64>, max: Vector2<f64>, config: OccupancyConfig, ) -> Self

Creates an all-unknown grid covering [min, max] (world, meters).

Source

pub fn from_scans<'a>( scans: impl IntoIterator<Item = (Pose2D, &'a [Vector2<f64>])> + Clone, margin: f64, config: OccupancyConfig, ) -> Self

Builds a grid from body-frame scans taken at poses, sized to fit every pose and scan point plus margin meters.

Source

pub fn resolution(&self) -> f64

Cell edge [m].

Source

pub fn size(&self) -> (usize, usize)

(width, height) in cells.

Source

pub fn origin(&self) -> Vector2<f64>

World position of the grid corner (cell (0, 0)’s lower-left corner).

Source

pub fn cell_of(&self, point: Vector2<f64>) -> Option<(usize, usize)>

Cell containing point, if inside the grid.

Source

pub fn cell_center(&self, x: usize, y: usize) -> Vector2<f64>

World center of cell (x, y).

Source

pub fn log_odds(&self, x: usize, y: usize) -> f32

Log-odds of cell (x, y) being occupied (0 = unknown).

Source

pub fn state(&self, x: usize, y: usize) -> CellState

State of cell (x, y).

Source

pub fn state_at(&self, point: Vector2<f64>) -> CellState

State of the cell containing point (Unknown outside the grid).

Source

pub fn occupied_points(&self) -> Vec<Vector2<f64>> ⓘ

World centers of every occupied cell.

Source

pub fn insert_scan(&mut self, pose: Pose2D, scan_body: &[Vector2<f64>])

Integrates one body-frame scan taken at pose. Each cell is updated at most once per scan, and a hit wins over a miss, so a wall cell is not erased by neighboring beams that graze it.

Source

pub fn insert_scan_with_trace( &mut self, pose: Pose2D, scan_body: &[Vector2<f64>], ) -> Vec<OccupancyCellUpdate>

Integrates a sparse return scan and records the updates actually applied, including clamping. Missing observations produce no updates; use Self::insert_ranges for a full range scan with no-return beams.

Source

pub fn insert_ranges(&mut self, pose: Pose2D, ranges: &[f64], max_range: f64)

Integrates a full 360° range scan taken at pose (beam order of crate::scan_to_map::ray_cast_ranges). Beams without a return (non-finite or beyond max_range) still clear the cells out to max_range, so open space becomes known free instead of unknown (NaN beams are skipped entirely, e.g. ones that hit a moving object), and free-only sub-rays fill the angular gaps between beams so far cells are not left as unknown speckles (which would look like frontiers).

Source

pub fn distance_field(&self, max_distance: f64) -> Vec<f32>

Distance [m] from every cell center to the nearest occupied cell center (two-pass chamfer approximation, exact along axes and diagonals), capped at max_distance. Row-major, width × height.

Trait Implementations§

Source§

impl Clone for OccupancyGrid

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OccupancyGrid

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V