ROS Connector#

The Duckiematrix comes with a ROS connector that allows us to connect Duckiebots to the Duckiematrix.

Both physical and virtual Duckiebots can be connected to the Duckiematrix using a ROS connector. Physical Duckiebots connected to the Duckiematrix allow for hardware-in-the-loop simulation of agents, while virtual Duckiebots provide a fully simulated solution.

The intercommunication between ROS and the Duckiematrix happens at the level of the hardware drivers. In particular, a virtual version of all the drivers in the dt-duckiebot-interface repository is implemented using the Duckiematrix Python SDK. These allow for virtual sensors (e.g., camera, time-of-flight, etc.) data to be bridged from the duckiematrix to the ROS network (ROS messages). Similarly, virtual actuators’ drivers (e.g., motors, leds, etc.) receive control commands from the ROS network and relay them to the Duckiematrix engine.

The following diagram shows the underlying architecture of hardware drivers for a Duckiebot connected to an instance of the Duckiematrix (Fig. 8). For comparison, Fig. 9 shows the architecture of hardware drivers for a real-world Duckiebot (no Duckiematrix).

../_images/block-ros-connector-hw-drivers-sim.png

Fig. 8 Architecture of hardware drivers for a Duckiebot connected to a Duckiematrix.#

../_images/block-ros-connector-hw-drivers-real.png

Fig. 9 Architecture of hardware drivers for a real-world Duckiebot (no Duckiematrix).#

Attach a Duckiebot to the Duckiematrix#

For a Duckiebot to act and sense inside the Duckiematrix, it needs a proxy in the virtual world (a virtual Duckiebot) to attach to. A Duckiebot outside the Duckiematrix is said to be attached to the Duckiematrix when all its sensors and actuators are linked to their virtual counterparts inside the Duckiematrix.

We can use the following command to attach a Duckiebot to a running Duckiematrix,

dts matrix attach [-e ENGINE_HOSTNAME] VIRTUAL_ROBOT_NAME ENTITY_NAME

where VIRTUAL_ROBOT_NAME is the name of the Duckiebot outside the Duckiematrix and ENTITY_NAME is the name of the virtual entity inside the Duckiematrix we want to connect to, for example, map_0/vehicle_0.