Coder Social home page Coder Social logo

rospy_websocker_client's Introduction

WebsocketROSClientPython

WebsocketROSClientPython is a lightweight ROS package and Python library to messaging between the machines with ROS via websocket. You can subscribe and publish and call service messages between rosbridge server and client.

Data is transmitted in JSON format and automatically converted into ROS messages using the library rospy_message_converter

Server: ROS --> Bridge: JSON <-- Client: ROS/MATLAB/UNITY

Support:

  • Publish
  • Subscribe (messages are immediately published in the specified topic)
  • Service (call only, the response didn't parse)

Note that this needs install:

sudo pip install websocket-client
sudo apt install ros-$ROS_DISTRO-rospy-message-converter
sudo apt install ros-$ROS_DISTRO-rosbridge-server

Stage: In the development

Usage

Init websocket client:

    from rospy_websocker_client import WebsocketROSClient as ros_ws
    ws_client = ros_ws('128.0.0.1', 9090) # ip, port, name of client
    ws_client.connect()

Disconnect:

    ws_client.disconnect()

Subscribe to topics from server:

    from geometry_msgs.msg import  PoseStamped
    # 1. The name of the topic server;
    # 2. The type of topic
    # 3. The name of the topic where to publish
    # 4. Frame rate: default = 0
    # 5. queue_length:  default = 0

    ws_client.subscribe('/position', PoseStamped(), '/position')

Publish to server:

    
    from std_msgs.msg import String
    msg = String()
    msg.data = "Test message"
    # 1. the name of the topic on server where to publish; 
    # 2. the message
    ws_client.publish("/client_topic",msg)

Call service from server

   # 1. the name of the service on server where to call;
   # 2. the service request message 
   ws_client.call_service('/ropic_of_service', srv_pub)

rospy_websocker_client's People

Contributors

gigaflopsis avatar

Stargazers

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