Field-Robotics-Japan / UnitySensors

ROS/ROS2 enabled Sensor models (Assets) on Unity
Apache License 2.0
191 stars 28 forks source link

Commonisation of serializers and publishers. #148

Closed Autumn60 closed 2 days ago

Autumn60 commented 4 months ago

Notice: This PR is less backward compatible.

Before merging, [master_2.x.x] branch must be created from the current [master] branch.

en

Commonisation of serializers and publishers

All "Sensor" classes, except a few such as TF, now have interface to the data provided by each sensor. "Serializer" classes and "Publisher" classes are now dependent on the interface of the corresponding data, not the "Sensor" classes.

This change allows "Sensor"s that provide common data to send data with a common "Serializer" and "Publisher" scripts. Also, scripts that are not "Sensor" can now be used as data sources from Serializer and Publisher if they have a corresponding interface.

PointCloud2 data serialisation method change

Change from a method using JobSystem to a method using memory copy.

RGBDCamera

RGBD camera with PointXYZRGB point cloud output implemented.

jp

SerializerPublisherの共通化

TFなどの一部を除くすべての "Sensor "クラスは、各センサーが提供するデータへのインターフェイスを持つようになりました。 「Serializer "クラスと "Publisher "クラスは、"Sensor "クラスではなく、対応するデータのインターフェースに依存するようになりました。

この変更により、共通のデータを提供する "Sensor "は、共通の "Serializer "と "Publisher "スクリプトでデータを送信できるようになりました。 また、"Sensor "ではないスクリプトでも、対応するインターフェイスがあれば、"Serializer "や "Publisher "のデータソースとして使用できるようになりました。

PointCloud2データのmsg化方法の変更

JobSystemを用いる方法から、メモリコピーを用いる方法に変更しました。 ROS->Unityの座標変換は、PointCloud2のPointFieldの順番を入れ替えることと、JobSystemを用いてx軸(ROSではy軸)を入れ替えることで実現しました。 可読性が酷いことになっていますが、 各点の4 byte 目に128を足す = 各点の1つ目の4 byte型(float)の1 bit 目を反転させる = 各点のxの値を反転させる 処理をしています。

RGBDカメラ復活

実装を見直したことで、RGBDカメラが再び実装されました。

RyodoTanaka commented 4 months ago

@Autumn60 Thank you for your PR. To check this PR merge, please tell us the list of confirmation for normal works.

Autumn60 commented 4 months ago

@RyodoTanaka I will create an integrated demo scene to provide confirmation.

RyodoTanaka commented 2 days ago

@Autumn60 I think this PR should be merged without the examples. Otherwise, this PR will be bigger and bigger.

Thus, I will merge this PR.