1
- # ros_numpy
2
- Tools for converting ROS messages to and from numpy arrays. Contains two functions:
1
+ # ros2_numpy
2
+ This project is a fork of [ ros_numpy] ( https://github.com/eric-wieser/ros_numpy )
3
+ to work with ROS 2. It provides tools for converting ROS messages to and from
4
+ numpy arrays. Contains two functions:
3
5
4
6
* ` arr = numpify(msg, ...) ` - try to get a numpy object from a message
5
7
* ` msg = msgify(MessageType, arr, ...) ` - try and convert a numpy object to a message
6
8
7
9
Currently supports:
8
10
9
11
* ` sensor_msgs.msg.PointCloud2 ` &harr ; structured ` np.array ` :
10
-
12
+
11
13
``` python
12
14
data = np.zeros(100 , dtype = [
13
15
(' x' , np.float32),
@@ -17,12 +19,12 @@ Currently supports:
17
19
data[' x' ] = np.arange(100 )
18
20
data[' y' ] = data[' x' ]* 2
19
21
data[' vectors' ] = np.arange(100 )[:,np.newaxis]
20
-
21
- msg = ros_numpy .msgify(PointCloud2, data)
22
+
23
+ msg = ros2_numpy .msgify(PointCloud2, data)
22
24
```
23
-
25
+
24
26
```
25
- data = ros_numpy .numpify(msg)
27
+ data = ros2_numpy .numpify(msg)
26
28
```
27
29
28
30
* ` sensor_msgs.msg.Image ` &harr ; 2/3-D ` np.array ` , similar to the function of ` cv_bridge ` , but without the dependency on ` cv2 `
@@ -36,11 +38,11 @@ Currently supports:
36
38
Support for more types can be added with:
37
39
38
40
``` python
39
- @ros_numpy .converts_to_numpy (SomeMessageClass)
41
+ @ros2_numpy .converts_to_numpy (SomeMessageClass)
40
42
def convert (my_msg ):
41
43
return np.array(... )
42
44
43
- @ros_numpy .converts_from_numpy (SomeMessageClass)
45
+ @ros2_numpy .converts_from_numpy (SomeMessageClass)
44
46
def convert (my_array ):
45
47
return SomeMessageClass(... )
46
48
```
0 commit comments