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:
35
46* ` arr = numpify(msg, ...) ` - try to get a numpy object from a message
57* ` msg = msgify(MessageType, arr, ...) ` - try and convert a numpy object to a message
68
79Currently supports:
810
911* ` sensor_msgs.msg.PointCloud2 ` &harr ; structured ` np.array ` :
10-
12+
1113 ``` python
1214 data = np.zeros(100 , dtype = [
1315 (' x' , np.float32),
@@ -17,12 +19,12 @@ Currently supports:
1719 data[' x' ] = np.arange(100 )
1820 data[' y' ] = data[' x' ]* 2
1921 data[' vectors' ] = np.arange(100 )[:,np.newaxis]
20-
21- msg = ros_numpy .msgify(PointCloud2, data)
22+
23+ msg = ros2_numpy .msgify(PointCloud2, data)
2224 ```
23-
25+
2426 ```
25- data = ros_numpy .numpify(msg)
27+ data = ros2_numpy .numpify(msg)
2628 ```
2729
2830* ` 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:
3638Support for more types can be added with:
3739
3840``` python
39- @ros_numpy .converts_to_numpy (SomeMessageClass)
41+ @ros2_numpy .converts_to_numpy (SomeMessageClass)
4042def convert (my_msg ):
4143 return np.array(... )
4244
43- @ros_numpy .converts_from_numpy (SomeMessageClass)
45+ @ros2_numpy .converts_from_numpy (SomeMessageClass)
4446def convert (my_array ):
4547 return SomeMessageClass(... )
4648```
0 commit comments