pub struct Robot { /* private fields */ }Expand description
Fully normalized runtime-facing robot model.
Implementations§
Source§impl Robot
impl Robot
pub const fn id(&self) -> &RobotId
pub const fn motion(&self) -> &MotionModel
Sourcepub fn components(&self) -> impl ExactSizeIterator<Item = &ComponentInstance>
pub fn components(&self) -> impl ExactSizeIterator<Item = &ComponentInstance>
Every mounted component instance, ordered by instance id.
Sourcepub fn component_ids(
&self,
) -> impl ExactSizeIterator<Item = &ComponentInstanceId>
pub fn component_ids( &self, ) -> impl ExactSizeIterator<Item = &ComponentInstanceId>
Every mounted instance’s identity, ordered.
Sourcepub fn component_instance(&self, id: &str) -> Option<&ComponentInstance>
pub fn component_instance(&self, id: &str) -> Option<&ComponentInstance>
The named instance, if the robot mounts one.
Sourcepub fn component_for_instance(&self, id: &str) -> Option<&Component>
pub fn component_for_instance(&self, id: &str) -> Option<&Component>
The component type behind the named instance.
Absent exactly when the instance is: a validated robot never mounts an instance of a type it did not load.
Sourcepub fn simulation_for_component_type(
&self,
component_type: &str,
) -> Option<&Simulation>
pub fn simulation_for_component_type( &self, component_type: &str, ) -> Option<&Simulation>
The simulation for a component type, when one was authored.
Sourcepub fn simulation_for_instance(&self, component_id: &str) -> Option<&Simulation>
pub fn simulation_for_instance(&self, component_id: &str) -> Option<&Simulation>
The simulation behind the named instance, when one was authored.
Sourcepub const fn structure(&self) -> &Structure
pub const fn structure(&self) -> &Structure
The robot’s own structure, in flattened runtime identities.
Sourcepub const fn footprint_envelope(&self) -> Option<FootprintEnvelope>
pub const fn footprint_envelope(&self) -> Option<FootprintEnvelope>
The persisted compiler-derived stock-safety envelope, if available.
Sourcepub fn capability(&self, reference: &CapabilityRef) -> Option<&Capability>
pub fn capability(&self, reference: &CapabilityRef) -> Option<&Capability>
The referenced capability, if the robot declares it.
Sourcepub fn capability_refs(
&self,
selects: impl Fn(&Capability) -> bool,
) -> Vec<CapabilityRef>
pub fn capability_refs( &self, selects: impl Fn(&Capability) -> bool, ) -> Vec<CapabilityRef>
Every declared capability matching selects.
The result is ordered by (component id, capability id). That order is
an invariant, not an accident of iteration: participants derive bus
identities and arbitration priorities from these positions, so two runs
over the same robot must produce the same sequence.
This is infallible because a Robot value cannot exist with an instance
whose component type is absent: validation rejects that with
ModelError::UnknownComponentType before the value is constructed. The
unresolved arm below is therefore unreachable rather than a capability
being quietly dropped, and it stays a skip rather than a panic so that
the impossible case degrades into a smaller result set instead of taking
the process down.
Sourcepub fn capabilities_with_role(&self, role: CapabilityRole) -> Vec<CapabilityRef>
pub fn capabilities_with_role(&self, role: CapabilityRole) -> Vec<CapabilityRef>
Every capability assigned the given authored role, ordered by
(component id, capability id).
Sourcepub fn require_motor(
&self,
reference: &CapabilityRef,
) -> Result<(&Motor, i8), ModelError>
pub fn require_motor( &self, reference: &CapabilityRef, ) -> Result<(&Motor, i8), ModelError>
The referenced motor and the direction sign to apply to it.
§Errors
Returns ModelError::UnknownCapability when the robot does not
declare the capability, and ModelError::CapabilityKindMismatch when
it declares something other than a motor.
Sourcepub fn require_encoder(
&self,
reference: &CapabilityRef,
) -> Result<(&Encoder, i8), ModelError>
pub fn require_encoder( &self, reference: &CapabilityRef, ) -> Result<(&Encoder, i8), ModelError>
The referenced encoder and the direction sign to apply to it.
§Errors
Returns ModelError::UnknownCapability when the robot does not
declare the capability, and ModelError::CapabilityKindMismatch when
it declares something other than an encoder.
Sourcepub fn link_target_frame(
&self,
reference: &CapabilityRef,
) -> Result<LinkId, ModelError>
pub fn link_target_frame( &self, reference: &CapabilityRef, ) -> Result<LinkId, ModelError>
The namespaced runtime frame for a capability’s component-local link.
§Errors
Returns ModelError::CapabilityTargetKind when the capability is
attached to a joint rather than a link, and
ModelError::UnknownBoundTarget when its component type has no such
link.