Skip to content

ROS turtlesim with generated gRPC API (example for ros-grpc-api-generator)

Notifications You must be signed in to change notification settings

azazdeaz/ros-grpc-bridge-generator-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example ROS workspace for ros-grpc-bridge-generator

You can see how a generated package looks like in src/turtles_grpc

  1. Download
  2. Run or Run with Docker
  3. Try out the API

Download

# clone this repo
git clone --recurse-submodules https://github.com/azazdeaz/ros-grpc-bridge-generator-example
cd ros-grpc-bridge-generator-example

Run

Tested on Ubuntu 20.04 with ROS Noetic. You can run with Docker if you have a different setup.

# build the workspace
rosdep update
rosdep install --from-paths src --ignore-src -r -y
catkin_make

# launch the ROS nodes (in a new terminal)
. devel/setup.bash
roslaunch test turtles.launch

# generate the gRPC server package (in a new terminal)
. devel/setup.bash
roslaunch test generate_grpc_server.launch
catkin_make

# launch gRPC server (in a new terminal)
. devel/setup.bash
roslaunch turtles_grpc grpc_server.launch

Run with Docker

# build the container with
docker build -t ros-grpc-turtle .
# Option 1: run the simulator with Docker:
xhost +

docker run -it \
    --network="host" \
    --env="DISPLAY" \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    -p 50051 --name grpc_turtle \
    ros-grpc-turtle

# Option 2: run the simulator with Rocker:

# install rocker (this makes it easier to run docker images with GUI)
pip3 install rocker off-your-rocker

# run the container (most of the options are stolen from the ignition-gym readme, hope they will work for you too :) )
# with Intel GPU
rocker --devices /dev/dri --x11 --oyr-run-arg "-p 50051 --name grpc_turtle" ros-grpc-turtle

# with Nvidia GPU
rocker --x11 --nvidia --oyr-run-arg "-p 50051 --name grpc_turtle" ros-grpc-turtle
# in a new terminal, generate the grpc server
docker exec -it grpc_turtle bash -c '. devel/setup.bash && roslaunch test generate_grpc_server.launch && catkin_make'

# run it
docker exec -it grpc_turtle bash -c '. devel/setup.bash && roslaunch turtles_grpc grpc_server.launch'

# and now the grpc server should be running at localhost:50051 ready to operate the turtle ٩(^‿^)۶!

Try out the API

Now you should see the turtle_sim window and have a running gRPC server in the background. You can quickly test the API with a tool like BloomRPC. You'll have to set the proto file (/ros.proto) and the server address (localhost:50051 by default)

About

ROS turtlesim with generated gRPC API (example for ros-grpc-api-generator)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published