Git Product home page Git Product logo

ros_numpy's Introduction

ros_numpy

Tools for converting ROS messages to and from numpy arrays. Contains two functions:

  • arr = numpify(msg, ...) - try to get a numpy object from a message
  • msg = msgify(MessageType, arr, ...) - try and convert a numpy object to a message

Currently supports:

  • sensor_msgs.msg.PointCloud2 ↔ structured np.array:

    data = np.zeros(100, dtype=[
      ('x', np.float32),
      ('y', np.float32),
      ('vectors', np.float32, (3,))
    ])
    data['x'] = np.arange(100)
    data['y'] = data['x']*2
    data['vectors'] = np.arange(100)[:,np.newaxis]
    
    msg = ros_numpy.msgify(PointCloud2, data)
    data = ros_numpy.numpify(msg)
    
  • sensor_msgs.msg.Image ↔ 2/3-D np.array, similar to the function of cv_bridge, but without the dependency on cv2

  • nav_msgs.msg.OccupancyGridnp.ma.array

  • geometry.msg.Vector3 ↔ 1-D np.array. hom=True gives [x, y, z, 0]

  • geometry.msg.Point ↔ 1-D np.array. hom=True gives [x, y, z, 1]

  • geometry.msg.Quaternion ↔ 1-D np.array, [x, y, z, w]

  • geometry.msg.Transform ↔ 4×4 np.array, the homogeneous transformation matrix

  • geometry.msg.Pose ↔ 4×4 np.array, the homogeneous transformation matrix from the origin

Support for more types can be added with:

@ros_numpy.converts_to_numpy(SomeMessageClass)
def convert(my_msg):
    return np.array(...)

@ros_numpy.converts_from_numpy(SomeMessageClass)
def convert(my_array):
    return SomeMessageClass(...)

Any extra args or kwargs to numpify or msgify will be forwarded to your conversion function

Future work

  • Add simple conversions for:

    • geometry_msgs.msg.Inertia

ros_numpy's People

Contributors

awesomebytes avatar drsensor avatar eric-wieser avatar gstavrinos avatar mikaelarguedas avatar pierrickkoch avatar xaedes 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.