Skip to content

b-robotized/ros2-launch-navigator

Repository files navigation

ROS 2 Launch Navigator

VSCode extension for navigating ROS 2 launch files. Provides Ctrl+Click navigation on node executables and included launch files.

Features

  • Ctrl+Click navigation on node executables (e.g., 'my_node.py') to open source files
  • Ctrl+Click navigation on included launch files to open them
  • Uses ROS 2's native launch module for accurate analysis
  • Supports both source workspace and install space navigation

Quick Start

Installation

Download the latest release and install it with:

code --install-extension ros2-launch-navigator-<current-version>.vsix

Alternatively, you can also build it from source:

# Build extension
docker run --rm -v "$(pwd)":/workspace -w /workspace node:20-bullseye \
  bash -c 'npm ci && npm run compile && npx --yes @vscode/vsce package --allow-missing-repository --no-rewrite-relative-links'

Configuration

The extension needs to know about your ROS 2 setup scripts. Therefore, some configuration is required: Configure ROS 2 setup scripts using commands:

  1. Open Command Palette (Ctrl+Shift+P)
  2. Run: "ROS Launch Linker: Add Setup Script"
  3. Select your ROS 2 setup.bash (e.g., /opt/ros/jazzy/setup.bash)
  4. Also add your workspace setup.bash files (e.g., /home/user/ros2_ws/install/setup.bash)

Add setup script

Or use: "ROS Launch Linker: Add Common Setup Scripts" to add the base ROS setup scripts.

Usage

  1. Open a .launch.py file
  2. Ctrl+Click on node executable names (e.g., 'dummy_node.py')
  3. Navigate to the source file

Commands

  • ROS Launch Linker: Add Setup Script - Add ROS 2 setup script path
  • ROS Launch Linker: Remove Setup Script - Remove setup script
  • ROS Launch Linker: Manage Setup Scripts - Interactive management
  • ROS Launch Linker: Add Common Setup Scripts - Quick-add common scripts
  • ROS Launch Linker: Toggle Prioritize Source - Switch between source/install paths

Configuration

{
  "rosLaunchLinker.setupScripts": [
    "/opt/ros/jazzy/setup.bash",
    "~/ros2_ws/install/setup.bash"
  ],
  "rosLaunchLinker.prioritizeSource": true
}

How It Works

  1. Extension activates when opening .launch.py files
  2. Calls Python analyzer using ROS 2's launch module
  3. Analyzer extracts node executables and launch file paths
  4. Extension creates clickable links in VSCode
  5. Ctrl+Click navigates to source or install files

Architecture

src/
├── extension.ts                    # Entry point
├── commands/
│   └── setupScriptCommands.ts     # Setup script commands
├── providers/
│   └── rosLaunchLinkProvider.ts   # Document link provider
└── analyzer/
    ├── analyze_launch.py          # Python analyzer
    └── launchAnalyzer.ts          # TypeScript wrapper

Testing

# Python tests
pytest test/python/ -v

# TypeScript tests
npm run compile && npm test

# Docker tests (full ROS 2 environment)
./run-docker-tests.sh

See RUNNING_TESTS.md for details.

Development

# Clone
git clone <repository-url>
cd ros2-launch-navigator

# Install dependencies
npm install

# Compile
npm run compile

# Run tests
npm test
pytest test/python/

# Package
docker run --rm -v "$(pwd)":/workspace -w /workspace node:20-bullseye \
  bash -c 'npm ci && npm run compile && npx --yes @vscode/vsce package --allow-missing-repository --no-rewrite-relative-links'

Version

Current version: 0.3.1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published