Skip to main content

ROS 2

加载包含 ROS 2 数据的本地和远程 MCAP 文件,或直接连接到实时 ROS 2 堆栈。

实时数据

安装 ROS 2,并确保您与机器人在同一网络上。

在 Foxglove 中,在“打开数据源”对话框中选择“打开连接”。

Foxglove WebSocket

我们推荐 Foxglove WebSocket 作为最简单的连接方式——特别是如果您在 ROS 和 Foxglove 之间有网络防火墙,因为它只需要您的 ROS 主机打开一个端口。

此选项需要运行一个额外的 ROS 节点 (foxglove_bridge)——请按照此处的安装说明进行操作。

连接

设置 Foxglove 桥接

在“打开数据源”对话框中选择“Foxglove WebSocket”,然后输入您的 Foxglove 桥接服务器的 URL:

Foxglove WebSocket 对话框

Reset connection

To reconnect to a Foxglove WebSocket in a different context, you must first clear out your most recently visualized data in Foxglove.

To clear the state and reset your visualizations, resend the serverInfo message with an updated value for its optional sessionID field (string value). This lets the Foxglove WebSocket connection know that you are initiating a new connection, instead of trying to reconnect to a dropped one.

限制

Foxglove WebSocket 连接支持发布回您的 ROS 堆栈,以及读取和设置 ROS 参数。

Rosbridge

注意:出于性能原因,我们推荐使用 Foxglove WebSocket 连接。

Connect directly to your running ROS stack via WebSockets using a Rosbridge connection. This connection option requires only a single open port between Foxglove and your robot.

A rosbridge connection uses a standard protocol to connect Foxglove to your ROS master over WebSockets. While it does require running an extra ROS noderosbridge_server, we recommend this option if you have a network firewall between ROS and Foxglove, as it requires your ROS host to have only one port open.

To open a Rosbridge connection, make sure you’ve installedrosbridge-suite

$ sudo apt install ros-galactic-rosbridge-suite // ROS 2 Galactic

Next, start the WebSocket server, and review the command printout to determine the port it is listening on (e.g. ws://0.0.0.0:9090):

$ ros2 launch rosbridge_server rosbridge_websocket_launch.xml

"Open connection" in the "Open data source" dialog, select "Rosbridge", then enter the URL to your Rosbridge server:

Rosbridge dialog

To test your connection, open the sidebar to verify that Foxglove is receiving your data source's topics.

限制

Rosbridge 连接支持发布回您的 ROS 堆栈,但不支持读取或设置 ROS 参数

远程文件

远程 ROS 2 .db3 文件不受支持,但您可以将它们转换为 MCAP 文件以支持远程文件。

在“打开数据源”对话框中选择“远程文件”,然后输入您的远程 .mcap 文件的 URL。

远程文件对话框

Check out the directions for setting up CORS to load remote data files into Foxglove.

本地数据

您必须先将 ROS 2 (.db3) 文件转换为支持的 MCAP 文件格式,然后才能在 Foxglove 中加载。

使用 mcap CLI 工具 进行转换: