Code Monkey home page Code Monkey logo

rosprocessing's Introduction

ROSProcessing

ROSBridge client for Processing.

Installation

Just clone the repo to the libraries folder inside your Processing sketchbook and restart Processing.

Basic Usage

  1. Import the library

    import rosprocessing.*;
    
  2. Create a global variable for the main library class

    ROSProcessing rp; 
    
  3. Initialize the library and connect to rosbridge inside your setup()

    void setup() {
      ...
      rp = new ROSProcessing(this);
      rp.connect();
      ...
    }
    

    You can specify the hostname and port like this:

    rp = new ROSProcessing(this, "192.168.1.1", 8080);
    

    If not specified, "localhost" and port 9090 are used.

  4. Subscribe to your topics using the subscribe method (e.g. also in your setup()).

    rp.subscribe("/image", "newImage");   
    

    The arguments are the topic name and the name of the event callback to be called when new data arrive.

  5. Create a callback function that will receive the data and save it in a global variable.

    PImage pImage;
    void newImage(Image image) {
      pImage=image.toPImage(this);
    }
    

    The event function must take an argument of a class corresponding to the message type of the ROS topic. Currently implemented message classes are storred in the src/rosprocessing/messages folder. Sometimes, those message classes provide convenience functions for parsing the raw ROS data, as in the example above where we convert ROS data to a PImage.

  6. Draw!

    void draw() {
      if (pImage!=null)
        image(pImage,0,0);
    }
    

For additional features, see the example for now.

Example

You can find an example in the examples folder.

rosprocessing's People

Contributors

grauwald avatar pronobis avatar wedontplay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rosprocessing's Issues

Example for Publisher needed

Nice work so far.
I see from your examples how I implement a ros subscriber, but how can I publish something on a topic?

Publish to a topic

Hi, am I wrong or this library just allow to subscribe and receive messages from ROS?
I need to publish to a topic, but I did't find a function to do that (maybe just I don't get it).
If I am correct i'm going to implement an advertise and a publish function and i'll make a merge request probably next week.

Tx
Gabriele

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.