Code/bag_recorder_backend

bag_recorder_backend

yannick

README

Bag Recorder Backend

A 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.

Features

  • REST API for controlling bag recordings (start/stop/list/download/delete)
  • Generic topic recording - records any ROS2 message type without type-specific code
  • Batch operations - download or delete multiple recordings at once
  • CORS support - easily connect from a separate frontend application

Requirements

  • ROS2 (Humble or later recommended)
  • Crow C++ web framework
  • nlohmann/json (header-only, typically included with Crow)

Installation

Docker Build

cd bag_recorder_backend
docker build -t bag_recorder_backend .

Usage

Running with Docker

# Basic run (connects to host ROS2 network)
docker run --rm -it \
  --network host \
  -v /tmp/rosbags:/tmp/rosbags \
  bag_recorder_backend

# With custom output directory
docker run --rm -it \
  --network host \
  -v /path/to/bags:/bags \
  -e OUTPUT_DIR=/bags \
  bag_recorder_backend

# With custom port
docker run --rm -it \
  --network host \
  -e SERVER_PORT=9090 \
  bag_recorder_backend

API Reference

REST Endpoints

Method Endpoint Description
GET /api/status Get current recording status
GET /api/topics List available ROS topics
POST /api/recording/start Start a new recording
POST /api/recording/stop Stop current recording
GET /api/config Get server configuration
POST /api/config Update server configuration
GET /api/recordings List all recorded bag files
DELETE /api/recordings/<name> Delete a recording
GET /api/recordings/<name>/download Download recording as tar.gz
POST /api/recordings/download Download multiple recordings
POST /api/recordings/delete Delete multiple recordings

API Examples

Start Recording:

curl -X POST http://localhost:8080/api/recording/start \
  -H "Content-Type: application/json" \
  -d '{
    "topics": ["/camera/image_raw", "/imu/data"],
    "output_path": "/tmp/rosbags/my_recording"
  }'

Stop Recording:

curl -X POST http://localhost:8080/api/recording/stop

Get Status:

curl http://localhost:8080/api/status

List Recordings:

curl http://localhost:8080/api/recordings

Download Recording:

curl -O http://localhost:8080/api/recordings/recording_20231215_143022/download

Delete Recording:

curl -X DELETE http://localhost:8080/api/recordings/recording_20231215_143022

Configuration

Configuration is done via ROS2 parameters:

Parameter Default Description
server_port 8080 HTTP server port
output_directory /tmp/rosbags Default bag output directory
enable_cors true Enable CORS headers for frontend

See config/config.yaml for the full configuration file.

Architecture

┌─────────────────────────────────────────────────────────┐
│                      main.cpp                           │
│         (initialization, signal handling)               │
└─────────────────────┬───────────────────────────────────┘
                      │
        ┌─────────────┴─────────────┐
        │                           │
        ▼                           ▼
┌───────────────────┐      ┌────────────────────┐
│  BagRecorderNode  │◄────►│    CrowServer      │
│   (ROS2 node)     │      │    (HTTP API)      │
│                   │      │                    │
│ - Topic discovery │      │ - REST API routes  │
│ - Bag writing     │      │ - CORS handling    │
│ - Subscriptions   │      │                    │
└───────────────────┘      └────────────────────┘

License

MIT License

Quick Actions

Browse FilesView Commits
git clone https://rakys.xyz/git/bag_recorder_backend.git

Repository Statistics

0
Stars
0
Forks
1
Watchers
0
Issues
Default Branch:main
Primary Language:C++
Created:December 3, 2025
Last Updated:December 14, 2025
Repository Size:0.06 KB