|
1 | 1 | # ROSForge |
2 | 2 |
|
3 | | -AI-driven ROS1 to ROS2 migration CLI tool. |
| 3 | +**AI-driven ROS1 to ROS2 migration CLI tool.** |
4 | 4 |
|
5 | | -## Install |
| 5 | +[](https://github.com/Rlin1027/ROSForge/actions) [](https://pypi.org/project/rosforge/) [](LICENSE) |
| 6 | + |
| 7 | +## Why ROSForge? |
| 8 | + |
| 9 | +ROS1 reached end-of-life in May 2025. Migrating a production codebase to ROS2 by hand is tedious and error-prone: API namespaces changed, CMakeLists.txt rules are different, launch files moved to Python, and hundreds of `ros::` calls need one-by-one replacement. ROSForge automates this work by combining a static knowledge base of known API mappings with an AI backend that handles the cases rules alone cannot cover. The result is a complete, confidence-scored migration in minutes rather than days. |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- **Full pipeline** — analyze, transform, validate, and report in a single command |
| 14 | +- **BYOM (Bring Your Own Model)** — Claude, Gemini, and OpenAI backends; CLI or API mode |
| 15 | +- **Auto-fix loop** — runs `colcon build`, feeds errors back to the AI, retries up to N times |
| 16 | +- **Interactive mode** — per-file diff review; accept or skip each transformed file |
| 17 | +- **Batch workspace migration** — migrate an entire catkin workspace in one pass |
| 18 | +- **Custom transformation rules** — override or extend mappings with a YAML file |
| 19 | +- **Static knowledge base** — built-in C++/Python API mappings, CMake rules, and launch conversion patterns |
| 20 | +- **Cost estimation** — token and USD estimates shown before any API calls are made |
| 21 | +- **Confidence scoring** — every output file is rated HIGH / MEDIUM / LOW; low-confidence files are flagged for manual review |
| 22 | + |
| 23 | +## Quick Start |
6 | 24 |
|
7 | 25 | ```bash |
| 26 | +# Install |
8 | 27 | pip install rosforge |
| 28 | + |
| 29 | +# Set your preferred AI backend (stored in ~/.config/rosforge/config.toml) |
| 30 | +rosforge config set engine.name gemini |
| 31 | +rosforge config set engine.mode cli |
| 32 | + |
| 33 | +# Migrate a single ROS1 package |
| 34 | +rosforge migrate ./my_ros1_package -o ./my_ros1_package_ros2 |
| 35 | +``` |
| 36 | + |
| 37 | +The migrated package and a `migration_report.md` are written to the output directory. |
| 38 | + |
| 39 | +## Commands |
| 40 | + |
| 41 | +| Command | Description | |
| 42 | +|---|---| |
| 43 | +| `rosforge migrate <path>` | Migrate a single ROS1 package to ROS2 | |
| 44 | +| `rosforge migrate-workspace <path>` | Migrate all packages in a catkin workspace | |
| 45 | +| `rosforge analyze <path>` | Analyze a package and report migration complexity without transforming | |
| 46 | +| `rosforge config set <key> <value>` | Set a configuration value and persist it | |
| 47 | +| `rosforge config get <key>` | Get a single configuration value | |
| 48 | +| `rosforge config list` | Print all current configuration values as JSON | |
| 49 | +| `rosforge config reset` | Reset configuration to defaults | |
| 50 | +| `rosforge config path` | Show the path to the configuration file | |
| 51 | +| `rosforge status` | Show the status of an in-progress or completed migration | |
| 52 | + |
| 53 | +## AI Engine Configuration |
| 54 | + |
| 55 | +ROSForge supports three AI backends. Each can run in **cli** mode (calls a locally installed CLI tool, no API key required) or **api** mode (calls the provider's REST API directly, requires an API key). |
| 56 | + |
| 57 | +### Claude |
| 58 | + |
| 59 | +```bash |
| 60 | +# CLI mode — requires the Anthropic Claude CLI installed and authenticated |
| 61 | +rosforge config set engine.name claude |
| 62 | +rosforge config set engine.mode cli |
| 63 | + |
| 64 | +# API mode — requires ANTHROPIC_API_KEY |
| 65 | +pip install "rosforge[claude]" |
| 66 | +rosforge config set engine.name claude |
| 67 | +rosforge config set engine.mode api |
| 68 | +export ANTHROPIC_API_KEY=sk-ant-... |
| 69 | +``` |
| 70 | + |
| 71 | +### Gemini |
| 72 | + |
| 73 | +```bash |
| 74 | +# CLI mode — requires the Google Gemini CLI installed and authenticated |
| 75 | +rosforge config set engine.name gemini |
| 76 | +rosforge config set engine.mode cli |
| 77 | + |
| 78 | +# API mode — requires GOOGLE_API_KEY |
| 79 | +pip install "rosforge[gemini]" |
| 80 | +rosforge config set engine.name gemini |
| 81 | +rosforge config set engine.mode api |
| 82 | +export GOOGLE_API_KEY=AIza... |
| 83 | +``` |
| 84 | + |
| 85 | +### OpenAI |
| 86 | + |
| 87 | +```bash |
| 88 | +# API mode — requires OPENAI_API_KEY |
| 89 | +pip install "rosforge[openai]" |
| 90 | +rosforge config set engine.name openai |
| 91 | +rosforge config set engine.mode api |
| 92 | +export OPENAI_API_KEY=sk-... |
9 | 93 | ``` |
10 | 94 |
|
11 | | -## Usage |
| 95 | +Install all backends at once: |
| 96 | + |
| 97 | +```bash |
| 98 | +pip install "rosforge[all]" |
| 99 | +``` |
| 100 | + |
| 101 | +## Advanced Usage |
| 102 | + |
| 103 | +### Interactive review |
| 104 | + |
| 105 | +Review each transformed file before it is written: |
12 | 106 |
|
13 | 107 | ```bash |
14 | | -rosforge migrate ./my_ros1_package |
| 108 | +rosforge migrate ./my_package --interactive |
15 | 109 | ``` |
| 110 | + |
| 111 | +Press `a` to accept, `s` to skip, `q` to quit and accept all remaining files. |
| 112 | + |
| 113 | +### Auto-fix loop |
| 114 | + |
| 115 | +Build the output with `colcon build` after migration, feed any errors back to the AI, and retry: |
| 116 | + |
| 117 | +```bash |
| 118 | +rosforge migrate ./my_package --max-fix-attempts 3 |
| 119 | +``` |
| 120 | + |
| 121 | +### Custom rules |
| 122 | + |
| 123 | +Supply additional or overriding transformation mappings: |
| 124 | + |
| 125 | +```bash |
| 126 | +rosforge migrate ./my_package --rules custom_rules.yaml |
| 127 | +``` |
| 128 | + |
| 129 | +### Skip confirmation |
| 130 | + |
| 131 | +Skip the cost-estimate confirmation prompt (useful in CI): |
| 132 | + |
| 133 | +```bash |
| 134 | +rosforge migrate ./my_package --yes |
| 135 | +``` |
| 136 | + |
| 137 | +### Target ROS2 distribution |
| 138 | + |
| 139 | +The default target is `humble`. To target a different distribution: |
| 140 | + |
| 141 | +```bash |
| 142 | +rosforge migrate ./my_package --distro jazzy |
| 143 | +``` |
| 144 | + |
| 145 | +### Workspace migration |
| 146 | + |
| 147 | +```bash |
| 148 | +rosforge migrate-workspace ./catkin_ws -o ./ros2_ws --engine gemini --yes |
| 149 | +``` |
| 150 | + |
| 151 | +### Analyze without migrating |
| 152 | + |
| 153 | +```bash |
| 154 | +# Rich table output in the terminal |
| 155 | +rosforge analyze ./my_package |
| 156 | + |
| 157 | +# Machine-readable JSON |
| 158 | +rosforge analyze ./my_package --json |
| 159 | + |
| 160 | +# Save JSON report to file |
| 161 | +rosforge analyze ./my_package -o analysis.json |
| 162 | +``` |
| 163 | + |
| 164 | +## Custom Rules |
| 165 | + |
| 166 | +Create a YAML file to add or override transformation mappings: |
| 167 | + |
| 168 | +```yaml |
| 169 | +# custom_rules.yaml |
| 170 | +version: 1 |
| 171 | + |
| 172 | +api_mappings: |
| 173 | + cpp: |
| 174 | + "ros::NodeHandle": "rclcpp::Node" |
| 175 | + "ros::Publisher": "rclcpp::Publisher" |
| 176 | + python: |
| 177 | + "rospy.init_node": "rclpy.init" |
| 178 | + "rospy.Publisher": "rclpy.create_publisher" |
| 179 | + |
| 180 | +package_mappings: |
| 181 | + "roscpp": "rclcpp" |
| 182 | + "rospy": "rclpy" |
| 183 | + |
| 184 | +cmake_mappings: |
| 185 | + "find_package(catkin REQUIRED": "find_package(ament_cmake REQUIRED" |
| 186 | +``` |
| 187 | +
|
| 188 | +Pass the file with `--rules custom_rules.yaml`. Custom mappings take precedence over the built-in knowledge base. |
| 189 | + |
| 190 | +## Development |
| 191 | + |
| 192 | +```bash |
| 193 | +git clone https://github.com/Rlin1027/ROSForge.git |
| 194 | +cd ROSForge |
| 195 | +pip install -e ".[dev,all]" |
| 196 | +pytest tests/ |
| 197 | +``` |
| 198 | + |
| 199 | +Lint and type-check: |
| 200 | + |
| 201 | +```bash |
| 202 | +ruff check src/ |
| 203 | +mypy src/ |
| 204 | +``` |
| 205 | + |
| 206 | +## Contributing |
| 207 | + |
| 208 | +Contributions are welcome. Please open an issue before submitting a pull request for significant changes. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. |
| 209 | + |
| 210 | +## License |
| 211 | + |
| 212 | +Apache 2.0 — see [LICENSE](LICENSE) for details. |
0 commit comments