Project

General

Profile

Documentation for ROS ACUMOS bridge examples.

Félix Ingrand <felix@laas.fr>

This project contains a number of C++ examples on how to connect ROS nodes (using .msg, topics, publish/subscribe) and ACUMOS components (using ProtoBuf and gRPC client/server).

Note The credits for the code should do to the gRPC and ROS community/developers, as most of it is taken from their respective tutorials.

These examples, should compile on any machine with ROS and gRPC installed (so install them first if needed). They are to be considered as starting points to be used for more ambitious projects.

Warning Beware of inconsistent ProtoBuf/gRPC versions. I strongly advise you to install gRPC following the instruction on: https://grpc.io/docs/languages/cpp/quickstart/ This will install gRPC and ProtoBuf, minimizing the risk of version inconsistency.

I am using regular Makefile and pkg-config. You may move to cmake and catkin if you feel like it, but do not ask me how to do it ;-) I would not know…​

Passing data from ROS/Topics to ACUMOS/ProtoBuf

The current setup contains 6 executable programs (the 2+2 mostly unmodified respective tutorial for both middlewares, plus 2 programs mixing them):

  • talker and listener are the regular ROS tutorial nodes with talker publishing the chatter topic containing a string, and listener which subscribes to this topic and prints it upon receiving i. The message description is trivial and standard: std_msgs/String.h, where the string is in the data field. If you are not familiar with ROS, check the code and run the example to familiarize yourself with it.

  • greeter_client and greeter_server are the regular gRPC tutorial client and server (synchronous version) which define the Greeter service which takes a string HelloRequest as input and produces a string HelloReply as output (see the helloworld.proto file which contains the ProtoBuf/gRPC definitions). Again, check the source and run the code to get an idea of how this works.

  • listener_greeter_bridge which mixes both middlewares tutorials. It is a ROS node/gRPC client which, acting as a ROS node, subscribes to the chatter topic and, acting as a gRPC client, call synchronously the Greeter service with the string contained in chatter as HelloRequest name field. greeter_server, then runs the service and sends the reply back. The gRPC Greeter service call is made inside the ROS callback attached to the chatter topic.

  • greeter_talker_bridge which also mixes both middlewares. It is a ROS node/gRPC server which acts as a gRPC server which implements Greeeter. It thus receives a string (in the HelloRequest name field )from a gRPC client and publish it in the chatter topic and then reply to its client.

These two examples are the most "simple" setup one can think of to "get started". Still, note that in both setup, you do not have to modify the nodes which publishes/subscibes to the topic (talker/listener in our case), nor do you need to change the gRPC server/client (greeter_server/greeter_client in this setup). So existing ROS nodes and gRPC server/client do not need to be modified, at the cost of an additional program which bridges the two middlewares.

Note Do not forget to start roscore before starting talker and listener

You can run all the programs at will, the most interesting combinations for connecting ROS nodes to ACUMOS components (without modifying any of theses) are:

The legend for the following figures is this one:

The legend of the figures
  • greeter_server, listener_greeter_bridge and talker (this combination can be used when you want a ROS node to send data to an ACUMOS component without changing any of these two). But nothing prevent you from adding the regular listener and or greeter_client…​ you can even add another talker (providing you change its node name).

The setup for the passing a ROS topic to a gRPC server
  • listener, greeter_talker_bridge and greeter_client (this combination can be used when you want an ACUMOS component to send data to a ROS node without changing any of these two). Here also you can add on the top of this a talker or another greeter_client.

The setup for the passing a gRPC client data to a ROS topic
Note if you run both greeter_talker_bridge and listener_greeter_bridge at the same time…​ and you feed them one topic value…​ guess what? you will see how fast these middlewares can run and freeze your terminal…​ ;-)

Calling a ROS service from a gRPC client thru a gRPC(server)/ROS(client) bridge

This setup relies on the AddTwoInts ROS service descibed in the ROS tutorial, you need first to install it Add Two Ints ROS Service, otherwise the executables will not be compiled (the Makefile is supposedly smart enough to not compile them). Two executables are provided: add_two_ints_client and add_two_ints_bridge.

  • add_two_ints_client is a simple gRPC client using the service/protobuf defined in AddTwoInts.proto. This ProtoBuf provides the definition for the service Adder and its rpc ATI, as well as the ATIrequest and ATIreply messages.

  • add_two_ints_bridge is a gRPC server/ROS Service client, which will call the ROS service defined in the Add Two Ints ROS Service tutorial.

The setup is illustrated in the following figure. You call the ROS Service server

rosrun beginner_tutorials add_two_ints_server

Then you start the add_two_ints_bridge which will setup a bridge which will act as a gRPC server/ROS Service client, and then you can call the add_two_ints_client with two integer as argument to illustrate the whole process.

add_two_ints_bridge &
add_two_ints_client 4 7
...
The setup for a gRPC client calling a bridge server calling a ROS Service (add_two_ints)

Enjoy!