Giter VIP home page Giter VIP logo

ros-tcp-endpoint's Introduction

ROS TCP Endpoint

License Version ROS ROS


We're currently working on lots of things! Please take a short moment fill out our survey to help us identify what products and packages to build next.


Introduction

ROS package used to create an endpoint to accept ROS messages sent from a Unity scene. This ROS package works in tandem with the ROS TCP Connector Unity package.

Instructions and examples on how to use this ROS package can be found on the Unity Robotics Hub repository.

Community and Feedback

The Unity Robotics projects are open-source and we encourage and welcome contributions. If you wish to contribute, be sure to review our contribution guidelines and code of conduct.

Support

For questions or discussions about Unity Robotics package installations or how to best set up and integrate your robotics projects, please create a new thread on the Unity Robotics forum and make sure to include as much detail as possible.

For feature requests, bugs, or other issues, please file a GitHub issue using the provided templates and the Robotics team will investigate as soon as possible.

For any other questions or feedback, connect directly with the Robotics team at [email protected].

License

Apache License 2.0

ros-tcp-endpoint's People

Contributors

at669 avatar hyounesy avatar lauriecheers-unity avatar mpinol avatar mrpropellers avatar p3te avatar peifeng-unity avatar prothen avatar sdiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ros-tcp-endpoint's Issues

Importing ROS-TCP-Connector from git URL in Package Manager results in package not found.

