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.
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.
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 |
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.
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
Listed in Cargo.toml
:
lsp-server
– LSP server implementationlsp-types
– Types for the LSP protocolserde
,serde_json
– JSON parsing for communicationcrossbeam
,anyhow
,thiserror
– Error handling and thread safety
Listed in requirements.txt
:
- Standard libs:
ast
,os
- ROS 2 Launch:
launch
,launch_ros
- ROS 2 Humble or later must be installed
-
🦀 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
git clone https://github.com/brambhattabhishek/ros2-launch-lsp.git
cd ros2-launch-lsp
python3 -m venv venv
source venv/bin/activate
cd lsp_server
cargo build
cargo run
- Editor Integration: Updated the "5. Editor Integration (VSCode / Neovim)" section with your exact input, keeping it as a subsection under "Setup Instructions."
- How It Works: Replaced the previous content with your exact wording, maintaining the bullet-point structure.
- Testing: Updated with your exact text, including the emoji-prefixed bullet points.
- Roadmap: Replaced the previous checklist format with your plain list format as provided.
- License: Kept it identical to your input.
- Acknowledgements: Updated with your exact wording, including the mentor name and inspiration statement.
- 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!