# Scanner Debug Web

Minimal local web debug view for `obstacle_scanner`.

Run from WSL after the machine can see the ROS2 graph:

```bash
cd /mnt/d/Programme/agent/projects/yiliao/scanner_debug_web
./run.sh
```

Open:

```text
http://127.0.0.1:8767
```

Topics used:

- `/obstacles` (`obstacle_scanner/msg/ObstacleArray`)
- `/obstacle_scanner/debug_info` (`std_msgs/msg/String` JSON)
- `/scan` (`sensor_msgs/msg/LaserScan`)

If the `obstacle_scanner` message package is installed in a non-default workspace, set:

```bash
export YILIAO_WS_SETUP=/path/to/yiliao_ws/install/setup.bash
./run.sh
```

## Image Web Bridge

`image_web_bridge.py` forwards ROS2 image topics to a browser MJPEG stream.

It supports the image publishing modes used by `car_usb_cam`:

- `/image` (`sensor_msgs/msg/Image`) from `hobot_usb_cam` when `usb_zero_copy:=False`
- `/image_mjpeg` or `/image_jpeg` (`sensor_msgs/msg/CompressedImage`) from `hobot_codec`
- `/hbmem_img` (`hbm_img_msgs/msg/HbmMsg1080P`, `HbmMsg540P`, or `HbmMsg480P`) from zero-copy camera paths

`car_usb_cam` can switch camera output modes using launch parameters only:

```bash
# Native MJPEG output from the USB camera.
ros2 launch car_usb_cam hobot_usb_cam.launch.py \
  usb_zero_copy:=false \
  usb_pixel_format:=mjpeg
# Publishes /image as sensor_msgs/msg/CompressedImage.
```

```bash
# Zero-copy hbmem output for consumers such as hobot_llamacpp shared-memory mode.
ros2 launch car_usb_cam hobot_usb_cam.launch.py \
  usb_zero_copy:=true \
  usb_pixel_format:=mjpeg
# Publishes /hbmem_img as hbm_img_msgs/msg/HbmMsg1080P.
```

Run on RDKx5:

```bash
cd /home/sunrise/yiliao_ws/src/car_usb_cam
source /opt/ros/humble/setup.bash
source /opt/tros/humble/setup.bash
source /home/sunrise/yiliao_ws/install/setup.bash
python3 image_web_bridge.py --host 192.168.10.210 --port 8080 --topic /image_mjpeg
```

Open from another device on the same network:

```text
http://192.168.10.210:8080
```

Use explicit topic types when the publisher is not running yet:

```bash
python3 image_web_bridge.py --host 192.168.10.210 --port 8080 --topic /image --topic-type sensor_msgs/msg/Image
python3 image_web_bridge.py --host 192.168.10.210 --port 8080 --topic /image_mjpeg --topic-type sensor_msgs/msg/CompressedImage
python3 image_web_bridge.py --host 192.168.10.210 --port 8080 --topic /hbmem_img --topic-type hbm_img_msgs/msg/HbmMsg1080P
```

By default, JPEG `CompressedImage` topics are passed through without re-encoding.
Add `--compress` to force every frame sent to the browser through JPEG encoding,
using `--quality` as the output quality:

```bash
python3 image_web_bridge.py --host 192.168.10.164 --port 8080 --topic /image_mjpeg --compress --quality 45
```

The page header shows the current output FPS and total forwarded frame count.
