Skip to content

Use Array to represent the field of array type in a message instead of TypedArray #399

@minggangw

Description

@minggangw

By landing f3bcddc, we achieved that enabling TypedArray to improve the performance when the message has a field which has the type of array. e.g. Image.msg, the data field

# This message contains an uncompressed image
# (0, 0) is at top-left corner of image

std_msgs/Header header # Header timestamp should be acquisition time of image
                             # Header frame_id should be optical frame of camera
                             # origin of frame should be optical center of cameara
                             # +x should point to the right in the image
                             # +y should point down in the image
                             # +z should point into to plane of the image
                             # If the frame_id here and the frame_id of the CameraInfo
                             # message associated with the image conflict
                             # the behavior is undefined

uint32 height                # image height, that is, number of rows
uint32 width                 # image width, that is, number of columns

# The legal values for encoding are in file src/image_encodings.cpp
# If you want to standardize a new string format, join
# ros-[email protected] and send an email proposing a new encoding.

string encoding       # Encoding of pixels -- channel meaning, ordering, size
                      # taken from the list of strings in include/sensor_msgs/image_encodings.h

uint8 is_bigendian    # is this data bigendian?
uint32 step           # Full row length in bytes
uint8[] data          # actual matrix data, size is (step * rows)

We can support the following types of array by leveraging the TypedArray, see here

Here is another story, as the rclnodejs is used as the backend of ros2-web-bridge and the format of the data transferring from the web browser is JSON over websockets. The thing is that the JSON does not have a representation of TypedArray, so you can't get the object back from JSON string. We found this issue when testing the unit test and reported an issue RobotWebTools/ros2-web-bridge#98

In this case, we want to use the normal Array to manipulate the data of array type, also, we have to be aware of the tremendous performance loss.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions