Skip to content

Instantly share code, notes, and snippets.

@changx03
Created April 4, 2024 04:16
Show Gist options
  • Save changx03/ff4d9f4ebfac851e9e03397598b12f8b to your computer and use it in GitHub Desktop.
Save changx03/ff4d9f4ebfac851e9e03397598b12f8b to your computer and use it in GitHub Desktop.
Instruction on running Foxglove V1 and recording ROS2 outputs

Foxglove

Created: April 3, 2024 12:19 PM

Source

We don’t need to build it. Just for backup purpose

Studio: https://github.com/changx03/foxglove-studio-v1

ROS2 Bridge: https://github.com/changx03/ros-foxglove-bridge

Docker containers

https://github.com/foxglove/studio/pkgs/container/studio

Run server from docker and install bridge

docker run -d -p 80:8080 --name foxglove --restart unless-stopped ghcr.io/foxglove/studio:1.87

This should running on my computer:

http://192.168.0.172

NOTE: Chrome only, need to set flags to ignore SSL certificate

Install

# Install bridge and mcap (for recording)
$ sudo apt install ros-humble-foxglove-bridge ros-hunmble-rosbag2-storage-mcap -y

Install mcap cli tool (Optional)

Download map: https://github.com/foxglove/mcap/releases

wget https://github.com/foxglove/mcap/releases/download/releases%2Fmcap-cli%2Fv0.0.42/mcap-linux-amd64 -O mcap
chmod +x mcap
sudo mv mcap /usr/bin

mcap cli usage: https://mcap.dev/guides/cli

Create a launch file

In foxglove_bridge.launch.py,

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
    arguments = [
        DeclareLaunchArgument("port", default_value="8765"),
        DeclareLaunchArgument("address", default_value="0.0.0.0"),
        DeclareLaunchArgument("tls", default_value="false"),
        DeclareLaunchArgument("certfile", default_value=""),
        DeclareLaunchArgument("keyfile", default_value=""),
        DeclareLaunchArgument("topic_whitelist", default_value="['.*']"),
        DeclareLaunchArgument("param_whitelist", default_value="['.*']"),
        DeclareLaunchArgument("service_whitelist", default_value="['.*']"),
        DeclareLaunchArgument("client_topic_whitelist", default_value="['.*']"),
        DeclareLaunchArgument("min_qos_depth", default_value="1"),
        DeclareLaunchArgument("max_qos_depth", default_value="10"),
        DeclareLaunchArgument("num_threads", default_value="0"),
        DeclareLaunchArgument("send_buffer_limit", default_value="10000000"),
        DeclareLaunchArgument("use_sim_time", default_value="false"),
        DeclareLaunchArgument(
            "capabilities",
            default_value="[clientPublish,parameters,parametersSubscribe,services,connectionGraph,assets]",
        ),
        DeclareLaunchArgument("include_hidden", default_value="false"),
        DeclareLaunchArgument(
            "asset_uri_allowlist",
            default_value="['^package://(?:\\w+/)*\\w+\\.(?:dae|fbx|glb|gltf|jpeg|jpg|mtl|obj|png|stl|tif|tiff|urdf|webp|xacro)$']",
        ),
    ]

    bridge = Node(
        package="foxglove_bridge",
        executable="foxglove_bridge",
        parameters=[
            {
                "port": LaunchConfiguration("port"),
                "address": LaunchConfiguration("address"),
                "tls": LaunchConfiguration("tls"),
                "certfile": LaunchConfiguration("certfile"),
                "keyfile": LaunchConfiguration("keyfile"),
                "topic_whitelist": LaunchConfiguration("topic_whitelist"),
                "param_whitelist": LaunchConfiguration("param_whitelist"),
                "service_whitelist": LaunchConfiguration("service_whitelist"),
                "client_topic_whitelist": LaunchConfiguration("client_topic_whitelist"),
                "min_qos_depth": LaunchConfiguration("min_qos_depth"),
                "max_qos_depth": LaunchConfiguration("max_qos_depth"),
                "num_threads": LaunchConfiguration("num_threads"),
                "send_buffer_limit": LaunchConfiguration("send_buffer_limit"),
                "use_sim_time": LaunchConfiguration("use_sim_time"),
                "capabilities": LaunchConfiguration("capabilities"),
                "include_hidden": LaunchConfiguration("include_hidden"),
                "asset_uri_allowlist": LaunchConfiguration("asset_uri_allowlist"),
            }
        ],
    )

    return LaunchDescription(arguments + [bridge])

Launch with a launch file

ros2 launch foxglove_bridge.launch.py

Start Foxglove Studio

  • Studio only runs on Chrome
  • To start the studio, open http://<HOST_IP>:8080 in Chrome
  • From Foxglove Studio, open ws://<BRIDGE_NODE_IP>:8765

Recording with mcap

# Start recording
cd ~/Documents
ros2 bag record -s mcap --all -b 500000000
# -s Storage type: mcap
# -all subscribe all topics
# -b --max-bag-size in bytes 500MB
# Create a folder in the current directory.
# mcap is compressed. Compression options make no difference.

Convert bag SQLite to mcap

mcap convert uses $AMENT_PREFIX_PATH to locate the definitions of interfaces

echo $AMENT_PREFIX_PATH

# Concert SQLite3 to mcap
mcap convert multiple_files_1.db3 demo.mcap

# specify ament path
$ mcap convert ros2_input.db3 ros1_output.mcap --ament-prefix-path=/your/first/directory;/your/second/directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment