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

Do expensive publishing operation in a seperate thread to resolve bottleneck #382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Assets/AWSIM/Scripts/Sensors/Camera/CameraRos2Publisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using ROS2;
using System.Threading.Tasks;

namespace AWSIM
{
Expand Down Expand Up @@ -84,9 +85,12 @@ void UpdateMessagesAndPublish(CameraSensor.OutputData outputData)
imageMsg.Header.Stamp = timeMsg;
cameraInfoMsg.Header.Stamp = timeMsg;


// Publish to ROS2
imagePublisher.Publish(imageMsg);
cameraInfoPublisher.Publish(cameraInfoMsg);
var taskBoth = Task.Run(() => {
imagePublisher.Publish(imageMsg);
cameraInfoPublisher.Publish(cameraInfoMsg);
});
}

private void UpdateImageMsg(CameraSensor.OutputData data)
Expand Down