Coder Social home page Coder Social logo

yuanhao-li / ros-kafka-connector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isakdiaz/ros-kafka-connector

0.0 0.0 0.0 31 KB

Publisher and subscriber ROS nodes to interface with Kafka sever

License: MIT License

CMake 43.05% Python 56.95%

ros-kafka-connector's Introduction

ROS Package: ros_kafka_connector

This is a ROS package for subscribing or publishing to topics using Kafka.

Parameter Info Default
bootstrap_server IP of kafka server "localhost:9092"
kafka_topic topic name found in Kafka "test"
ros_topic topic name found in ROS "test"
msg_type full ROS message name "std_msgs/String"

Currently std_msgs/String, geometry_msgs/Twist and sensor_msgs/Image are supported. You can add any message type by adding the import to the utils.py file and then changing the parameter in the launch file.

Publish to ROS topic

$ roslaunch ros_kafka_connector ros_publish.launch

After updating the launch file with the correct settings for your topic, you can test it by pubishing a json to your kafka topic using a kafka publisher. The String message json is simple: {'data': 'Hello world!'}

You could also send the message to the kafka server through python with the following script.

Install kafka library

$ pip install kafka-python

python script

from kafka import KafkaProducer
kafka_topic = 'test'
msg = 'Hello World!'
producer = KafkaProducer(bootstrap_servers="localhost:9092", value_serializer=lambda x: json.dumps(x).encode('ascii')) 
producer.send(kafka_topic, {'data': msg})          # 'data' is part of the string message definition

Publish to Kafka topic

$ roslaunch ros_kafka_connector kafka_publish.launch

To test this node you can simply type...

Terminal

$ roscore
$ rostopic pub -r 3 /test std_msgs/String "data: 'Hello World!'"

This will output the hello world at 3 hz to the "/test" ROS topic. To confirm this works you can open up another terminal and type in "rostopic echo /test" which should show you the same message is being published to ROS. This message should also be published to the Kafka topic.

ros-kafka-connector's People

Contributors

isakdiaz 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.