Helpers the bb_nsk.add_* tasks share.
BB.Igniter covers most of what an installer needs, but its
populate_link/4 deliberately refuses a link that already has a body — it
exists to fill an empty link :base_link do end without trampling a user's
edits — and it walks down to a link through a chain of enclosing links.
Neither fits here. The Balance Bot's links are separated by joints rather
than nested directly, and each task adds to a link that a previous task has
already populated: bb_nsk.install gives :base_link its visual and
inertial, and the wheels and the IMU mount hang off it afterwards.
So these search the topology for a link by name and append to it. Names are unique across a BB topology, which is what makes the search unambiguous.
Only available when :igniter is loaded.
Summary
Functions
Add a sensor to the robot's top-level sensors do … end section.
Append code to the body of a named topology entity.
Append code to the body of the joint named joint.
Append code to the body of the link named link, wherever it sits in the
topology.
Whether the robot's topology already carries an entity of this name — a link, a joint, a sensor or an actuator.
Whether the robot's topology has a link of this name.
Functions
Add a sensor to the robot's top-level sensors do … end section.
For a sensor that measures something about the robot's surroundings rather
than about a link — the HTS221 reads the air, and has no frame. It also
decides where the reading is published: a robot-level sensor publishes on
[:sensor, <name>], where one hung off a link is buried under that link's
whole path.
Idempotent on name, and the section is created if it isn't there.
@spec append_to(Igniter.t(), module(), {atom(), atom()}, String.t(), {atom(), atom()}) :: Igniter.t()
Append code to the body of a named topology entity.
Idempotent through marker, an {entity, name} pair naming something the
code adds — {:joint, :left_wheel_joint}, say. If that entity is already
somewhere underneath, the igniter is returned unchanged, so a task can be run
twice and a user's edits to what it added the first time survive.
Returns the igniter unchanged if the target isn't there. Tasks check that for
themselves with entity_in_topology?/4 so they can say something useful
about it.
Append code to the body of the joint named joint.
Sensors that report a joint's own configuration belong in its body rather than on a link — the lean angle and the heading are both measurements of a joint, derived from an IMU hanging off a link somewhere below it.
Append code to the body of the link named link, wherever it sits in the
topology.
Whether the robot's topology already carries an entity of this name — a link, a joint, a sensor or an actuator.
Read-only, so it doesn't queue a change the way Spark.Igniter.update_dsl
would.
Whether the robot's topology has a link of this name.
Tasks use it to check their preconditions, so that bb_nsk.add_balance run
against a robot with no IMU says so rather than producing one that never
stands up.