简体   繁体   English

在同一台计算机上的两个进程之间使用ROSBridge

[英]Using ROSBridge Between Two Processes on the Same Computer

I have a C++ ROS node using ROSBridge to send the ROS Topics as JSON strings via TCP WebSocket over port 9090. On the same computer, I have a C# Unity program that needs to access the JSON and send some of its own. 我有一个C ++ ROS节点,使用ROSBridge通过9090端口通过TCP WebSocket将ROS Topics作为JSON字符串发送。在同一台计算机上,我有一个C#Unity程序,需要访问JSON并发送它自己的一些程序。 If I put this program on a different computer there is no problem--I can access port 9090 and see the JSON. 如果我将此程序放在另一台计算机上没有问题,那么我可以访问端口9090并查看JSON。 But if it is on the same computer as the ROSBridge Host, then there is a conflict with using the same port. 但是,如果它与ROSBridge主机位于同一台计算机上,则使用同一端口会有冲突。 So the two applications cannot communicate with each other on the same PC but they can on separate PCs. 因此,这两个应用程序不能在同一台PC上相互通信,但是可以在不同的PC上进行通信。

So what can I do? 那我该怎么办? Must the ports match and thus always conflict or maybe I can somehow make Process A send on 9090 but receive on 9091 and Process B just the opposite or something? 端口必须匹配并且总是冲突吗,或者我可以以某种方式使进程A在9090上发送但在9091与进程B上相反? Any other options? 还有其他选择吗? In essence, I'm trying to get Unity to participate in the ROS communications, but it does not have native support for that and thus the workaround with the ROSBridge JSON strings. 本质上,我正在尝试让Unity参与ROS通信,但它对此没有本地支持,因此没有使用ROSBridge JSON字符串的解决方法。

According to http://wiki.ros.org/rosbridge_suite/Tutorials/RunningRosbridge you can set the port that Rosbridge talks on in the .launch file. 根据http://wiki.ros.org/rosbridge_suite/Tutorials/RunningRosbridge,您可以在.launch文件中设置Rosbridge所使用的端口。

If you are using the example rosbridge_websocket.launch file, the second line of the file includes a port number in the form of <arg name="port" default="9090" /> . 如果您使用的是示例rosbridge_websocket.launch文件,则文件的第二行包含<arg name="port" default="9090" />形式的端口号。 You can change 9090 to change the default port it uses. 您可以更改9090来更改其使用的默认端口。


According to the roslaunch documentation at http://wiki.ros.org/roslaunch/Commandline%20Tools you can also pass arguments to roslaunch on the command line: 根据http://wiki.ros.org/roslaunch/Commandline%20Tools上的roslaunch文档,您还可以在命令行roslaunch参数传递给roslaunch

The rosbridge_websocket.launch file sets the port from the argument "port", so if you run roslaunch like this it will use port 8080: rosbridge_websocket.launch文件通过参数“ port”设置端口,因此,如果您这样运行roslaunch,它将使用端口8080:

roslaunch rosbridge_server rosbridge_websocket.launch port:=8080


You can see the full rosbridge_websocket.launch file at https://github.com/RobotWebTools/rosbridge_suite/blob/develop/rosbridge_server/launch/rosbridge_websocket.launch 您可以在https://github.com/RobotWebTools/rosbridge_suite/blob/develop/rosbridge_server/launch/rosbridge_websocket.launch上看到完整的rosbridge_websocket.launch文件。

Looking over that file for the line <param name="port" value="$(arg port)"/> is how I know that it uses the "port" argument to set the port. 在该文件中查找行<param name="port" value="$(arg port)"/>就是我知道它使用“ port”参数设置端口的方式。


If you post your .launch files I can give your more advice on how to edit them if this answer is not clear. 如果您发布.launch文件,如果此答案不清楚,我可以为您提供有关如何编辑它们的更多建议。

It sounds like my understanding about ports was lacking. 听起来我缺乏对端口的了解。 The host for the ROSBridge is being set up to use port 9090 so that anyone wishing to connect to it will request the host's port 9090 for the connection but will still use whatever port it desires on its own side. ROSBridge的主机已设置为使用端口9090,因此,希望连接到该主机的任何人都将请求主机的端口9090进行连接,但仍将使用其自己需要的任何端口。 In both applications, I can state that the "Host" port is 9090 without conflict because the client application will still open a random other port for its own use to connect to the host port. 在这两个应用程序中,我都可以声明“主机”端口为9090,而不会发生冲突,因为客户端应用程序仍会打开一个随机的其他端口供自己连接到主机端口。 Therefore, the trouble I am experiencing is something other than "port sharing" since that is not what is happening. 因此,我遇到的麻烦不是“端口共享”,而是因为这不是正在发生的事情。 Only one is hosting on 9090. 9090上只有一台主机。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 同一台计算机上的两个程序之间的通信-如何进行? - Communication between two programs on same computer – How? 使用文件在两个进程之间交换消息 - Using file to exchange messages between two processes .NET 远程客户端和服务器在同一台计算机上。 一个过程? 两个过程? - .NET remoting client and server on the same computer. One process? Two processes? 在同一台计算机上的两个程序之间发送和接收UDP数据包 - Sending and receiving UDP packets between two programs on the same computer 在c#中使用命名管道的两个进程之间的双工操作 - duplex operation between two processes using named pipes in c# 使用内存映射文件在一个盒子上的两个进程之间进行文本交换 - text exchange between two processes on a box using Memory Mapped File 显示使用WMI在远程计算机上运行的进程 - Show processes running on remote computer using WMI C#锁定会影响同一计算机系统上的其他进程吗 - does C# lock affect other processes on the same computer system 什么WCF绑定可用于在同一台计算机上以不同特权在两个进程之间进行通信? - What WCF binding to use to communicate between two processes with different privileges on the same machine? 是否可以在同一台计算机上的两个进程之间共享类实例,而不必进行序列化/反序列化? - Can I share class instances between two processes on the same machine without having to serialize/deserialize?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM