pub struct CuPlanningScene<const MAX_OBSTACLES: usize = DEFAULT_MAX_OBSTACLES, const MAX_ATTACHED: usize = DEFAULT_MAX_ATTACHED> { /* private fields */ }Expand description
Fixed-capacity, versioned planning scene storage (CuMsgPayload-compliant).
Holds environment obstacles in world frame and attached shapes in robot frames.
Every mutation is transactional and increments CuSceneRevision on success.
collision_env borrows the scene as a zero-copy CuCollisionEnv.
Implementations§
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Sourcepub const OBSTACLE_CAPACITY: usize = MAX_OBSTACLES
pub const OBSTACLE_CAPACITY: usize = MAX_OBSTACLES
Maximum number of environment obstacles.
Sourcepub const ATTACHED_CAPACITY: usize = MAX_ATTACHED
pub const ATTACHED_CAPACITY: usize = MAX_ATTACHED
Maximum number of attached shapes.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty planning scene initialized at CuSceneRevision::INITIAL.
Sourcepub const fn revision(&self) -> CuSceneRevision
pub const fn revision(&self) -> CuSceneRevision
Returns the current scene revision.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if the scene has neither obstacles nor attached shapes.
Sourcepub fn obstacle_shapes(&self) -> &[CuCollisionShape]
pub fn obstacle_shapes(&self) -> &[CuCollisionShape]
Active obstacle shapes in world coordinates; the count is obstacle_shapes().len().
Sourcepub fn obstacle_ids(&self) -> &[CuObjectId]
pub fn obstacle_ids(&self) -> &[CuObjectId]
Stable IDs of the active obstacles, parallel to obstacle_shapes.
Sourcepub fn obstacles(&self) -> impl Iterator<Item = CuSceneObstacle> + '_
pub fn obstacles(&self) -> impl Iterator<Item = CuSceneObstacle> + '_
Iterates over the active obstacles with their IDs.
Sourcepub fn attached_shapes(&self) -> &[CuAttachedShape]
pub fn attached_shapes(&self) -> &[CuAttachedShape]
Active attached shapes; the count is attached_shapes().len().
Sourcepub fn obstacle(&self, id: CuObjectId) -> Option<&CuCollisionShape>
pub fn obstacle(&self, id: CuObjectId) -> Option<&CuCollisionShape>
Looks up an obstacle shape by its typed object ID.
Sourcepub fn attached_shape(&self, id: CuObjectId) -> Option<&CuAttachedShape>
pub fn attached_shape(&self, id: CuObjectId) -> Option<&CuAttachedShape>
Looks up an attached shape by its typed object ID.
Sourcepub fn contains(&self, id: CuObjectId) -> bool
pub fn contains(&self, id: CuObjectId) -> bool
Returns true if the specified object identifier is present in the scene.
Sourcepub fn collision_env(&self) -> CuCollisionEnv<'_>
pub fn collision_env(&self) -> CuCollisionEnv<'_>
Zero-copy view of the obstacles (with IDs) and attached shapes for collision checks.
Add exclusions with CuCollisionEnv::with_exclusions.
Sourcepub fn add_obstacle(
&mut self,
shape: CuCollisionShape,
id: Option<CuObjectId>,
) -> CuResult<CuObjectId>
pub fn add_obstacle( &mut self, shape: CuCollisionShape, id: Option<CuObjectId>, ) -> CuResult<CuObjectId>
Adds a world-frame obstacle and returns its ID.
With id = None a fresh unique ID is assigned; with Some(id) that ID is used and must be
valid and unused. Fails on capacity, invalid geometry, invalid or duplicate ID, or revision
exhaustion; on failure, state is unmodified.
Sourcepub fn update_obstacle(
&mut self,
id: CuObjectId,
shape: CuCollisionShape,
) -> CuResult<()>
pub fn update_obstacle( &mut self, id: CuObjectId, shape: CuCollisionShape, ) -> CuResult<()>
Replaces the geometry of an existing obstacle. On failure, state is unmodified.
Sourcepub fn remove_obstacle(&mut self, id: CuObjectId) -> CuResult<CuCollisionShape>
pub fn remove_obstacle(&mut self, id: CuObjectId) -> CuResult<CuCollisionShape>
Removes an obstacle, preserving the order of the others. On failure, state is unmodified.
Sourcepub fn add_attached(
&mut self,
frame: Option<usize>,
shape: CuCollisionShape,
id: Option<CuObjectId>,
) -> CuResult<CuObjectId>
pub fn add_attached( &mut self, frame: Option<usize>, shape: CuCollisionShape, id: Option<CuObjectId>, ) -> CuResult<CuObjectId>
Adds a shape attached to frame (None = base frame) and returns its ID.
ID assignment follows add_obstacle. On failure, state is unmodified.
Sourcepub fn update_attached(
&mut self,
id: CuObjectId,
update: CuAttachedUpdate,
) -> CuResult<()>
pub fn update_attached( &mut self, id: CuObjectId, update: CuAttachedUpdate, ) -> CuResult<()>
Changes the frame and/or geometry of an attached shape. On failure, state is unmodified.
Sourcepub fn remove_attached(&mut self, id: CuObjectId) -> CuResult<CuAttachedShape>
pub fn remove_attached(&mut self, id: CuObjectId) -> CuResult<CuAttachedShape>
Removes an attached shape, preserving the order of the others. On failure, state is unmodified.
Sourcepub fn attach(
&mut self,
id: CuObjectId,
frame: Option<usize>,
local_shape: CuCollisionShape,
) -> CuResult<()>
pub fn attach( &mut self, id: CuObjectId, frame: Option<usize>, local_shape: CuCollisionShape, ) -> CuResult<()>
Turns an existing obstacle into a shape attached to frame (e.g. object grasp), keeping
its CuObjectId. local_shape is the geometry in frame coordinates.
Fails if the obstacle is not found, geometry is invalid, attached storage is full, or the revision is exhausted. On failure, state is unmodified.
Sourcepub fn detach(
&mut self,
id: CuObjectId,
world_shape: CuCollisionShape,
) -> CuResult<()>
pub fn detach( &mut self, id: CuObjectId, world_shape: CuCollisionShape, ) -> CuResult<()>
Turns an attached shape into a world-frame obstacle (e.g. object release), keeping its
CuObjectId.
Fails if the attached shape is not found, geometry is invalid, obstacle storage is full, or the revision is exhausted. On failure, state is unmodified.
Sourcepub fn clear(&mut self) -> CuResult<()>
pub fn clear(&mut self) -> CuResult<()>
Clears all obstacles and attached shapes, advancing the revision if the scene was not empty. On failure (revision exhaustion), state is unmodified.
Sourcepub fn clear_obstacles(&mut self) -> CuResult<()>
pub fn clear_obstacles(&mut self) -> CuResult<()>
Clears all obstacles, advancing the revision if any were present. On failure, state is unmodified.
Sourcepub fn clear_attached(&mut self) -> CuResult<()>
pub fn clear_attached(&mut self) -> CuResult<()>
Clears all attached shapes, advancing the revision if any were present. On failure, state is unmodified.
Sourcepub fn transaction<F, R>(&mut self, f: F) -> CuResult<R>where
F: FnOnce(&mut Self) -> CuResult<R>,
pub fn transaction<F, R>(&mut self, f: F) -> CuResult<R>where
F: FnOnce(&mut Self) -> CuResult<R>,
Executes a transaction block on the planning scene.
If the closure f succeeds, modifications are committed and the revision advances once
if state was modified without advancing it. If f returns an error or revision
exhaustion occurs, the scene rolls back to its pre-transaction state.
Sourcepub fn world_attached_shapes<const N: usize, const MAX_OUT: usize>(
&self,
link_frames: &[Transform3D<f64>; N],
out_shapes: &mut [CuCollisionShape; MAX_OUT],
) -> CuResult<usize>
pub fn world_attached_shapes<const N: usize, const MAX_OUT: usize>( &self, link_frames: &[Transform3D<f64>; N], out_shapes: &mut [CuCollisionShape; MAX_OUT], ) -> CuResult<usize>
Writes world-space copies of the active attached shapes for link_frames into
out_shapes and returns how many were written.
Validates capacity, frame indices, transforms, and resulting geometry first: on error,
out_shapes is unmodified.
Trait Implementations§
Source§impl<'de, C, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> BorrowDecode<'de, C> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<'de, C, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> BorrowDecode<'de, C> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = C>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = C>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Clone for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Clone for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§fn clone(&self) -> CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
fn clone(&self) -> CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Debug for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Debug for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<C, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Decode<C> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<C, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Decode<C> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Default for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Default for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<'de, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Deserialize<'de> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<'de, const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Deserialize<'de> for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Encode for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Encode for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> PartialEq for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> PartialEq for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Serialize for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Serialize for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> StructuralPartialEq for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
Source§impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> TypePath for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> TypePath for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
fn type_path() -> &'static str
fn short_type_path() -> &'static str
fn type_ident() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
fn module_path() -> Option<&'static str>
Auto Trait Implementations§
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Freeze for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> RefUnwindSafe for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Send for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Sync for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> Unpin for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> UnsafeUnpin for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
impl<const MAX_OBSTACLES: usize, const MAX_ATTACHED: usize> UnwindSafe for CuPlanningScene<MAX_OBSTACLES, MAX_ATTACHED>
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<T> CuMsgPayload for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> GetTypeRegistration for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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