asimov.api

init-node!

(init-node! name client-host master-host master-port hosts)
Starts a new ros node.
This node connects to a single master and can subscibe and publish
to other nodes that are connected to it.
Multiple nodes with the same or different masters can be started
simultaneously, this allows for communication with multiple masters
and the creation of multiple services within the same process or repl.

Expects:
 client-host:string  The address of the machine the node runs on, in the masters network.
 master-host:string The adress of the machine running the ros master.
 master-port:number The port on which the master communicates.
 hosts:{string string} A hosts map that has the same function as the hosts file.
 name:string The name of the node.

Returns an atom storing all the connections state.
Which can then be used to publish and subscribe to topics.

msg

(msg id raw)(msg msgs id raw)
Creates a single message definition from a string.
When loading a message definition for which the id already exists,
the old message definition will be overriden and message definitions
depending on it will be rebuild.
Note that messages must be loaded in the order they depend on each other,
if you want to load multiple messages you should use `msgs`.

Expects:
 msgs:map The messages already loaded.
          It has to contain the dependencies of this message definition.
          Defaults to the empty map.
 id:string The `package/name` identifier of this message.
 raw:string The raw message definition in the ros message definition format.

Returns the given message definition map with the new message added to it.

msgs

(msgs dir)(msgs msgs dir)
Loads all the message definitions contained in the given directory.
Message definitions may be stored at arbitrary depth as long as they follow
the ros `package_name/msgs/msg_name.msg` path convention.
When loading message definitions for which the id already exists,
the old message definitions will be overriden and message definitions
depending on them will be rebuild.
Note that messages must be loaded in the order they depend on each other,
so you should load them either all at once or take appropriate measures.

Expects:
 msgs:map The messages already loaded.
          It has to contain the dependencies of this message definition.
          Defaults to the empty map.
 dir:string The directory from which the messages are to be loaded.

Returns the given message definition map with the new messages added to it.

pub!

(pub! node msg-def topic)
Makes the node publish to a topic.

Expects:
 node:atom A node that is supposed to make the publication.
 msg-def:map The message definition to be used to serialize send messages.
 topic:string The name of the topic.

Returns a core.async sliding channel that will forward messages onto the topic.
This channel will also be stored on the node atom.

sub!

(sub! node msg-def topic)
Subscribes a node to a topic.
Currently connection will only happen to those nodes that have already
published the topic. This is subject to change, so that connections will automatically
be added once new publishers appear.

Expects:
 node:atom A node that is supposed to make the subscription.
 msg-def:map The message definition to be used to deserialize received messages.
 topic:string The name of the topic.

Returns a core.async sliding channel that will contain messages received on the topic.
This channel will also be stored on the node atom.