ROS-TCP-Connector
ROS-TCP-Connector copied to clipboard
Quality of service setting missing and laser scan (/scan) on ground level
Our robot uses quality of service 'RELIABILITY=VOLATILE' for the laser scan, but it needs to be changed to 'RELIABLE' to work with Unity. I couldn't find anywhere to configure it in Unity. Then, when it works, the laser scan is on ground-level. It should be a bit above it.
The global and local costmaps also don't align. This, plus the laser scan issue, makes me think it might be a problem with the /tf.
When I run the Nav2-SLAM-Example, everything is aligned and properly positioned (with the data from Unity's simulated robot).
Environment:
- Unity Version: 2021.3.14f1
- Unity machine OS + version: Ubuntu
- ROS machine OS + version: Docker image running ROS-galactic (osrf/ros:galactic-desktop)
- ROS–Unity communication: Docker container running ROS-TCP-Endpoint
In the following image, pink is the floor on Y=-1, laser scan are the colored dots, white dots are the point cloud (unrelated), and the costmap is the white+black-ink square (also looks weird).
Nav2-SLAM-Example has maps and laserscan properly aligned and positioned:
FIY, I just ran into the same issue, tried to work around it by changing the QoS in ros_tcp_endpoint/subscriber.py
to reliability=ReliabilityPolicy.BEST_EFFORT
. While that fixed the issue, paradoxically, it also fixed it when using the default ros_tcp_endpoint, so I'm not sure if it is really related to any QoS settings.
@jankolkmeier Hi, I am having the issue where there is incompatibility issue with Unity and ROS. The laser scanner driver that we are using uses BEST EFFORT, but unity apparently only supports RELIABLE. I tried looking into the subscriber.py to change the QoS, but i cant seem to find the line of code of:
reliability=ReliabilityPolicy
Do you mind double checking if that is still a valid solution?
Change the qos_profile in ros_tcp_endpoint/subscriber.py
like this:
qos_profile = QoSProfile(depth=queue_size, reliability=QoSReliabilityPolicy.BEST_EFFORT)
Hope this helps.
@KingKiger This is the subscriber.py script that is from Unity-Technologies/ROS-TCP-Endpoint repo, unless I am missing something or looking at the wrong place, i do not see the where is qos_profile
that you mentioned above. Or is this something i have to add somewhere?
# Copyright 2020 Unity Technologies
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import rospy
import socket
import re
from .communication import RosReceiver
from .client import ClientThread
class RosSubscriber(RosReceiver):
"""
Class to send messages outside of ROS network
"""
def __init__(self, topic, message_class, tcp_server, queue_size=10):
"""
Args:
topic: Topic name to publish messages to
message_class: The message class in catkin workspace
queue_size: Max number of entries to maintain in an outgoing queue
"""
strippedTopic = re.sub("[^A-Za-z0-9_]+", "", topic)
self.node_name = "{}_RosSubscriber".format(strippedTopic)
RosReceiver.__init__(self, self.node_name)
self.topic = topic
self.msg = message_class
self.tcp_server = tcp_server
self.queue_size = queue_size
# Start Subscriber listener function
self.sub = rospy.Subscriber(self.topic, self.msg, self.send)
def send(self, data):
"""
Connect to TCP endpoint on client and pass along message
Args:
data: message data to send outside of ROS network
Returns:
self.msg: The deserialize message
"""
self.tcp_server.send_unity_message(self.topic, data)
return self.msg
def unregister(self):
"""
Returns:
"""
if not self.sub is None:
self.sub.unregister()