Code Monkey home page Code Monkey logo

swarm_ros_bridge's Introduction

swarm_ros_bridge

Introduction

A lightweight middle interface ROS package mainly based on ZeroMQ. It enables the specified ROS messages transmission among swarm robots through socket communication. The purpose of this package is to replace the traditional way of running ROS across multiple machines in ROS1, which has some drawbacks under swarm robots situation.

An example of two ROS robots communicating with each other through swarm_ros_bridge is shown below:

framework

Compared with ROS1 multi-robot wireless communication, it has the following benefits:

  • Robust: No need for base station ROS master launching first. Support each robot launching in a random sequence and connecting each other autonomously.

  • Flexible: You can choose the sending/receiving ROS topics rather than transferring all topic (names) as ROS1 does.

  • Easy to use: Specify all the IP and ROS topics in one configuration file.

Compared with ROS2 DDS communication, it may have the following benefits:

  • Lightweight: It is a small ROS bridge node subscribing and sending remote ROS topics, so connecting with other ROS nodes is easy.
  • Reliable: It uses ZeroMQ socket communication based on TCP protocol while ROS2 is based on DDS, whose default protocol is UDP (unreliable). DDS is mainly designed for data exchange between native processes under wired communication rather than remote wireless communication.

ROS wiki page: https://wiki.ros.org/swarm_ros_bridge

source code: https://github.com/shupx/swarm_ros_bridge.git

csdn blog (in chinese): https://blog.csdn.net/benchuspx/article/details/128576723

Structure

└── swarm_ros_bridge
    ├── CMakeLists.txt
    ├── config
    │   └── ros_topics.yaml  # Config file to specify send/receive ROS topics
    ├── include
    │   ├── bridge_node.hpp  # Header file of bridge_node.cpp
    │   ├── ros_sub_pub.hpp  # Header file for different ROS message type.
    ├── launch
    │   └── test.launch
    ├── package.xml
    └── src
        └── bridge_node.cpp  # @brief Reliable TCP bridge for ros data transfer in unstable network.
                             # It will send/receive the specified ROS topics in ../config/ros_topics.yaml
                             # It uses zmq socket(PUB/SUB mode), which reconnects others autonomously and
                             # supports 1-N pub-sub connection even with TCP protocol.

Install

Supported platforms/releases:

Platform ROS Release
Ubuntu 16.04 Xenial ROS Kinetic
Ubuntu 18.04 Bionic ROS Melodic
Ubuntu 20.04 Focal ROS Noetic

Install process:

## clone this package
mkdir -p swarm_ros_bridge_ws/src  # or your own ros workspace
cd swarm_ros_bridge_ws/src
git clone https://gitee.com/shu-peixuan/swarm_ros_bridge.git
# or 'git clone https://github.com/shupx/swarm_ros_bridge.git'

## install dependencies
sudo apt install libzmqpp-dev
# or 'rosdep install --from-path swarm_ros_bridge/'

## build
cd ../
catkin_make
source devel/setup.bash

Usage

  1. Specify the IP and ROS topic information in config/ros_topics.yaml.
  • For the sending topic, IP is self IP (* for example) and port should be different as it binds to the "tcp://*:port".
  • For the receiving topic, IP and port should be the remote source IP and port as it connects to the "tcp://srcIP:srcPort".

(The max_freq only guarantees the sending frequency is lower than that but not be that. If the send_topics frequency is larger than max_freq, the node will decrease it by 2x, 3x, ... until it satisfies the max_freq. check github issue #2)

  1. Launch the bridge_node:
roslaunch swarm_ros_bridge test.launch
  1. Publish messages into send_topics and check that remote recv_topics are receiving these messages. The console will also print INFO the first time recv_topics receive messages.

Advanced

* More ROS message types

The default supported ROS message types are only sensor_msgs/Imu and geometry_msgs/Twist. If you need more types:

  1. Modify the macros about MSG_TYPEx and MSG_CLASSx in include/ros_sub_pub.hpp, then it will generate template functions for different ros message types.
// In ros_sub_pub.hpp
// uncomment and modify the following lines:
#include <xxx_msgs/yy.h>
#define MSG_TYPE3 "xxx_msgs/yy"
#define MSG_CLASS3 xxx_msgs::yy

We support up to 10 types modification. If that is still not enough, then you should modify the topic_subscriber(), topic_publisher() and deserialize_publish() in include/ros_sub_pub.hpp according to their styles.

  1. Add the dependent package in find_package() of CMakeLists.txt:
# in CMakeLists.txt
find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  geometry_msgs
  sensor_msgs
  xxx_msgs
)
  1. Recompile:
cd swarm_ros_bridge_ws/
catkin_make

* More send_topics

We support up to 50 send_topics. Modify the following lines in include/ros_sub_pub.hpp if you need more.

// in ros_sub_pub.hpp
# define SUB_MAX 50 // max number of subscriber callbacks
//...
template <typename T>
void (*sub_callbacks[])(const T &)=
{
  sub_cb<T,0>, sub_cb<T,1>, ... //add more
};

Then recompile:

cd swarm_ros_bridge_ws/
catkin_make

Future Work

  1. Dynamic RPC, including dynamic node discovery, online topic change, and ground station monitor.
  2. Support UDP protocol for mass data transmission like video streams.
  3. Support ROS service transmission with ZeroMQ request-reply mode.
  4. Support ROS2 topic and service transmission.

Contributor

Peixuan Shu ([email protected]), PhD, beihang university, China, 2023.1.1

This package is personally developed by Peixuan Shu (PhD, beihang university, China) on Jan. 2023. Any question/suggestion is welcomed at swarm_ros_bridge issue or [email protected].

img1

swarm_ros_bridge's People

Contributors

shupx avatar carryowen avatar nuclearsandwich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.