pub struct Robot { /* private fields */ }Expand description
Fully normalized runtime-facing robot model.
This is the whole of what manifest.json carries: the robot’s identity and
structure, the motion it may make, the services it runs, and the components
it mounts together with the types behind them. Everything a launched
participant needs to know about the robot - including its own configuration -
is read from here, so there is no second persisted document to agree with.
Implementations§
Source§impl Robot
impl Robot
pub const fn id(&self) -> &RobotId
pub const fn motion(&self) -> &MotionModel
Sourcepub fn services(&self) -> impl ExactSizeIterator<Item = (&ServiceId, &Service)>
pub fn services(&self) -> impl ExactSizeIterator<Item = (&ServiceId, &Service)>
Every service this robot runs, ordered by service id.
Sourcepub fn service_config(&self, id: &str) -> Option<&Value>
pub fn service_config(&self, id: &str) -> Option<&Value>
The configuration the named service is launched with.
None covers both “this robot does not run that service” and “it runs
with no configuration”, which is the same answer to the one question a
service asks about itself at startup.
Sourcepub fn components(&self) -> impl Iterator<Item = ComponentView<'_>>
pub fn components(&self) -> impl Iterator<Item = ComponentView<'_>>
Every mounted component, 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(&self, id: &str) -> Option<ComponentView<'_>>
pub fn component(&self, id: &str) -> Option<ComponentView<'_>>
The named component: its instance, its type, and its simulation.
Sourcepub fn component_types(
&self,
) -> impl ExactSizeIterator<Item = (&ComponentTypeId, &Component)>
pub fn component_types( &self, ) -> impl ExactSizeIterator<Item = (&ComponentTypeId, &Component)>
Every declared component type, ordered by type id.
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Robot
impl<'de> Deserialize<'de> for Robot
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Auto Trait Implementations§
impl Freeze for Robot
impl RefUnwindSafe for Robot
impl Send for Robot
impl Sync for Robot
impl Unpin for Robot
impl UnsafeUnpin for Robot
impl UnwindSafe for Robot
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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