BB.NSK.TestRobot (bb_nsk v0.1.2)

Copy Markdown View Source

The Balance Bot's topology, with nothing attached to it.

The same robot the installer writes into a user's project, minus the IMU. The BMI323 driver stops rather than declining when the chip isn't there, which on the host would take the supervision tree with it, so the tests publish onto the estimator's path directly instead.

The wheels are declared and will decline to start — there is no pwmchip0 on a laptop — which is the behaviour a robot missing its hardware is supposed to have, and is worth exercising.

Anything here that disagrees with the bb_nsk.add_* tasks is a bug in one of them.

Summary

Functions

Returns default parameter values.

Returns the parameter schema for validation.

Execute the arm command.

Returns a child specification for starting this robot under a supervisor.

Execute the disarm command.

Execute the fall command.

Execute the poweroff command.

Returns the optimised robot representation.

Execute the stand command.

Starts the robot's supervision tree.

Functions

__bb_default_parameters__()

@spec __bb_default_parameters__() :: [{[atom()], term()}]

Returns default parameter values.

Returns a list of {path, value} tuples for parameters that have defaults.

__bb_parameter_schema__()

@spec __bb_parameter_schema__() :: [{[atom()], keyword()}]

Returns the parameter schema for validation.

The schema is a list of {path, opts} tuples where opts is a keyword list compatible with Spark.Options.

arm(goal \\ [])

@spec arm(keyword()) :: {:ok, pid()} | {:error, term()}

Execute the arm command.

Returns

  • {:ok, pid()} - Command started, use BB.Command.await/2 for the result
  • {:error, term()} - Command could not be started

Example

{:ok, cmd} = arm(goal_args)
{:ok, result} = BB.Command.await(cmd)

child_spec(opts \\ [])

@spec child_spec(Keyword.t()) :: Supervisor.child_spec()

Returns a child specification for starting this robot under a supervisor.

disarm(goal \\ [])

@spec disarm(keyword()) :: {:ok, pid()} | {:error, term()}

Execute the disarm command.

Returns

  • {:ok, pid()} - Command started, use BB.Command.await/2 for the result
  • {:error, term()} - Command could not be started

Example

{:ok, cmd} = disarm(goal_args)
{:ok, result} = BB.Command.await(cmd)

fall(goal \\ [])

@spec fall(keyword()) :: {:ok, pid()} | {:error, term()}

Execute the fall command.

Returns

  • {:ok, pid()} - Command started, use BB.Command.await/2 for the result
  • {:error, term()} - Command could not be started

Example

{:ok, cmd} = fall(goal_args)
{:ok, result} = BB.Command.await(cmd)

poweroff(goal \\ [])

@spec poweroff(keyword()) :: {:ok, pid()} | {:error, term()}

Execute the poweroff command.

Returns

  • {:ok, pid()} - Command started, use BB.Command.await/2 for the result
  • {:error, term()} - Command could not be started

Example

{:ok, cmd} = poweroff(goal_args)
{:ok, result} = BB.Command.await(cmd)

robot()

@spec robot() :: BB.Robot.t()

Returns the optimised robot representation.

This struct is built at compile-time from the DSL definition and contains:

  • All physical values converted to SI base units (floats)
  • Flat maps for O(1) lookup of links, joints, sensors, and actuators
  • Pre-computed topology metadata for efficient traversal

Examples

robot = Elixir.BB.NSK.TestRobot.robot()
{:ok, link} = BB.Robot.get_link(robot, :base_link)
{:ok, joint} = BB.Robot.get_joint(robot, :shoulder)

stand(goal \\ [])

@spec stand(keyword()) :: {:ok, pid()} | {:error, term()}

Execute the stand command.

Returns

  • {:ok, pid()} - Command started, use BB.Command.await/2 for the result
  • {:error, term()} - Command could not be started

Example

{:ok, cmd} = stand(goal_args)
{:ok, result} = BB.Command.await(cmd)

start_link(opts \\ [])

@spec start_link(Keyword.t()) :: Supervisor.on_start()

Starts the robot's supervision tree.

Options

All options are passed through to sensor and actuator child processes.