144 lines
3.9 KiB
Markdown
144 lines
3.9 KiB
Markdown
# Robot App Web (RBS)
|
|
|
|
Chức năng:
|
|
- Đăng ký danh sách cảm biến LiDAR (tên, ip, port)
|
|
- Đăng ký IMU (tên, frame_id, topic, nguồn) và pose trên robot
|
|
- Kéo thả icon LiDAR/IMU trên canvas để set vị trí (robot frame)
|
|
- Nhiều layout — mỗi layout lưu profile trong SQLite (`layout_profiles`); catalog trong document `state`
|
|
- Database SQLite: `data/RBS.db` (WAL mode). Thư mục media: `data/maps/`, `data/sounds/`, `data/recordings/`
|
|
|
|
## Build
|
|
|
|
```bash
|
|
cd /home/robotics/RD/RBS
|
|
# Ubuntu/Debian: sudo apt install libsqlite3-dev
|
|
cmake -S . -B build
|
|
cmake --build build -j
|
|
```
|
|
|
|
## Run
|
|
|
|
Chạy mặc định port 8080, phục vụ static từ `www/`, dữ liệu SQLite tại `data/RBS.db`:
|
|
|
|
```bash
|
|
./build/lidar_manager_web
|
|
```
|
|
|
|
Hoặc chỉ định:
|
|
|
|
```bash
|
|
./build/lidar_manager_web 8080 ./www ./data/RBS.db
|
|
```
|
|
|
|
Mở trình duyệt: `http://localhost:8080/`
|
|
|
|
### API Maps & Sounds (SQLite)
|
|
|
|
| Method | Endpoint | Mô tả |
|
|
|--------|----------|-------|
|
|
| GET | `/api/maps` | Danh sách map |
|
|
| POST | `/api/maps` | Tạo map (JSON metadata) |
|
|
| GET/PUT/DELETE | `/api/maps/{id}` | CRUD map |
|
|
| GET/POST | `/api/maps/{id}/image` | Tải/xem ảnh map (file trong `data/maps/{id}/`) |
|
|
| GET | `/api/sounds` | Danh sách sound |
|
|
| POST | `/api/sounds` | Tạo sound |
|
|
| GET/PUT/DELETE | `/api/sounds/{id}` | CRUD sound |
|
|
| GET/POST | `/api/sounds/{id}/file` | Tải/upload file âm thanh |
|
|
| GET/PUT | `/api/dashboards` | Dashboard (server-side, thay localStorage) |
|
|
| GET | `/api/recordings` | Stub — trả về `[]` (Phase sau) |
|
|
|
|
### Đăng nhập (Signing in — MiR §2.1)
|
|
|
|
Trang web **bắt buộc đăng nhập**. Hai tab: tên/mật khẩu hoặc **Mã PIN** (keypad 4 số). Tài khoản mặc định (trong `data/RBS.db`, seed lần đầu):
|
|
|
|
| User | Password | Nhóm |
|
|
|------|----------|------|
|
|
| Admin | admin | Administrators (full quyền) |
|
|
| User | user | Users (dashboard write, còn lại read) |
|
|
| Distributor | distributor | Distributors (full quyền) |
|
|
|
|
PIN 4 chữ số chỉ dùng được với user thuộc nhóm **Users** sau khi admin gán PIN (`PUT /api/users/:id`).
|
|
|
|
Tắt auth cho dev/test: `LM_AUTH_DISABLED=1 ./build/lidar_manager_web …`
|
|
Tài liệu đầy đủ: [`docs/Reference_guide.md` §2.1](docs/Reference_guide.md#21-signing-in).
|
|
|
|
## Docker (giới hạn 2 CPU, 4 GB RAM)
|
|
|
|
Mô phỏng cấu hình controller tối thiểu SICK (Dual-Core, 4 GB) trên máy dev:
|
|
|
|
```bash
|
|
cd /home/robotics/RD/RBS
|
|
./scripts/lm.sh docker up
|
|
# hoặc: sudo docker compose up --build -d
|
|
```
|
|
|
|
Kiểm tra giới hạn:
|
|
|
|
```bash
|
|
./scripts/lm.sh docker stats
|
|
```
|
|
|
|
Dừng:
|
|
|
|
```bash
|
|
./scripts/lm.sh docker down
|
|
```
|
|
|
|
Dữ liệu layout vẫn lưu tại `data/` trên host (volume mount).
|
|
|
|
Kiểm tra tài nguyên trong container:
|
|
|
|
```bash
|
|
# Vào shell container
|
|
./scripts/lm.sh docker shell
|
|
|
|
# Trong container, thử:
|
|
htop # CPU/RAM (q để thoát)
|
|
free -h # RAM
|
|
nproc # số CPU nhìn thấy
|
|
ps aux # process
|
|
cat /proc/meminfo | head
|
|
```
|
|
|
|
```bash
|
|
./scripts/lm.sh docker htop
|
|
./scripts/lm.sh docker stats
|
|
```
|
|
|
|
## Test tự động
|
|
|
|
Chạy toàn bộ: unit C++ (GTest), API smoke (`curl`), pytest integration.
|
|
|
|
```bash
|
|
cd /home/robotics/RD/RBS
|
|
chmod +x scripts/lm.sh scripts/test/*.sh
|
|
./scripts/lm.sh test run
|
|
```
|
|
|
|
Chỉ unit test C++:
|
|
|
|
```bash
|
|
cmake -S . -B build -DBUILD_TESTING=ON
|
|
cmake --build build -j
|
|
ctest --test-dir build --output-on-failure
|
|
```
|
|
|
|
Chỉ API smoke (server đang chạy, dùng fixture `tests/fixtures/data/`):
|
|
|
|
```bash
|
|
./build/lidar_manager_web 18080 www tests/fixtures/data/state.json &
|
|
./scripts/lm.sh test smoke http://127.0.0.1:18080
|
|
```
|
|
|
|
Fixture mission id mặc định: `testmission00001` (`tests/fixtures/data/missions.json`).
|
|
|
|
Benchmark hiệu năng trong container (cần `docker compose up -d`):
|
|
|
|
```bash
|
|
./scripts/lm.sh docker bench
|
|
# hoặc chỉ HTTP: ./scripts/lm.sh bench http
|
|
```
|
|
|
|
CI: GitHub Actions workflow `.github/workflows/test.yml`.
|
|
|