I am using Unity 2020.2.1f1 and using the following URL as directed here (https://github.com/Unity-Technologies/Unity-Robotics-Hub/blob/dev/tutorials/quick_setup.md): https://github.com/Unity-Technologies/ROS-TCP-Connector.git

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/ROS-TCP-Endpoint.git]: [https://github.com/Unity-Technologies/ROS-TCP-Endpoint.git] does not point to a valid package repository. No package manifest was found. Verify the repository URL and make sure the package is located in the root folder of the repository. [NotFound]. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()


Please note, adding the URDF-Importer through the same method worked without issue: https://github.com/Unity-Technologies/URDF-Importer.git

/usr/bin/env: ‘python’: No such file or directory

Describe the bug
When I try to launch the endpoint, I get an error "/usr/bin/env: ‘python’: No such file or directory" and the process dies.

I am not familiar with python, but eventually figured out that the "shebang line" in the default_server_endpoint.py script is causing the issue. A common problem for shebang related issues seems to be with UNIX line endings, but even after applying the "dos2unix" command on the script file, the problem still persisted.

To Reproduce
Steps to reproduce the behavior:

  1. Setup the ROS TCP Endpoint package in the catkin workspace
  2. Launch the "endpoint.launch" Launch-File

Console logs / stack traces

roslaunch src/ros_tcp_endpoint/launch/endpoint.launch 
... logging to /home/ilmu011/.ros/log/1c302e54-1a46-11ed-b94a-d1992999f350/roslaunch-ubuntu20-19246.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu20:36939/

SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.15.14
 * /unity_endpoint/tcp_ip: 0.0.0.0
 * /unity_endpoint/tcp_port: 10000

NODES
  /
    unity_endpoint (ros_tcp_endpoint/default_server_endpoint.py)

ROS_MASTER_URI=http://localhost:11311

process[unity_endpoint-1]: started with pid [19260]
/usr/bin/env: ‘python’: No such file or directory
[unity_endpoint-1] process has died [pid 19260, exit code 127, cmd /home/ilmu011/Desktop/fusionws/src/ros_tcp_endpoint/src/ros_tcp_endpoint/default_server_endpoint.py __name:=unity_endpoint __log:=/home/ilmu011/.ros/log/1c302e54-1a46-11ed-b94a-d1992999f350/unity_endpoint-1.log].
log file: /home/ilmu011/.ros/log/1c302e54-1a46-11ed-b94a-d1992999f350/unity_endpoint-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done

Expected behavior
It should work

Environment:

  • Unity Version: (should be irrelevant, but it's 2021.3.4f1)
  • Unity machine OS + version: Ubuntu 20.04
  • ROS machine OS + version: Ubuntu 20.04, ROS Noetic
  • ROS–Unity communication: (none yet... also not using docker)
  • Branch or version: main

QoS other than default not supported

Describe the bug

I can't subscribe to topics which have QoS profile other than the default one.
For example if I publish a topic with QoS Sensor Data, the endpoint subscriber says it can't receive any data as the qos profiles are not compatible.

To Reproduce
Publish data with QoS Sensor Data
Try to receive data with endpoint

Console logs / stack traces
offering incompatible QoS. No messages will be received from it. Last incompatible policy: RELIABILITY

Expected behavior
Data is received and sent to unity.

Environment (please complete the following information, where applicable):

  • Unity Version: Unity 2020.3.10f1
  • Unity machine OS + version: Ubuntu 20.04
  • ROS machine OS + version: Ubuntu 20.04, ros2 galactic
  • Branch or version: ROS2v0.6.0

Docker container memory usage increases with time, possible memory leak

Describe the bug
When the Unity client connects, and starts subscribing to a ROS2 topic, the ROS-TCP-ENDPOINT docker container memory usage starts to go up. Container memory usage increases only if the client is connected and the topic is being subscibed to. Once the client disconnects or there is no more ros2 messages being published, the memory usage stays the same.

Console logs / stack traces
No errors or anything out of the ordinary in either ROS-TCP-Endpoint or ROS-TCP-Connector logs.

Expected behavior
Container memory usage should not increase with time

Screenshots
image (3)

Environment:

  • Unity Version: Unity 2021.1.17f1
  • Unity machine OS + version: Windows 11, Windows 10 & Android 11
  • ROS machine OS + version: Ubuntu 20.04 ROS Foxy
  • ROS–Unity communication: Docker (Running on either Ubuntu 20.04 host or Windows 11 host)
  • ROS-TCP-Connector version: both v0.6.0 and v. 0.5.0
  • ROS-TCP-Endpoint branch: both dev-ros2 and main-ros2

Additional context
Used msg packages: ros built-in messages, geographic_msgs, unique_identifier_msgs, and a custom message type.
Only 1 topic.

When I publish a jpeg image to ROS I receive this error

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Console logs / stack traces
Please wrap in triple backticks (```) to make it easier to read.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots or videos to help explain your problem.

Environment (please complete the following information, where applicable):

  • Unity Version: [e.g. Unity 2020.2.0f1]
  • Unity machine OS + version: [e.g. Windows 10]
  • ROS machine OS + version: [e.g. Ubuntu 18.04, ROS Noetic]
  • ROS–Unity communication: [e.g. Docker]
  • Branch or version: [e.g. v0.2.0]

Additional context
Add any other context about the problem here.

Why are parameters like ROS_IP global?

self.tcp_ip = rospy.get_param("/ROS_IP")

ROS_IP and ROS_TCP_PORT are global ROS parameters.
So they are expected to be set directly as /ROS_IP.
I think it would be cleaner if these parameters were privat/local.
In this way the global ROS workspace would not be polluted.
Other nodes might like to have a different ROS_IP and then they would be in conflict.

Maybe also the ROS in the names ROS_IP and ROS_TCP_PORT is misleading.
Because it is the IP and PORT where somebody else from outside can connect to over TCP and not with ROS, or?

Upgrade from 0.6 to 0.7 broke Python version

I'm using ROS1 Noetic, which uses Python 3.8.

The shebang call at the top of default_server_endpoint.py has the line:

#!/usr/bin/env python

This causes rosrun to execute the python script using python2, which is incorrect. It needs to be changed to this shebang in all python files:

#!/usr/bin/env python3

Need a "Subscribe" override that the callback function can know which topic the message is arrived from

I have to subscribe more than 2 nodes at once with the same type of message.

_ros.Subscribe<PointCloud2>(topicName1, GeneratePointCloud);
_ros.Subscribe<PointCloud2>(topicName2, GeneratePointCloud);
_ros.Subscribe<PointCloud2>(topicName3, GeneratePointCloud);

GeneratePointCloud(PointCloud2 message)
{
    ~~~
}

Each generated pointCloud needs to know which topic it is from. But because there is no parameter in the CallbackFunction that describes the topic, I have to make different callback functions for each different topics doing the same thing.

So the best thing that I think is making an override of Subscribe that has the parameters like this:
Subscribe(string topic, Callback<T, string topic>);

P.S.
I want to contribute on the ROSConnection.dll to test it. Is it possible for me to look into the codes and modify it? I'll just fork it and give some pull requests

Open File Leak

Describe the bug
So I was running my simulator in a stop start fashion for a while with the ROS_TCP_Endpoint running in the background and after a while I noticed some additional errors in the console:
[ERROR] [1652857378.828228]: Exception: [Errno 24] Too many open files

To Reproduce
Steps to reproduce the behavior:

  1. Register publishers & subscribers, a lot

Console logs / stack traces

[INFO] [1652857997.679180]: Disconnected from 127.0.0.1
[INFO] [1652857999.689510]: Connection from 127.0.0.1
[INFO] [1652857999.690933]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._TFMessage.TFMessage'>) OK
[ERROR] [1652857999.691834]: Exception: [Errno 24] Too many open files
[INFO] [1652857999.692657]: Disconnected from 127.0.0.1
[INFO] [1652858000.695326]: Connection from 127.0.0.1
[INFO] [1652858000.702791]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._TFMessage.TFMessage'>) OK
[ERROR] [1652858000.703683]: Exception: [Errno 24] Too many open files
{Repeat Every Two Seconds Indefinitely}

Environment (please complete the following information, where applicable):

  • Unity Version: [e.g. Unity 2021.2.18f1]
  • Unity machine OS + version: [e.g. Ubuntu 18.04]
  • ROS machine OS + version: [e.g. Ubuntu 18.04, ROS Melodic]
  • ROS–Unity communication: [e.g. Bare Metal]
  • Branch or version: [e.g. v idk lol probably a little old]

Additional context
It's possible that it's been encountered before and been fixed (I am a little behind on the version at the moment). What I might do is update my version of ROS_TCP_Connector and ROS_TCP_Endpoint and see if I can still replicate the issue.

Potential memory leak when creating Unity subscriber

Describe the bug
When registering subscriber from Unity to a ROS message e.g.

ROS.Subscribe<ImageMsg>("/hmd/rgb/image_raw", HandleGazeboCameraMsg);

memory usage of default_server_endpoint.py rises rapidly and will not release until ROS is shutdown via CTRL-C.

To Reproduce
Steps to reproduce the behavior:

  1. Launch the default_server_endpoint.py via roslaunch i.e roslaunch ros_tcp_endpoint endpoint.launch along with other topics you want Unity to be able to access, my case were images from a Gazebo simulated camera.
  2. Start a ROS connection in Unity via a script and register a subscriber i.e.
// [Relevant using statements]

public class ROSManager : MonoBehaviour
{
    public ROSConnection ROS;
    public Camera HeadMountDisplay;

    // Start is called before the first frame update
    void Start()
    {
        // connect to ROS, works
        ROS = ROSConnection.GetOrCreateInstance();
        
        // publish to ROS, works
        ROS.RegisterPublisher<PoseMsg>("/unity/hmd_pose");    
        
        // shortly after subscribing, RAM goes skyhigh and never came back down...
        ROS.Subscribe<ImageMsg>("/hmd/rgb/image_raw", HandleGazeboCameraMsg); 
    }

    // Update is called once per frame
    void Update()
    {
        // works as expected
        var hmd_pose = new PoseMsg();
        hmd_pose.position = HeadMountDisplay.transform.position.To<FLU>();
        hmd_pose.orientation = HeadMountDisplay.transform.rotation.To<FLU>();
        ROS.Publish("/unity/hmd_pose", hmd_pose);
    }

    void HandleGazeboCameraMsg(ImageMsg img_msg)
    {
        // does not matter if there is something running here
    }
}
  1. See RAM goes up rapidly, does not get clean up.

Console logs / stack traces
Unity console log did not report anything. I have attached ROS logs as additional information.
ROS-log-ff137296-c503-11ec-bb7b-e4b97af38577.zip

Expected behavior
RAM usage should go up since there is active communication between the two, assuming message encoding/decoding matters, but not at that rate.

Screenshots
Peek 2022-04-25 20-56

Environment (please complete the following information, where applicable):
Original issue first noticed while using Docker on WSL on Windows 11. I assumed it has something to do with WSL so I ported my code to a different machine running Ubuntu 20.04, same result.

  • Unity Version: 2020.3.33f1 and 2021.3.1f1
  • Unity machine OS + version: Windows 11 10.0.22000 Build 22000
  • ROS machine OS + version:
    • Windows 11 10.0.22000 Build 22000
    • Ubuntu 20.04 kernel 5.13.0-40-generic
  • ROS–Unity communication:
    • ROS on Ubuntu 20.04 Docker on WSL, Docker IP connection
    • ROS directly on WSL, localhost connection
    • ROS on Ubuntu 20.04 Docker on Ubuntu 20.04 across LAN, Unity remains on Windows machine
    • ROS directly on Ubuntu 20.04 across LAN, Unity remains on Windows machine
  • Branch or version: tried 0.7.0 and 0.6.0, did not go back further since the syntax seems to have been updated.

Additional context
As long as there is nothing published on the topic, this issue doesn't happen i.e. subscribing to an empty /joint_states topic does not increase RAM usage. I remember distinctively having to declare publisher/subscriber way back when but can't seem to find the reference, I'll add once I found it. Found the old example in Unity-Robotics-Hub v0.5.0. It seems the newer syntax has made this obsolete.

It might be related to #139, #124, and #19. As far as I can tell there is no noticable differences between swapping out any version of either ROS-TCP-Endpoint or ROS-TCP-Connector.

failed to deserialize ROS message: Fast CDR exception deserializing message of type std_srvs::srv::dds_::Empty_Response_.

Hi,

I am creating a ROS Service in Unity Simulator of type std_srvs/Empty.

I am able to call the service, service is doing the intended work.

But when I return the empty response, I get the following error:

The following exception was never retrieved: failed to deserialize ROS message: Fast CDR exception deserializing message of type std_srvs::srv::dds_::Empty_Response_., at /home/user/ros2_humble/src/ros2/rmw_fastrtps/rmw_fastrtps_cpp/src/type_support_common.cpp:118

can anyone help me with what could be going wrong?

ROS_TCP_ENDPOINT fresh out of the box build can't find python

Describe the bug
ROS_TCP_ENDPOINT is not referencing the correct version of python on my system when built fresh out of the box (Python 3.8). The ROS beginner_tutorial package, which I just built, works fine and is able to launch python. The problem is not my development environment and has something to do with the CMakeLists.txt build file in ROS_TCP_ENDPOINT.

To Reproduce
Steps to reproduce the behavior:

  1. source /opt/ros/noetic/setup.bash
  2. rosparam set ROS_IP 172.24.147.215
  3. rosparam set ROS_TCP_PORT 10000
  4. cd cat*
  5. . ~/catkin_ws/devel/setup.bash
  6. rosrun ros_tcp_endpoint default_server_endpoint.py
    /usr/bin/env: ‘python’: No such file or directory

Expected behavior
ROS_TCP_ENDPOINT should have launched correctly. Instead there is an error because python can't be found.

Environment:

  • ROS machine OS + version: Ubuntu 18.04, ROS Noetic
  • Branch or version: ROS v1.15.13
  • ROS_TCP_ENDPOINT v0.6.0

From ROS_TCP_ENDPOINT:
image

From ROS1 Tutorial:
image

Odd issue where services work but subscribers do not

I'm trying to create a simple JointState subscriber and keep running into the Exception timed out error when sending the message from ROS on VMWare to Unity. However, I created a service prior to this where I request motion plans from ROS, and that works fine. The Ubuntu VM instance is using a Bridged adapter and I've created a rule to allow incoming connections on Windows so I'm a bit baffled about how to deal with this. On Unity, I see the message that the server is listening on the right IP and even the handshake between the two is received in the ROS node. Any advice would be appreciated. Thanks!

EDIT: I also tried a host-only adapter but the same issue persists. I can publish from Unity to ROS but cannot receive messages, but this time the error is different:
Exception [Errno 111] Connection refused.

Directory structure is a bit weird

Directory structure is a bit weird

As far as I can see this repository is meant to have a ROS package for other projects (catkin workspaces) to import. In general, I've seen that packages have got to have the following structured define in this link.

Right now, the tcp_endpoint package is a little weird, where within src we can find "duplicated" files in a wrong location. These files are:

  1. CMakeLists.txt
  2. package.xml
  3. setup.py

Are these files in there for any special reason? It seems to me that those are unused by ROS and they could be safely deleted.

Wrong usage of mock.called_once

In several test files the called_once method of mock is used without the required parentheses ().
In this way the called_once statements have no effect, the tests seem to succeed, but actually nothing is tested.

See for example:

mock_import_module.assert_called_once

In

mock_sys_modules.assert_called_once
there is a further bug, besides the missing parentheses.
It should not be checked that the mock is called_once but its getitem method.

Allow creating debian package

Is your feature request related to a problem? Please describe.
When deploying a setup, it's very useful to be allow to directly use the package as a debian package. It gives precise control of the version that is currently used and allow dependent packages to install it automatically if the debian package is uploaded to an APT repository and the package is listed in some rosdep yaml file.

Describe the solution you'd like
The package is almost ready to allow you create a working debian package of it using for example python-bloom tool.
Four changes need to be apply:

  1. Add installs to CMakeLists.txt to install launch, config, requirements.txt and scripts:
   install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
   install(DIRECTORY config/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config)

   install(FILES requirements.txt DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
   catkin_install_python(PROGRAMS  scripts/<script_1>
                                   scripts/<script_2>
                                   scripts/<script_3>
                                   scripts/<script_4>
                                   scripts/<script_5>
............................................................
                                   setup.py
                                  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}

  )
  1. Add "std_msgs" ROS package and python packages to package.xml
<exec_depend>std_msgs</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>python3-pip</exec_depend>
<exec_depend>python3-venv</exec_depend>
<exec_depend>virtualenv</exec_depend>
  1. Add a postinst file to automatically create the python virtual environment: The content will depend on the python or ROS versions that you want to support, but the basic structure could be the following (valid for ROS Noetic):
## Detect ROS version or if both ROS1 and ROS2 are installed and get the ros path <ros_path>. 
  cd <ros_path>/share/ros_tcp_endpoint
  python3 -m venv venv_tcp_endpoint > /dev/null
  sudo chown -R $(whoami) venv_tcp_endpoint
  source venv_tcp_endpoint/bin/activate
  pip3 install --upgrade pip
  pip3 install wheel
  pip3 install -r requirements.txt --no-cache-dir
  deactivate
  1. Configure launch to run scripts under the virtual environment: This is the most relevant change. Instead of manually activating the python virtual environment in the running console, it's necessary to automatically run the scripts with the virtual environment. For that purpose what I do right now with other packages is to create a top running generic script called for example default_server_endpoint_script.py
#!/usr/bin/env python

import os
import subprocess
import sys
from time import sleep

def is_venv():
    return (hasattr(sys, 'real_prefix') or
            (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))

arg='--venv'

args = sys.argv[1:]

path_to_venv = args[args.index(arg) + 1].rstrip('/')

if not is_venv():
    python_bin = path_to_venv + "/bin/python"
else:
    python_bin = sys.executable

dirname, filename = os.path.split(os.path.abspath(__file__))
script_file = dirname + "/default_server_endpoint.py"

try:
    s = subprocess.Popen([python_bin, script_file] + args)
    return_node = s.wait()
    exit(return_node)

except KeyboardInterrupt:

    while s.poll() is None:
        sleep(5)

    return_node = s.wait()
    exit(return_node)

It implies also changing the way the node is executed in the launch:

<launch>
    <rosparam file="$(find ros_tcp_endpoint)/config/params.yaml" command="load"/>
    <node name="server_endpoint" pkg="ros_tcp_endpoint" type="default_server_endpoint_script.py" args="--venv  $(find ros_tcp_endpoint)/venv_tcp_endpoint --wait" output="screen" respawn="true" />
</launch>
  1. Optionally add a postrm file to delete the virtual environement after removing the package with apt remove command:
#!/bin/bash

if [ "$1" != "upgrade" ] ; then
    # GET ROS PACKAGE PATH 
    path="/opt/ros/<ROSDISTRO>/share/ros_tcp_endpoint"
    echo "Removing virtual enviroment files..."
    sudo rm -rf $path
    echo "Virtual enviroment removed in $path"

fi

Sorry because it's a little bit long but I think that this are the only necessary changes. I can create also a pull request with the changes.

Describe alternatives you've considered

Additional context
Add any other context or screenshots about the feature request here.

Process exit, rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested

Describe the bug
Endpoint process exit with error:
rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested

To Reproduce

  1. boot ROS-TCP-Endpoint node (ROS2)
  2. try to connect and disconnect from unity client several times
  3. Endpoint process exited with error
  4. See error

Console logs / stack traces
[INFO] [1652075356.407162168] [UnityEndpoint]: Disconnected from 192.168.8.166
[INFO] [1652076762.672048998] [UnityEndpoint]: Connection from 192.168.8.166
[INFO] [1652076763.037987192] [UnityEndpoint]: RegisterSubscriber(/image2, <class 'sensor_msgs.msg._compressed_image.CompressedImage'>) OK
[INFO] [1652076763.106981882] [UnityEndpoint]: RegisterSubscriber(/imagez, <class 'sensor_msgs.msg._compressed_image.CompressedImage'>) OK
The following exception was never retrieved: 'NoneType' object has no attribute 'put'
[INFO] [1652076763.602603903] [UnityEndpoint]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._tf_message.TFMessage'>) OK
Traceback (most recent call last):
File "/home/hee/ros2_galactic/install/ros_tcp_endpoint/lib/ros_tcp_endpoint/default_server_endpoint", line 33, in
sys.exit(load_entry_point('ros-tcp-endpoint', 'console_scripts', 'default_server_endpoint')())
File "/home/hee/ros2_galactic/build/ros_tcp_endpoint/ros_tcp_endpoint/default_server_endpoint.py", line 14, in main
tcp_server.setup_executor()
File "/home/hee/ros2_galactic/build/ros_tcp_endpoint/ros_tcp_endpoint/server.py", line 177, in setup_executor
executor.spin()
File "/home/hee//ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/executors.py", line 279, in spin
self.spin_once()
File "/home/hee/ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/executors.py", line 757, in spin_once
self._spin_once_impl(timeout_sec)
File "/home/hee/ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/executors.py", line 744, in _spin_once_impl
timeout_sec, None, wait_condition)
File "/home/hee/ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/executors.py", line 690, in wait_for_ready_callbacks
return next(self._cb_iter)
File "/home/hee/ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/executors.py", line 585, in _wait_for_ready_callbacks
waitable.add_to_wait_set(wait_set)
File "/home/hee/ros2_galactic/install/rclpy/lib/python3.6/site-packages/rclpy/qos_event.py", line 114, in add_to_wait_set
with self.__event:
rclpy._rclpy_pybind11.InvalidHandle: cannot use Destroyable because destruction was requested

Expected behavior
Endpoint process should not exit

Environment (please complete the following information, where applicable):

  • Unity Version: [e.g. Unity 2022.1]
  • Unity machine OS + version: [Windows 10]
  • Unity machine OS + version: [Android 11]
  • ROS machine OS + version: [Ubuntu 18.04, ROS2 galactic]
  • ROS–Unity communication: [TCP, public internet]
  • Branch or version: [e.g. v0.7.0]

Expose the queue_size functionality in the RegisterSubscriber sys_command

Is your feature request related to a problem? Please describe.
In some rooms we have a weak Wifi connection between Unity and ROS. When receiving data from ROS this can have the effect, that we receive very old data, as the RosSubscriber has an infinite buffer.
Because of this, I would like to be able to set the queue_size parameter when calling the RegisterSubscriber sys_command.
This is similar to #82, where this feature was requested for the publisher.
So e.g. I could set the queue_size=1 for data where I'm just interested in in last message. This would save a lot of bandwidth potentially.

Describe the solution you'd like
I guess the solution is the same as for #82, we just need a way to pipe the queue_size parameter from unity to SysCommand/RosSubscriber/rospy.Subscriber

Method to know if a service server on ROS side is up and ready

Is your feature request related to a problem? Please describe.
There doesn't seem to be a method in ROS TCP Endpoint / Connector to check if a service server on ROS side is ready to use so I can send a request from unity side properly.

Describe the solution you'd like

  • Add a method equivalent to wait_for_service of rclpy
  • Or add a method to know if a service server on ROS side is ready or not from Unity side
  • Or add a method to list service servers on ROS side

Describe alternatives you've considered

  • Send requests to service server without knowing if it's ready or not.
  • Create a new publisher on ROS side to notify unity side that a service server is up and ready.

Additional context
I'm using ROS2 Galactic, and I don't understand enough about the compatibility with ROS1.

implement ROS-TCP-ENDPOINT with C++

I'm trying to rewrite this module with C++ as this python project runs with high and unsteady cpu resource. have you ever considered this thought before? It looks like I'm facing the problem of dynamically deserialize ros2 msg or srv class. Any good suggestion for this? thanks.

ROS2 windows error : CMake Error at CMakeLists.txt:4 (find_package)

D:\ros2\ROS-TCP-Endpoint>colcon build
Starting >>> ros_tcp_endpoint
--- stderr: ros_tcp_endpoint
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

CMake Error at CMakeLists.txt:4 (find_package):
By not providing "Findcatkin.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "catkin", but
CMake did not find one.

Could not find a package configuration file provided by "catkin" with any
of the following names:

catkinConfig.cmake
catkin-config.cmake

Add the installation prefix of "catkin" to CMAKE_PREFIX_PATH or set
"catkin_DIR" to a directory containing one of the above files. If "catkin"
provides a separate development package or SDK, be sure it has been
installed.


Failed <<< ros_tcp_endpoint [14.7s, exited with code 1]

Summary: 0 packages finished [15.1s]
1 package failed: ros_tcp_endpoint
1 package had stderr output: ros_tcp_endpoint

TCPServer Memory Leak

I've noticed a memory leak that occurs whilst running.

I've not verified what the source of the problem, but I think it has to do with the following code:
RosTCPServer.py, line 51:
`

    threads = []
    while True:
        tcp_server.listen(self.connections)

        (conn, (ip, port)) = tcp_server.accept()
        new_thread = ClientThread(conn, self, ip, port)
        new_thread.start()
        threads.append(new_thread)

    for t in threads:
        t.join()`

I believe the problem is that each published message opens a new TCP connection, starting a new thread which is appended to a list of threads, but they are never being removed until the program has stopped.
Also I'm not sure how the thread joins are ever called when they are outside of a 'while True:'

Publishers / subscribers are never closed when connection closes

Describe the bug
If I connect to the endpoint via the Unity player, create subscribers/publishers, and then close the connection (i.e by stopping Unity), the subscribers/publishers are never destroyed and remain in the list of ros2 topic list and ros2 node list.

To Reproduce
Steps to reproduce the behavior:

  1. Launch Unity
  2. Launch docker container with endpoint
  3. Click play in Unity with scripts that register publishers/subscribers
  4. ros2 topic list and ros2 node list show correct subscribers/publishers
  5. Stop Unity editor execution
  6. ros2 topic list and ros2 node list still show subscribers/publishers, despite the log message
    [INFO] [1649729856.926835838] [UnityEndpoint]: Disconnected from 172.17.0.1

Console logs / stack traces
Docker container endpoint

root@0c49719e8970:/home/dev_ws# ros2 run ros_tcp_endpoint default_server_endpoint --ros-args -p ROS_IP:=0.0.0.0
[INFO] [1649731919.301293293] [UnityEndpoint]: Starting server on 0.0.0.0:10000
[INFO] [1649731924.108205420] [UnityEndpoint]: Connection from 172.17.0.1
[INFO] [1649731924.260963087] [UnityEndpoint]: RegisterSubscriber(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[INFO] [1649731924.278215629] [UnityEndpoint]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._tf_message.TFMessage'>) OK
[INFO] [1649731924.287839920] [UnityEndpoint]: RegisterPublisher(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[INFO] [1649731924.302599337] [UnityEndpoint]: RegisterPublisher(/pose_stamped, <class 'geometry_msgs.msg._pose_stamped.PoseStamped'>) OK
[WARN] [1649731924.304394170] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[INFO] [1649731924.319359004] [UnityEndpoint]: RegisterPublisher(/cmd_vel, <class 'geometry_msgs.msg._twist.Twist'>) OK
[WARN] [1649731924.321670712] [rcl.logging_rosout]: Publisher already registered for provided node name. If this is due to multiple nodes with the same name then all logs for that logger name will go out over the existing publisher. As soon as any node with that name is destructed it will unregister the publisher, preventing any further logs for that name from being published on the rosout topic.
[INFO] [1649731924.341157712] [UnityEndpoint]: RegisterPublisher(/pose_stamped, <class 'geometry_msgs.msg._pose_stamped.PoseStamped'>) OK
[ERROR] [1649731932.677630258] [UnityEndpoint]: Exception: No more data available
[INFO] [1649731932.679670758] [UnityEndpoint]: Disconnected from 172.17.0.1

Environment (please complete the following information, where applicable):

  • Unity Version: [e.g. Unity 2021.2.19f1]
  • Unity machine OS + version: Mac Montery (M1)
  • ROS machine OS + version: Ubuntu 20.04 Foxy
  • ROS–Unity communication: Docker
  • Branch or version: 0.7.0

CameraInfo Serialisation Bug

When sending a CameraInfo message to ROS, I've found it doesn't serialise and deserialise correctly.
The issue is that a number of the arrays are defined as fixed length in ROS but when Unity Serialises them, it serialises the length of the array which then displaces the double value deserialisation by 32 bits.
There's an easy fix, just comment out a couple of lines:

`
CameraInfo.cs:178

        //listOfSerializations.Add(BitConverter.GetBytes(K.Length));
        foreach(var entry in K)
            listOfSerializations.Add(BitConverter.GetBytes(entry));
        
        //listOfSerializations.Add(BitConverter.GetBytes(R.Length));
        foreach(var entry in R)
            listOfSerializations.Add(BitConverter.GetBytes(entry));
        
        //listOfSerializations.Add(BitConverter.GetBytes(P.Length));
        foreach(var entry in P)
            listOfSerializations.Add(BitConverter.GetBytes(entry));

`

Also I haven't verified, but I think the following lines should also be changed to this:

`
CameraInfo.cs:217

        var KArrayLength = 9;
        //offset += 4;
        this.K= new double[KArrayLength];
        for(var i =0; i <KArrayLength; i++)
        {
            this.K[i] = BitConverter.ToDouble(data, offset);
            offset += 8;
        }
        
        var RArrayLength = 9;
        //offset += 4;
        this.R= new double[RArrayLength];
        for(var i =0; i <RArrayLength; i++)
        {
            this.R[i] = BitConverter.ToDouble(data, offset);
            offset += 8;
        }
        
        var PArrayLength = 12;
        //offset += 4;
        this.P= new double[PArrayLength];
        for(var i =0; i <PArrayLength; i++)
        {
            this.P[i] = BitConverter.ToDouble(data, offset);
            offset += 8;
        }

`

I think this would be an issue with the Message generation so I guess that code should be updated because it could affect other ROS messages also.

ROS 2 Release

Is your feature request related to a problem? Please describe.
Building from source is annoying for stable projects.

Describe the solution you'd like
Release this repo on the ROS 2 buildfarm, particularly for Foxy.

Describe alternatives you've considered
Continue building from src

Additional context
Add any other context or screenshots about the feature request here.

Disabled ubuntu uncomplicated firewall (ufw) causes ROS-Unity Connection issues between two machines, Documentation should be updated to include issue

Problem

I was running into issues with connecting ROS to Unity.

My previous setup (which worked fine, we had a connection) had both ROS and Unity installed in Ubuntu on one Machine.

My new setup has ROS and Ubuntu on one machine, and Unity on a separate machine. Although we were following the same procedure to connect ROS and Unity using the ROSTCPConnector, it was failing to connect. The ROS terminal did not show any debugging information.

@ZhuoyunZhong and I discovered that on the Ubuntu ROS machine, the firewall was not enabled. Once it was enabled and port 10000 was added as a policy, I was able to successfully connect both machines.

Solution

I would like to add to the documentation, when debugging network issues. The file was ROS-Unity Integration: Network Description I imagine the most useful thing to add is:

  1. A way to check to see if the Ubuntu Uncomplicated Firewall (UFW) is enabled, by checking the status.
  2. How to enable UFW if not done so already
  3. Viewing the current policies
  4. Adding the policy to connect to port 10000 as needed

Additional Context

Here is roughly the commands that we followed to solve my issue.

sudo ufw enable
sudo ufw allow 10000

For debugging purposes use:

sudo ufw status 
sudo ufw status verbose

We also referenced this website here for our commands: Basic UFW (Uncomplicated Firewall) commands

ros_tcp_endpoint can't connect to ros2 rolling

Describe the bug
ros_tcp_endpoint can't connect to ros2 rolling. give below errors

/opt/ros/rolling/lib/python3.10/site-packages/rclpy/executors.py:780: UserWarning: MultiThreadedExecutor is used with a single thread.
Use the SingleThreadedExecutor instead. [ros2run]: Segmentation fault

To Reproduce
Steps to reproduce the behavior:

  1. run 'ros2 run ros_tcp_endpoint default_server_endpoint --ros-args -p ROS_IP:=1xx.xx.x.x' in ubuntu terminal
  2. Click on 'play button over at Unity windows PC'
  3. See error

Console logs / stack traces

jlkee@jlkee-ThinkPad-E14-Gen-2:~/ros-tcp-connector$ ros2 run ros_tcp_endpoint default_server_endpoint --ros-args -p ROS_IP:=192.168.1.120
[INFO] [1686222339.152750512] [UnityEndpoint]: Starting server on 192.168.1.120:10000
[INFO] [1686222344.932709639] [UnityEndpoint]: Connection from 192.168.1.10
[INFO] [1686222344.985584038] [UnityEndpoint]: RegisterSubscriber(/tf, <class 'tf2_msgs.msg._tf_message.TFMessage'>) OK
[ros2run]: Segmentation fault

Expected behavior
I expected Unity and ROS2 to be connected and see 'blue arrows' at Unity side

Screenshots
image

Environment (please complete the following information, where applicable):

  • Unity Version: Unity 2020.3.24f1
  • Unity machine OS + version: Windows 10
  • ROS machine OS + version: Ubuntu 22.04.2 LTS, ROS2 Rolling
  • ROS–Unity communication: Wifi and LAN cable through ros_tcp_endpoint
  • Branch or version: v0.7.0

Additional context
I tried with ROS2 humble using another laptop and connection was established successfully with 'blue arrows' seen.

ROS2 - Can't unsubscribe

Describe the bug
The ROS TCP endpoint throws an exception and hitches significantly when unsubscribing from topics.

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to a topic
  2. Unsubscribe
  3. Look at the TCP endpoint connector log
  4. See error

Console logs / stack traces

Exception in thread Thread-4:
Traceback (most recent call last):
  File "c:\python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\source\sol-proj-universal-robopose\ROS2\install\ros_tcp_endpoint\Lib\site-packages\ros_tcp_endpoint\client.py", line 213, in run
    self.tcp_server.handle_syscommand(destination, data)
  File "C:\source\sol-proj-universal-robopose\ROS2\install\ros_tcp_endpoint\Lib\site-packages\ros_tcp_endpoint\server.py", line 121, in handle_syscommand
    function = getattr(self.syscommands, topic[2:])
AttributeError: 'SysCommands' object has no attribute 'remove_subscriber'

Expected behavior
The topic should be unsubscribed with no crashing.

Environment:

  • Unity Version: Unity 2020.3.21f1
  • Unity machine OS + version: Windows 11
  • ROS machine OS + version: Windows 11, ROS Foxy
  • ROS–Unity communication: Windows Environment
  • Branch or version: dev_ros2

Handle socket timeout exception

Hello,

I've been using this for a couple of weeks now and it's great. Thank you. :)

Just one thing I'd like to add. If I'm not running my Unity game for too long then the socket in here times out and it crashes.

If we just put a try/except around the code in RosTCPServer.py (lines 53-59) like this then it'll stop crashing on timeout.

        while True:
            tcp_server.listen(self.connections)

            try:
                (conn, (ip, port)) = tcp_server.accept()
                new_thread = ClientThread(conn, self, ip, port)
                new_thread.start()
                threads.append(new_thread)
            except socket.timeout as err:
                logging.exception("RosTCPServer: socket timeout")

Improving the efficiency of the ROS side read_message

Is your feature request related to a problem? Please describe.

As part of the changes in Unity-Technologies/ROS-TCP-Connector#152 I've been testing scenarios where the queue fills and messages are dropped.
So I've tested the code on two machines with Unity running two 720p stereo pairs as fast as it can (This is typical of one of the robots I'm aiming to simulate and If I could get it efficient enough, I am aiming for possibly multiple robots simultaneously). This would roughly equate to a 1440p resolution every frame (Currently 30-40fps). The data is being published to the ROS network over loopback (localhost / 127.0.0.1).
PC1 can handle full frame rate, and PC2 drops messages as the queue fills up.

  • PC1: i7 9700k, 32GB 2133Mhz ddr4 rtx2080.
  • PC2: i7 3770k, 32GB 1600Mhz ddr3 gtx1080.

I added some timing logs to the output of the ROS-TCP-Endpoint for more information and it revealed that on the older less powerful machine, it was taking too long to read the data which surprised me this is running on loopback.

I was thinking about ways to mitigate this issue and was considering:

  1. Setting it up to have a thread for each publisher both on the send (Unity) and receive (ROS python) side. The downside to this is that the struggling machine is already running out of available processing headroom. Also implementing this would require a fair amount of code changes.
  2. Seeing if I can tweak the reading thread on the ROS-TCP-Endpoint to be more efficient. The downside to this is that looking at the code, it already looks pretty efficient. There's an existing note on line 101 of client.py that reads "# Only grabs max of 1024 bytes TODO: change to TCPServer's buffer_size". So maybe implementing this would fix my issues.

Anyhow, I'm considering implementing the second option as it is by far the easier to implement, but I thought I'd ask about the first option. What are the thoughts on the dev team about having a separate thread for each publisher? Have you considered implementing this? Also if you had any other suggestions, I'm all ears!

TopicOrServiceNameDoesNotExistError due to empty topic when client is disconnecting

I'm using the tcp-endpoint version 0.2.0 and Unity 2019.4.23f1, if I'm hosting a Server (on WSL), connect with Unity3D with it and then stop the Unity3D Connection, it seems like Unity is sending an empty message to the ros-tcp-endpoint, which raises an exception on the server side, exception is:

Exception in thread Thread-295:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/pattke/code/install/ros_tcp_endpoint/lib/python3/dist-packages/ros_tcp_endpoint/client.py", line 172, in run
    raise TopicOrServiceNameDoesNotExistError(error_msg)
ros_tcp_endpoint.exceptions.TopicOrServiceNameDoesNotExistError: Topic/service destination '' is not defined! Known topics are: dict_keys(['pos_srv', 'pos_rot', 'color', 'camera']) 

This happens multiple times after a client is disconnected. This msg should be ignored and should not throw an Exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.