ipa-rar / ros-grpc-bridge-generator

Experimental gRPC server generator to mirror ROS topics and services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ROS - gRPC bridge generator

Experimental gRPC server generator to mirror ROS topics and services

How it works?

  • The script creates a snapshot of all the running ROS topics and services available at the moment,
  • then generates a standalone package in your catkin workspace, which implements the gRPC server as a ROS node.

Notes

  • Protobuf has no equivalent for constants in ROS messages, so they are added as comments to the proto message definitions.
  • uint8[] and char[] ROS array types are represented as bytes in Protobuf (like in the python msg generator)
  • Only ROS Noetic is supported (because it needs python3)
  • The whole generator is implemented as a Jupyter notebook and a cookiecutter template, so feel free to try changes and suggest modifications :)

Install

Clone the repo into a catkin workspace:

# in your_catkit_ws/src
git clone https://github.com/azazdeaz/ros-grpc-bridge-generator.git

install dependencies and build

# in your_catkit_ws
rosdep update
rosdep install --from-paths src --ignore-src -r -y
catkin_make

Usage

  1. Start the necessary ROS nodes to make the topics and services visible.

  2. Generate the server

roslaunch grpc_bridge_generator generate.launch pkg_name:=grpc_bridge
# now, the new pkg should be in your workspace
# install its deps and build it:
rosdep install --from-paths src --ignore-src -r -y
catkin_make
  1. Run the generated server

roslaunch grpc_bridge server.launch

Example

You can find an example catkin workspace at https://github.com/azazdeaz/ros-grpc-bridge-generator-example

Development

The script is implemented as a Jupyter Notebook, so it's easy to poke around and tailor the generator for your project.

To launch the editor, just run:

rosrun grpc_bridge_generator notebook

Executing this notebook is equivalent to running generate.launch.

Tests

The end-to-end tests are a bunch of snapshot files in the test/snapshots folder and their pre-generated packages in the test/expected folder.

Running rostest grpc_bridge_generator generate.test will regenerate these packages in the test/result folder and compare them with the expected folder. It will fail for any changes. To update the tests, override the files in the test/expected folder.

To add a new test, copy a snapshot file in test/snapshots, run the tests, and move the generated pkg from the result to the expected folder.

There are also some doctests in the generate.ipynb but only to make the development easier. They will run with the notebook.

Notes on the snapshot file

  • It's an ini file (python configparse format) used as the only source for the gRPC server generator
  • Generated by default but can be edited manually
  • You can tell the generate script to use an edited snapshot instead of generating a new one (see options)
  • Has three sections: TOPICS, SERVICES, and MESSAGE_DEFINITIONS
  • Keys are ordered alphabetically for easier editing/diffing
  • Nested message definitions are normalized (flattened)

About

Experimental gRPC server generator to mirror ROS topics and services

License:MIT License


Languages

Language:Python 90.4%Language:Jupyter Notebook 9.0%Language:CMake 0.5%Language:Shell 0.2%