Code Monkey home page Code Monkey logo

ros_wild's Introduction

ros_wild wercker status

Wildcard Subscriber and Publisher for ROS (Python only).

Installation

$ sudo apt install ros-kinetic-ros-wild

or

$ cd /path/to/your/catkin_ws/src/
$ git clone https://github.com/yuma-m/ros_wild.git
$ cd ../
$ catkin_make

Usage

Example scripts are placed in example directory.

Command line

Echo multiple topics

$ rosrun ros_wild echo ".*_sensor"
---
topic: /ultrasound_sensor
type: sensor_msgs/Range

header:
  seq: 1
  stamp:
    secs: 1478776655
    nsecs:    143582
  frame_id: ultrasound_sensor
radiation_type: 0
field_of_view: 0.569999992847
min_range: 0.20000000298
max_range: 3.0
range: 0.600000023842
---
topic: /infrared_sensor
type: sensor_msgs/Range

header:
  seq: 2
  stamp:
    secs: 1478776656
    nsecs:    998511
  frame_id: infrared_sensor
radiation_type: 1
field_of_view: 0.00999999977648
min_range: 0.00999999977648
max_range: 1.0
range: 0.20000000298

Python

Wildcard Subscriber

>>> from ros_wild import Subscriber

# subscribe to all Log topics
>>> sub = Subscriber(r"/rosout.*")
>>> sub.subscribed_topics
['/rosout', '/rosout_agg']

# unsubscribe from all topics
>>> sub.unregister_all()
>>> sub.subscribed_topics
[]

# resubscribe to topics
>>> sub.reload_topics()
>>> sub.subscribed_topics
['/rosout', '/rosout_agg']

Register Callback

>>> from ros_wild import Subscriber
>>> from std_msgs.msg import Bool, String

>>> def callback_bool(msg):
>>>     print("bool is {}".format(msg.data))

>>> def callback_string(msg):
>>>     print("string is {}".format(msg.data))

# subscribe without callback
>>> sub = Subscriber(r".+")
>>> print("Subscribed topics are {}".format(sub.subscribed_topics))
Subscribed topics are ['/bool/01', '/rosout', 'rosout_agg', '/string/01']

# register callback
>>> sub.register_callback(Bool, callback_bool)
>>> sub.register_callback(String, callback_string)
>>> print("Topics with callback are {}".format(sub.topics_with_callback))
Topics with callaback are ['/bool/01', '/strings/01']

Wildcard Publisher

The code below will publish Log message to /rosout and /rosout_agg topics.

>>> import rospy
>>> from ros_wild import Publisher
>>> from rosgraph_msgs.msg import Log

# publish to all topics
>>> rospy.init_node("test")
>>> pub = Publisher(".*", queue_size=1)
>>> pub.published_topics
['/rosout', '/rosout_agg', '/tf', ... ]
>>> pub.publish(Log(msg="this is test message"))

Links

ros_wild's People

Contributors

yuma-m avatar

Stargazers

Clan avatar  avatar Chrissunny94 avatar Ato Araki avatar

Watchers

 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.