pub struct ComponentTypeBuilder { /* private fields */ }Expand description
Declares one component type: the capabilities and structure every instance of it has, and how a simulated world models it.
Reached through RobotBuilder::component_type.
Implementations§
Source§impl ComponentTypeBuilder
impl ComponentTypeBuilder
Sourcepub fn capability(self, capability: &str, declared: Capability) -> Self
pub fn capability(self, capability: &str, declared: Capability) -> Self
Declare one capability, exactly as the canonical model carries it.
Every shorthand below is this method with one kind’s defaults filled in; reach for this one when a capability needs parameters, or a structural target, that its shorthand does not offer.
use phoxal_model::builder::RobotBuilder;
use phoxal_model::component::capability::{
Capability, Motor, MotorCommand, StructuralTarget,
};
use phoxal_model::identity::JointId;
let robot = RobotBuilder::new("arm-bot")
.component_type("joint_motor", |joint_motor| {
joint_motor.capability(
"lift",
Capability::Motor(Motor {
target: StructuralTarget::Joint { id: JointId::new("elbow") },
command: MotorCommand::Position,
gear_ratio: 50.0,
max_torque_nm: Some(12.0),
max_velocity_radps: None,
}),
)
})
.component("arm", "joint_motor")
.build()?;
let (motor, _sign) = robot.require_motor(&"arm.lift".parse()?)?;
assert_eq!(motor.gear_ratio, 50.0);Sourcepub fn joint(self, joint: Joint<'_>) -> Self
pub fn joint(self, joint: Joint<'_>) -> Self
Add one joint, and its child link, to this component’s structure.
A component that states nothing still gets a joint or link for every capability target it declares.
Sourcepub fn link(self, link: Link<'_>) -> Self
pub fn link(self, link: Link<'_>) -> Self
Give one link of this component’s structure a body.
A link no stated joint attaches is added beneath mount by a fixed
joint named <link>_joint, so this is enough on its own to put a link
on the component. Stating the same link twice replaces the earlier body.
use phoxal_model::builder::{Link, RobotBuilder, Visual};
use phoxal_model::structure::Geometry;
let robot = RobotBuilder::new("rover")
.component_type("rgbd", |camera| {
camera.camera("rgb", "lens").link(Link {
name: "lens",
visuals: vec![Visual::new(Geometry::Cylinder {
radius: 0.02,
length: 0.01,
})],
..Link::default()
})
})
.component("front_camera", "rgbd")
.build()?;
let camera = robot
.component_for_instance("front_camera")
.expect("the mounted type is loaded");
let lens = camera.structure().link("lens").expect("the stated link");
assert_eq!(lens.visuals().len(), 1);Sourcepub fn material(self, material: Material<'_>) -> Self
pub fn material(self, material: Material<'_>) -> Self
Add one material to this component structure’s own catalogue.
The component counterpart of RobotBuilder::material. Restating a
name replaces the earlier material.
Sourcepub fn simulated(self, capability: &str, simulated: Capability) -> Self
pub fn simulated(self, capability: &str, simulated: Capability) -> Self
Model one of this type’s capabilities in a simulated world.
The named capability must be one this type declares, of the same kind,
which RobotBuilder::build checks.
use phoxal_model::builder::RobotBuilder;
use phoxal_model::simulation;
let robot = RobotBuilder::new("rover")
.component_type("drive_motor", |motor| {
motor.motor("spin", "axle").simulated(
"spin",
simulation::Capability::Motor(simulation::Motor::default()),
)
})
.component("left_drive", "drive_motor")
.build()?;
assert!(robot.simulation_for_instance("left_drive").is_some());Sourcepub fn contact_material(self, link: &str, material: &str) -> Self
pub fn contact_material(self, link: &str, material: &str) -> Self
Give one component-local link a simulated contact material.
Sourcepub fn motor(self, capability: &str, joint: &str) -> Self
pub fn motor(self, capability: &str, joint: &str) -> Self
A velocity motor driving joint, geared one to one.
Sourcepub fn encoder(self, capability: &str, joint: &str) -> Self
pub fn encoder(self, capability: &str, joint: &str) -> Self
An incremental encoder measuring joint, geared one to one.
Sourcepub fn accelerometer(self, capability: &str, link: &str) -> Self
pub fn accelerometer(self, capability: &str, link: &str) -> Self
A three-axis accelerometer on link.
Sourcepub fn magnetometer(self, capability: &str, link: &str) -> Self
pub fn magnetometer(self, capability: &str, link: &str) -> Self
A three-axis magnetometer on link.
Sourcepub fn imu(self, capability: &str, link: &str) -> Self
pub fn imu(self, capability: &str, link: &str) -> Self
A fused inertial measurement unit on link.
Sourcepub fn gnss(self, capability: &str, link: &str) -> Self
pub fn gnss(self, capability: &str, link: &str) -> Self
A satellite receiver on link, reporting in the robot’s local frame.
Sourcepub fn camera(self, capability: &str, link: &str) -> Self
pub fn camera(self, capability: &str, link: &str) -> Self
A 640x480 colour camera looking out of link.
Sourcepub fn depth(self, capability: &str, link: &str) -> Self
pub fn depth(self, capability: &str, link: &str) -> Self
A 640x480 depth sensor looking out of link.
Sourcepub fn emergency_stop(self, capability: &str, link: &str) -> Self
pub fn emergency_stop(self, capability: &str, link: &str) -> Self
An emergency stop input on link.
Sourcepub fn range(self, capability: &str, link: &str) -> Self
pub fn range(self, capability: &str, link: &str) -> Self
A narrow single-beam range finder on link.
Sourcepub fn lidar(self, capability: &str, link: &str) -> Self
pub fn lidar(self, capability: &str, link: &str) -> Self
A planar lidar on link, publishing ranges.
Sourcepub fn microphone(self, capability: &str, link: &str) -> Self
pub fn microphone(self, capability: &str, link: &str) -> Self
A microphone on link.