Skip to content

nootsquared/RTelemetry

Repository files navigation

ROS 2 Variable Logging and Visualization System

A comprehensive ROS 2 variable logging and visualization system for RoboMaster projects. This system allows you to log variables from ROS 2 nodes and visualize/modify them in real-time through a modern web interface.


Prerequisites

Before setting up, ensure you have:

  1. ROS 2 Humble (or later) installed and configured

  2. Node.js 18+ and npm

    • macOS: brew install node
    • Windows: Download from nodejs.org
  3. Python 3.8+ (usually pre-installed)

    • Install websockets library: pip3 install websockets

Quick Start

1. Install Node.js (if not installed)

macOS:

brew install node

Windows: Download and install from nodejs.org

Verify installation:

node --version
npm --version

2. Run Setup

Navigate to the RTelemetry project directory and run the automated setup:

cd /path/to/RTelemetry
npm run setup

This will:

  • Install Node.js dependencies
  • Create a ROS workspace
  • Build ROS packages
  • Generate an environment setup script

3. Start the Simulator

You need 3 terminal windows running simultaneously:

Terminal 1 - Bridge Node:

cd /path/to/RTelemetry
source rossimulator_env.sh
ros2 run ros_introspection_bridge bridge_node.py

Terminal 2 - Publisher Node:

cd /path/to/RTelemetry
source rossimulator_env.sh
ros2 run robomaster_logger publisher_node

Terminal 3 - Web Interface:

cd /path/to/RTelemetry
npm run dev

Then open your browser to http://localhost:3000


Usage

Accessing the Dashboard

  1. Start all three services (see above)
  2. Open http://localhost:3000 in your browser
  3. Verify the connection status indicator is green

Variable Tree

  • View Variables: All logged variables appear in the left sidebar
  • Expand/Collapse: Click node names to expand/collapse
  • Edit Variables: Click on variable values to edit them

Graph Panel

  • Add Variables: Drag variables from the sidebar onto graph axis boxes (Left Axis, Right Axis, or Discrete)
  • Toggle Visibility: Click the eye icon to show/hide variables
  • Change Line Style: Click the line style icon to cycle through styles
  • Remove Variables: Hover and click the X button

Log Viewer

  • Real-time log messages from ROS nodes
  • Use the search box to filter logs
  • Logs are color-coded by severity level

Running Your ROS Nodes

If you have ROS nodes that log variables, run them in additional terminals:

# Source your main workspace (if different from RTelemetry)
cd /path/to/your/ros/workspace
source install/setup.bash

# Run your nodes
ros2 run your_package your_node

Example - Running Autonav Node:

cd /path/to/your/ros/workspace
source install/setup.bash
ros2 run autonav autonav_node

Using the Logger in Your Code

Include the logger header and use the ROBOMASTER_LOG macro:

#include <robomaster_logger/logger.hpp>

// In your node:
float health_threshold = 67.0;
ROBOMASTER_LOG("/autonav/capture/health_threshold", health_threshold);

int max_retries = 5;
ROBOMASTER_LOG("/autonav/capture/max_retries", max_retries);

bool enable_debug = false;
ROBOMASTER_LOG("/autonav/debug/enable", enable_debug);

std::string current_state = "idle";
ROBOMASTER_LOG("/autonav/state/current", current_state);

Supported Types:

  • float, double
  • int, int32_t, int64_t
  • bool, boolean
  • std::string
  • std::vector<T> (arrays)

Troubleshooting

WebSocket Connection Failed

Symptoms: Connection status shows red, no variables appear

Solutions:

  1. Verify bridge node is running (Terminal 1)
  2. Check if port 9090 is in use: lsof -i :9090 (macOS) or netstat -ano | findstr :9090 (Windows)
  3. Check browser console (F12) for WebSocket errors
  4. Verify firewall isn't blocking port 9090

Variables Not Appearing

Symptoms: Dashboard loads but no variables in sidebar

