/
/
/
1# Bag Recorder Backend
2
3A ROS2 bag recorder backend with a REST API for controlling bag recordings. Designed as a simple developer tool for recording ROS topics into bag files via a web interface.
4
5## Features
6
7- **REST API** for controlling bag recordings (start/stop/list/download/delete)
8- **Generic topic recording** - records any ROS2 message type without type-specific code
9- **Batch operations** - download or delete multiple recordings at once
10- **CORS support** - easily connect from a separate frontend application
11
12## Requirements
13
14- ROS2 (Humble or later recommended)
15- Crow C++ web framework
16- nlohmann/json (header-only, typically included with Crow)
17
18## Installation
19
20### Docker Build
21
22```bash
23cd bag_recorder_backend
24docker build -t bag_recorder_backend .
25```
26
27## Usage
28
29### Running with Docker
30
31```bash
32# Basic run (connects to host ROS2 network)
33docker run --rm -it \
34 --network host \
35 -v /tmp/rosbags:/tmp/rosbags \
36 bag_recorder_backend
37
38# With custom output directory
39docker run --rm -it \
40 --network host \
41 -v /path/to/bags:/bags \
42 -e OUTPUT_DIR=/bags \
43 bag_recorder_backend
44
45# With custom port
46docker run --rm -it \
47 --network host \
48 -e SERVER_PORT=9090 \
49 bag_recorder_backend
50```
51
52## API Reference
53
54### REST Endpoints
55
56| Method | Endpoint | Description |
57|--------|----------|-------------|
58| `GET` | `/api/status` | Get current recording status |
59| `GET` | `/api/topics` | List available ROS topics |
60| `POST` | `/api/recording/start` | Start a new recording |
61| `POST` | `/api/recording/stop` | Stop current recording |
62| `GET` | `/api/config` | Get server configuration |
63| `POST` | `/api/config` | Update server configuration |
64| `GET` | `/api/recordings` | List all recorded bag files |
65| `DELETE` | `/api/recordings/<name>` | Delete a recording |
66| `GET` | `/api/recordings/<name>/download` | Download recording as tar.gz |
67| `POST` | `/api/recordings/download` | Download multiple recordings |
68| `POST` | `/api/recordings/delete` | Delete multiple recordings |
69
70### API Examples
71
72**Start Recording:**
73```bash
74curl -X POST http://localhost:8080/api/recording/start \
75 -H "Content-Type: application/json" \
76 -d '{
77 "topics": ["/camera/image_raw", "/imu/data"],
78 "output_path": "/tmp/rosbags/my_recording"
79 }'
80```
81
82**Stop Recording:**
83```bash
84curl -X POST http://localhost:8080/api/recording/stop
85```
86
87**Get Status:**
88```bash
89curl http://localhost:8080/api/status
90```
91
92**List Recordings:**
93```bash
94curl http://localhost:8080/api/recordings
95```
96
97**Download Recording:**
98```bash
99curl -O http://localhost:8080/api/recordings/recording_20231215_143022/download
100```
101
102**Delete Recording:**
103```bash
104curl -X DELETE http://localhost:8080/api/recordings/recording_20231215_143022
105```
106
107## Configuration
108
109Configuration is done via ROS2 parameters:
110
111| Parameter | Default | Description |
112|-----------|---------|-------------|
113| `server_port` | `8080` | HTTP server port |
114| `output_directory` | `/tmp/rosbags` | Default bag output directory |
115| `enable_cors` | `true` | Enable CORS headers for frontend |
116
117See `config/config.yaml` for the full configuration file.
118
119## Architecture
120
121```
122âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
123â main.cpp â
124â (initialization, signal handling) â
125âââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââââââ
126 â
127 âââââââââââââââ´ââââââââââââââ
128 â â
129 â¼ â¼
130âââââââââââââââââââââ ââââââââââââââââââââââ
131â BagRecorderNode âââââââºâ CrowServer â
132â (ROS2 node) â â (HTTP API) â
133â â â â
134â - Topic discovery â â - REST API routes â
135â - Bag writing â â - CORS handling â
136â - Subscriptions â â â
137âââââââââââââââââââââ ââââââââââââââââââââââ
138```
139
140## License
141
142MIT License
143