Note: This tutorial assumes that you have completed the previous tutorials: Rocon Launch, Launching a Gateway Hub. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Command Line Tools
Description: Convenient tools for gateway interaction from the command line.Keywords: rocon, multimaster, gateway
Tutorial Level: BEGINNER
Next Tutorial: Gateway Graph Rqt Plugin
Contents
Overview
To keep the workflow concise and clear, we are using rocon_launch to kickstart a multimaster environment using linux terminals running roscores on different ports.
Launch Hub and Gateways
The following starts three separate ros masters - hub, gateway system with tutorials and a gateway system with nothing added (to act as the remote gateway).
> rocon_launch rocon_gateway_tutorials gateway_tutorials.concert --screen == Operations == === Flipping === For ease of testing, [[rocon_gateway]] provides some tools to conveniently interact with the gateways. Interactively flipping the chatter publisher from the first gateway to the second (make sure you are on ROS_MASTER_URI=http://localhost:11312 here) {{{ > rosrun rocon_gateway flip > Create or cancel a flip rule (f/c): f Automatically selecting target gateway pirate_gateway2 (only one visible) Select a connection to flip (name-type-node): 0) /chatter-subscriber-/listener 1) /babbler-publisher-/babbler 2) /chatter-publisher-/talker 3) /fibonacci/client-action_client-/fibonacci_client 4) /add_two_ints-service-/add_two_ints_server 5) /fibonacci/server-action_server-/fibonacci_server Enter [0-5] or regex keyed by name [e.g. /cha.* or .*]: 2 Information Local Gateway: /gateway Operation : flip Flip Rules : pirate_gateway2-/chatter-publisher-/talker Proceed? (y/n): y
You can see here that connections are flipped based on a 'name-type-node' triple. Also note regex's are quite ok as well (this applies further to the actual service calls).
What this actually does is add a flip rule to a watchlist. When it finds a matching connection, it will immediately flip that connection to the specified gateway.
Cancelling a rule that has been added to the watchlist:
snorri@snorriwork64:/opt/multimaster$ rosrun rocon_gateway flip > Create or cancel a flip rule (f/c): c Automatically selecting /chatter (only one flip rule in the watchlist) Information Local Gateway: /gateway Operation : cancel Flip Rules : pirate_gateway2-/chatter-publisher-/talker Proceed? (y/n): y
Advertise-Pull
The second method for gateway interactions is a two-step method, advertise-pull. One gateway advertises some of its connections for public use and another gateway can freely pull these (flipping provides a mechanism for the gateway system who have the connections, while pulling provides control for the gateway accessing the services).
First, let's advertise the /chatter publisher from the first gateway (ROS_MASTER_URI=http://localhost:11312):
> rosrun rocon_gateway advertise > Advertise or cancel advertisements (a/c): a Select a connection to advertise (name-type-node): 0) /chatter-subscriber-/listener 1) /babbler-publisher-/babbler 2) /chatter-publisher-/talker 3) /fibonacci/client-action_client-/fibonacci_client 4) /add_two_ints-service-/add_two_ints_server 5) /fibonacci/server-action_server-/fibonacci_server Enter [0-5] or regex keyed by name [e.g. /cha.* or .*]: 2 Information Local Gateway: /gateway Operation : advertise Advertise Rules : /chatter-publisher-/talker Proceed? (y/n): y
Then, pull /chatter from the second gateway (ROS_MASTER_URI=http://localhost:11313):
> rosrun rocon_gateway pull > Pull or unpull connections (p/u): p Automatically selecting /chatter (only one visible) Information Local Gateway: /gateway Operation : pull Pull Rules : pirate_gateway-/chatter-publisher-/talker Proceed? (y/n): y snorri@snorriwork64:/opt/multimaster$ rostopic list /chatter /rosout /rosout_agg /zeroconf/lost_connections /zeroconf/new_connections snorri@snorriwork64:/opt/multimaster$ rostopic info /chatter Type: std_msgs/String Publishers: * /talker_snorriwork64_24493_2191842069361869173 (http://192.168.10.123:58213/) Subscribers: None
The functionality provided by these script are also accessible via the 'advertise', 'advertise_all', 'pull' and 'pull_all' services maintained by the gateway (with even more fine-grained control).
Introspection
Once you've flipped/advertised/pulled some services, you can use the following scripts to introspect on the gateway network.
Introspecting the local gateway (from the first gateway at ROS_MASTER_URI=http://localhost:11312):
> rosrun rocon_gateway gateway_info Found a local gateway at /gateway Gateway Namespace : /gateway Name : pirate_gateway Ip/Hostname : 192.168.10.123 Connected : True On Hub : Pirate Hub Firewall : False Public Watchlist : /chatter-publisher-/talker Public Interface : /chatter-publisher-/talker Flip Watchlist : pirate_gateway2-/babbler-publisher-/babbler Flipped Connections : pirate_gateway2-/babbler-publisher-/babbler Flipped in Connections : - Pull Watchlist : - Pulled Connections : -
Inspecting the remote gateways (in this case from the second gateway at ROS_MASTER_URI=http://localhost:11313):
> rosrun rocon_gateway remote_gateway_info Found a local gateway at /gateway Local Gateway Namespace: /gateway Ip/Hostname: 192.168.10.123 Remote Gateway Name : pirate_gateway Ip/Hostname: 192.168.10.123 Firewall : False Public Interface : /chatter-publisher-/talker Flipped Interface : pirate_gateway2-publisher-/babbler-/babbler Pulled Interface : -
Using the Ros Services Directly
The functionality provided by these scripts are also accessible via the 'flip', 'flip_all', 'advertise', 'advertise_all' services maintained by the gateway. Using the services directly provides even finer grained control - regex based patterns for the gateway, name and node in a remote rule, the ability to provide a rule for a connection which doesn't exist yet, amongst others.