pub struct OccupancyGrid { /* private fields */ }Expand description
A fixed-size log-odds occupancy grid over an axis-aligned world rectangle.
Implementations§
Source§impl OccupancyGrid
impl OccupancyGrid
Sourcepub fn new(
min: Vector2<f64>,
max: Vector2<f64>,
config: OccupancyConfig,
) -> Self
pub fn new( min: Vector2<f64>, max: Vector2<f64>, config: OccupancyConfig, ) -> Self
Creates an all-unknown grid covering [min, max] (world, meters).
Sourcepub fn from_scans<'a>(
scans: impl IntoIterator<Item = (Pose2D, &'a [Vector2<f64>])> + Clone,
margin: f64,
config: OccupancyConfig,
) -> Self
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.
Sourcepub fn resolution(&self) -> f64
pub fn resolution(&self) -> f64
Cell edge [m].
Sourcepub fn origin(&self) -> Vector2<f64>
pub fn origin(&self) -> Vector2<f64>
World position of the grid corner (cell (0, 0)’s lower-left corner).
Sourcepub fn cell_of(&self, point: Vector2<f64>) -> Option<(usize, usize)>
pub fn cell_of(&self, point: Vector2<f64>) -> Option<(usize, usize)>
Cell containing point, if inside the grid.
Sourcepub fn log_odds(&self, x: usize, y: usize) -> f32
pub fn log_odds(&self, x: usize, y: usize) -> f32
Log-odds of cell (x, y) being occupied (0 = unknown).
Sourcepub fn state_at(&self, point: Vector2<f64>) -> CellState
pub fn state_at(&self, point: Vector2<f64>) -> CellState
State of the cell containing point (Unknown outside the grid).
Sourcepub fn insert_scan(&mut self, pose: Pose2D, scan_body: &[Vector2<f64>])
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.
Sourcepub fn insert_scan_with_trace(
&mut self,
pose: Pose2D,
scan_body: &[Vector2<f64>],
) -> Vec<OccupancyCellUpdate>
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.
Sourcepub fn insert_ranges(&mut self, pose: Pose2D, ranges: &[f64], max_range: f64)
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).
Sourcepub fn distance_field(&self, max_distance: f64) -> Vec<f32>
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
impl Clone for OccupancyGrid
Auto Trait Implementations§
impl Freeze for OccupancyGrid
impl RefUnwindSafe for OccupancyGrid
impl Send for OccupancyGrid
impl Sync for OccupancyGrid
impl Unpin for OccupancyGrid
impl UnsafeUnpin for OccupancyGrid
impl UnwindSafe for OccupancyGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.