• Stars
    star
    272
  • Rank 151,235 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tools for converting ROS messages to and from numpy arrays

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.OccupancyGrid ↔ np.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

More Repositories

1

numpy_ringbuffer

Ring-buffer implementation that thinly wraps a numpy array
Python
79
star
2

lean-matrix-cookbook

The matrix cookbook, proved in the Lean theorem prover
Lean
68
star
3

nanopb-arduino

Arduino stream wrappers for nanopb
C++
41
star
4

computercraft-github

A readonly github repository client for computercraft
Lua
28
star
5

packet-io

An arduino library for framing protocols, inspired by PacketSerial
C++
20
star
6

snakes

A game written in node.js, HTML5 canvas, and Socket.IO.
JavaScript
19
star
7

banking

Python scrapers for extracting bank statements from tesco, santander, and lloyds in the QIF format
Python
16
star
8

build-with-input

A plugin to improve the build system of sublime text
Python
10
star
9

lean-graded-rings

A formalization of graded rings in Lean, corresponding to a CICM 2022 submission
Lean
7
star
10

sublime-student-robotics

Student Robotics Build Script
Python
4
star
11

caius-rooms

The room balloting and information system for gonville and caius college
CSS
4
star
12

mbed-led-dot-matrix

C++
3
star
13

USACO-solutions

C++
3
star
14

perspective-undistort

Using opencv to remove perspective distortion of aerial photos
Python
3
star
15

Robocup-Junior-Soccer-2011

A repository for source code for the Robocup Junior Soccer competition
C#
3
star
16

2.12-robot

Final project for MIT's 2.12 - Intro to Robotics
MATLAB
2
star
17

rfw-manager

A bukkit plugin to make running RFW servers easier
Java
2
star
18

two.js

JavaScript
2
star
19

engineering-calendar

icalendar mangler for the Cambridge Engineering IA course. Now hosted by the department,
Python
2
star
20

Robocup-temp

Grabbed from beanstalkapp
Java
2
star
21

hungercraft

Java
2
star
22

ARC

2
star
23

raven-client

A python requests adapter to automatically login to the Cambridge University Raven Login
Python
2
star
24

sublime-bottle

A package for working with the bottle framework
Smarty
1
star
25

gpml

A git mirror of http://www.gaussianprocess.org/gpml/code/matlab/doc/
MATLAB
1
star
26

lean-multiple-inheritance

Lean
1
star
27

eric-wieser

1
star
28

generatorify

Convert a function taking a repeated callback to a generator that pauses at each callback
Python
1
star
29

codejam

Solutions to past codejam competitions. Never pushed before scoring is complete
Python
1
star
30

type_templating

C++-style templated types for python
Python
1
star
31

masters-thesis

TeX
1
star
32

mathlib-import-graph

An interactive viewer for the mathlib import graph
HTML
1
star