Solutions:

  1. Verify publisher node is running (Terminal 2)
  2. Check ROS topics: ros2 topic list | grep variable_snapshots
  3. Monitor the topic: ros2 topic echo /robomaster_logger/variable_snapshots
  4. Verify your ROS nodes are calling ROBOMASTER_LOG and variables are being updated

Setup Fails

Solutions:

  1. Verify ROS 2 is installed: ros2 --version
  2. Ensure ROS 2 environment is sourced. The setup script will auto-detect your ROS installation, or you can set ROSSIMULATOR_ROS_SETUP environment variable to point to your ROS setup.bash file
  3. Install Python websockets: pip3 install websockets
  4. Check that rosdep is initialized: sudo rosdep init && rosdep update (if needed)

Port Already in Use

Solutions:

  1. Find process using port 9090: lsof -i :9090 (macOS) or netstat -ano | findstr :9090 (Windows)
  2. Kill the process or use different ports:
    export ROSSIMULATOR_BRIDGE_PORT=9091
    ros2 run ros_introspection_bridge bridge_node.py

ROS Packages Not Found

Solutions:

  1. Source the environment: source rossimulator_env.sh
  2. Verify packages are built: ros2 pkg list | grep robomaster_logger
  3. Rebuild if needed:
    cd .ros_ws
    colcon build --packages-select robomaster_logger ros_introspection_bridge
    source install/setup.bash

Project Structure

RTelemetry/
├── app/                    # Next.js app directory
├── components/            # React components
├── hooks/                # React hooks
├── lib/                  # Utilities
├── scripts/              # Setup scripts
├── src/                  # ROS 2 packages
│   ├── robomaster_logger/
│   └── ros_introspection_bridge/
├── .ros_ws/             # ROS workspace (generated)
├── package.json         # Node.js dependencies
└── rossimulator_env.sh  # Environment script (generated)

Development

Rebuilding ROS Packages

cd .ros_ws
colcon build --packages-select robomaster_logger ros_introspection_bridge
source install/setup.bash

Rebuilding Web Interface

The development server (npm run dev) automatically reloads on changes. For production:

npm run build
npm start

Configuration

Environment Variables

ROS Setup (for scripts and setup):

  • ROSSIMULATOR_ROS_SETUP: Absolute path to ROS setup.bash file (e.g., /opt/ros/humble/setup.bash). If not set, scripts will auto-detect common ROS installations.
  • ROSSIMULATOR_ROS_WORKSPACE: Custom path for ROS workspace (default: .ros_ws in project root)
  • ROS_DISTRO: ROS distribution name (e.g., humble, iron). Used for auto-detection if ROSSIMULATOR_ROS_SETUP is not set.
  • ROS_ROOT: ROS root directory. Used for auto-detection if other methods fail.

Bridge Node:

  • ROSSIMULATOR_BRIDGE_HOST: Host to bind (default: 0.0.0.0)
  • ROSSIMULATOR_BRIDGE_PORT: Port number (default: 9090)

Web Interface:

  • NEXT_PUBLIC_ROS_BRIDGE_HOST: Hostname to connect to (default: browser hostname)
  • NEXT_PUBLIC_ROS_BRIDGE_PORT: Port number (default: 9090)
  • NEXT_PUBLIC_ROS_BRIDGE_URL: Full WebSocket URL (overrides other options)

Custom ROS Installation

If your ROS installation is in a non-standard location, you can set the ROSSIMULATOR_ROS_SETUP environment variable before running setup:

export ROSSIMULATOR_ROS_SETUP="/custom/path/to/ros/setup.bash"
npm run setup

Or source it manually before running any ROS commands:

export ROSSIMULATOR_ROS_SETUP="/custom/path/to/ros/setup.bash"
source rossimulator_env.sh

License

MIT License - see LICENSE file for details


Last updated: 2025

About

A comprehensive ROS 2 variable logging and visualization system for RoboMaster projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published