pub struct ComponentBuilder { /* private fields */ }Expand description
Configures one mounted component instance.
Reached through RobotBuilder::component_with.
Implementations§
Source§impl ComponentBuilder
impl ComponentBuilder
Sourcepub fn mounted_on(self, link: &str) -> Self
pub fn mounted_on(self, link: &str) -> Self
Mount this instance on the named robot link rather than on the one generated from its instance id.
The link is added beneath base_link unless a stated joint already
attaches it.
Sourcepub fn direction_sign(self, capability: &str, sign: i8) -> Self
pub fn direction_sign(self, capability: &str, sign: i8) -> Self
State which way this instance’s capability is turned, as 1 or -1.
This is what Robot::require_motor and Robot::require_encoder
return beside the capability, so that a mirrored actuator is described
once on the model rather than by every consumer that drives it.
Sourcepub fn driver(self, driver: Value) -> Self
pub fn driver(self, driver: Value) -> Self
Give this instance the hardware connection block that makes it a driven component.
Its presence is what says a component driver runs for this instance, under the instance’s own id, and the block is that driver’s configuration. An instance without one is modelled and observed but launches no process.
use phoxal_model::builder::RobotBuilder;
let robot = RobotBuilder::new("rover")
.component_type("drive_motor", |motor| motor.motor("spin", "axle"))
.component_with("left_drive", "drive_motor", |mounted| {
mounted.driver(serde_json::json!({ "connection": "/dev/ttyUSB0" }))
})
.build()?;
let left = robot.component("left_drive").expect("the mounted instance");
assert!(left.instance().driver().is_some());