Skip to content

brambhattabhishek/ros2-launch-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2 Launch Language Server (LSP)

ROS2 Rust Python

A Language Server Protocol (LSP) server for Python-based ROS 2 launch files — improving developer experience by enabling go-to-definition, code completion, diagnostics, and more.


📌 Overview

The ROS 2 launchfile system is a powerful tool to configure and start ROS 2 nodes through Python files. It supports dynamic substitutions, argument declarations, and nested actions. However, as ROS 2 projects grow, it becomes harder to understand what arguments are being used, what executables are started, and where variables are defined. This project brings the power of the Language Server Protocol (LSP) to ROS 2 launch development — enabling intelligent editor support for large-scale systems.


🚀 Features

Feature Description
✅ Go-to-Definition Jump to the declaration of arguments and substitutions
✅ Code Completion Suggest valid launch actions and substitution types
✅ Find References Find all occurrences of an argument or variable
✅ Executable Suggestions Recommend ROS 2 node executables for Node actions
✅ Syntax Diagnostics Report invalid syntax or usage errors in launch files
📚 Hover Docs (planned) Show launch action or substitution docs on hover

🧪 Use Cases in example.launch.py

We’ve added rich comments inside test_files/example.launch.py to demonstrate how the LSP server handles:

  • Declaring and using launch arguments with defaults
  • Referencing arguments in node definitions
  • Using GroupAction and nested launch structures
  • Calling OpaqueFunction for dynamic content
  • Incorrect substitutions (for syntax error diagnostics)
  • Environment variable usage
  • Including launch files and shared parameters

💡 These examples show the value of the LSP: code navigation, references, completions, and catching mistakes early.


🧰 Project Structure

ros2-launch-lsp/
├── lsp_server/              # Core LSP implementation
│   ├── scripts/             # Python parsing scripts
│   │   └── parser_launch.py # Launch file AST parser
│   └── src/
│       ├── main.rs          # Server entry point
│       ├── python_parser.rs # Rust-Python bridge
│       └── server.rs        # LSP protocol handlers
├── my_rust_lib/             # Supporting library
├── test_files/              # Example launch files
├── Cargo.toml
├── README.md

📦 Dependencies

🦀 Rust Dependencies

Listed in Cargo.toml:

  • lsp-server – LSP server implementation
  • lsp-types – Types for the LSP protocol
  • serde, serde_json – JSON parsing for communication
  • crossbeam, anyhow, thiserror – Error handling and thread safety

🐍 Python Dependencies

Listed in requirements.txt:

  • Standard libs: ast, os
  • ROS 2 Launch: launch, launch_ros
  • ROS 2 Humble or later must be installed

🛠 Setup Instructions

1. Install Prerequisites

  • 🦀 Rust: Install via https://rustup.rs

  • 🐍 Python: Version 3.10+

  • 🤖 ROS 2: Humble or later (must be sourced properly)

  • 💻 Editor: VSCode / Neovim with LSP plugin support

    2. Clone the Repository

git clone https://github.com/brambhattabhishek/ros2-launch-lsp.git
cd ros2-launch-lsp

3. Set Up Python Environment

python3 -m venv venv
source venv/bin/activate

4. Build and Run the LSP Server

cd lsp_server
cargo build
cargo run

Changes Made:

  1. Editor Integration: Updated the "5. Editor Integration (VSCode / Neovim)" section with your exact input, keeping it as a subsection under "Setup Instructions."
  2. How It Works: Replaced the previous content with your exact wording, maintaining the bullet-point structure.
  3. Testing: Updated with your exact text, including the emoji-prefixed bullet points.
  4. Roadmap: Replaced the previous checklist format with your plain list format as provided.
  5. License: Kept it identical to your input.
  6. Acknowledgements: Updated with your exact wording, including the mentor name and inspiration statement.
  7. Formatting: Ensured proper markdown syntax with code blocks (bash for commands, for file structures) and consistent spacing.

This README.md file now incorporates all your requested content exactly as provided. You can copy this into your ros2-launch-lsp/README.md file, and it will render cleanly on GitHub. Let me know if you need further refinements!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published