Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent publishing rate for sensors #166

Open
alonsollorente opened this issue Aug 13, 2024 · 4 comments
Open

Inconsistent publishing rate for sensors #166

alonsollorente opened this issue Aug 13, 2024 · 4 comments

Comments

@alonsollorente
Copy link

Hi everyone!

I hope you can help me with this problem that I'm having. I'm trying to broadcast sensory data in ROS2 and going through some difficulties.

Thank you in advance for helping me out! I let you with a brief description of my problem.

Description of the bug
There is an inconsistency in the publishing frequency of sensor data between ROS2 and Unity when using ros_tcp_endpoint. Despite setting the publishing rate to 10Hz for one LiDAR sensor and 100Hz for an IMU, the actual publishing rate observed is significantly lower and inconsistent, being in the case of the IMU around 35Hz. The ros2 topic hz /imu output can be seen:

image

To Reproduce
Steps to reproduce the behavior:

  • I'm using the set of sensors from UnitySensor, which uses ROS_TCP_Connector.
  • Setting from IMU and LiDAR:

image
image

Environment set up:

  • Unity Version: 2023.2.20f1
  • Ubuntu 22.04, ROS2 Humble
@RyodoTanaka
Copy link
Member

RyodoTanaka commented Aug 13, 2024

@alonsollorente
Thank you for updating the issue.
This issue is related to #156 (It is written in Japanese, but discussing same topic)
The main reason of this problem comes from using Update() function.
To fix this, we should use FixUpdate() function.
https://github.com/Field-Robotics-Japan/UnitySensors/blob/master/Assets/UnitySensorsROS/Runtime/Scripts/Publishers/RosMsgPublisher.cs#L39
https://github.com/Field-Robotics-Japan/UnitySensors/blob/master/Assets/UnitySensors/Runtime/Scripts/Sensors/IMU/IMUSensor.cs#L51

But, this problem is already fixed in develop branch.
Thus, please try to use develop branch.
Now, merging PR from develop into master is under development (#163)

@alonsollorente
Copy link
Author

alonsollorente commented Aug 13, 2024

Hi!

Thank you for the fast answer. I checked that the Update() function in the LiDAR publisher case is the same in the develop and master branch. I don't know if maybe I'm approaching it wrong...

Furthermore, I tried the project in the develop branch, and is still inconsistent in frequency for both sensors.

@RyodoTanaka
Copy link
Member

RyodoTanaka commented Aug 13, 2024

@alonsollorente

the Update() function in the LiDAR publisher case is the same in the develop.

Yes, you are right. It is still not fixed in develop branch about LiDAR Publisher.

I tried the project in the develop branch, and is still inconsistent in frequency for both sensors.

About this, I need to find the reason why especially for IMU sensors.
I think it takes a bit long time to fix. But if someone find the solution, comment it please.

@Bob-Eric
Copy link
Contributor

Hi there!
I have tried these sensors in both ROS1 and ROS2 and they work fine.
However, you have to be aware of the frame rate in Unity.
Currently it is not possible to publish sensors faster than the frame rate.

{F2949AC1-41AE-4560-B41F-48C1BF3B04B7} {8325D53A-8857-4213-BC92-33AA2162E3A1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants