Unity-based AR interface for EEG/BCI-driven target selection and robot grasping.
The app receives brain signals via OSC, lets the user select and confirm objects in AR, and then sends the target ID to a robot controller (e.g., Raspberry Pi + MyCobot) via HTTP.
基于 Unity 的 脑机接口 + 增强现实 + 机械臂抓取 项目:通过脑电指令在手机 AR 画面中选择/确认目标物体,并将目标编号发送给机械臂端执行抓取任务。
This project is part of a larger BCI–AR–Robot closed-loop system:
-
BCI / EEG
- Emotiv (or other) EEG headset
- Motor imagery commands (e.g.,
/left,/right,/lift,/confirm) encoded as OSC messages
-
AR-BCI-Unity (this repo)
- Runs on an Android phone
- Uses AR (marker / QR / image tracking) to recognize multiple physical objects
- Uses EEG commands to move a “selection cursor” between objects and confirm the final target
- Highlights state:
- Idle – all targets white
- Selected – current target turns yellow and scales up
- Confirmed – target turns green, and its ID is sent to the robot
-
Robot side (e.g., Raspberry Pi + MyCobot)
- Receives the target ID (A/B/C/…) from the phone via HTTP (and/or OSC)
- Maps ID → visual marker ID (e.g., STAG / ArUco)
- Runs camera-based pose estimation + hand–eye calibration
- Executes the corresponding grasping motion
In short: 脑电信号 → 手机 AR 目标选择 → 发送目标编号 → 机械臂视觉识别并抓取。
-
EEG-driven target selection
- Use BCI commands to switch between multiple AR targets
- Final confirmation via a dedicated EEG command (e.g.,
/confirmor/lift)
-
AR-based multi-object scene
- Plane detection + marker / image tracking
- Each object is visualized as a 3D arrow / marker
- Dynamic color + scale to indicate selection state
-
Communication bridge
- OSC input from BCI → Unity (e.g., from BCI-OSC / Python scripts)
- HTTP POST (or OSC) output from Unity → robot controller
- Message format e.g.:
{ "target": "A" }
-
Test utilities
TestFile/test_confirm.pyfor sending test/confirmsignals to Unity when BCI is not available
At the top level:
AR-BCI-Unity/
├─ Assets/ # Unity assets: scenes, prefabs, scripts, materials, etc.
├─ Packages/ # Unity packages (AR Foundation, etc.)
├─ ProjectSettings/ # Unity project configuration
├─ TestFile/
│ └─ test_confirm.py # Python script to send OSC 'confirm' signal for testing
├─ .gitignore
└─ .vsconfig
Note: The detailed scripts and scenes are under
Assets/. Key components include AR setup, OSC receiver, and HTTP client for robot communication.
-
Unity (2020+; recommended an LTS version)
-
AR support:
- AR Foundation / ARCore XR Plugin (for Android)
- Properly configured AR scene (camera, session origin, etc.)
-
Mobile device:
- Android phone (e.g., Xiaomi 14) with ARCore support
-
EEG device (e.g., Emotiv EPOC series)
-
Software to send OSC:
- EmotivBCI + BCI-OSC (or any custom Python script)
- Network reachable from the phone (same Wi-Fi / hotspot)
-
Raspberry Pi (robot controller)
-
Robot arm (e.g., MyCobot 280Pi or similar)
-
Python 3.x environment
-
Flask (or similar HTTP server) to receive target ID, e.g.:
POST /targetwith JSON{ "target": "A" }
-
Vision + calibration code (STAG / ArUco marker detection, hand–eye calibration, etc.)
git clone https://github.com/Junzhe/AR-BCI-Unity.git
cd AR-BCI-Unity- Open the project in Unity Hub.
- Let Unity import all assets and packages.
- Open the main AR scene under
Assets/(e.g., your AR demo scene).
-
In Unity, locate the script / GameObject that receives OSC (e.g., a receiver component).
-
Set:
- Listening IP: usually
0.0.0.0on the phone - Port: must match the port used by your BCI OSC sender
- Listening IP: usually
-
Configure the expected OSC addresses, for example:
/left,/right— switch selected target/liftor/confirm— confirm the current target
-
Ensure the phone and PC are on the same network.
-
In
TestFile/test_confirm.py, set:UNITY_IP→ phone IPUNITY_PORT→ OSC port Unity listens on
-
Run:
python test_confirm.py
-
You should see the AR target change to a “confirmed” state in Unity.
-
In Unity, find the script that sends the target ID to the robot (e.g., HTTP client).
-
Set:
- Robot controller URL, e.g.:
http://<raspberry_pi_ip>:5000/target
- Robot controller URL, e.g.:
-
Confirm that the Raspberry Pi is running a Flask server like:
@app.route("/target", methods=["POST"]) def target(): data = request.get_json() target_code = data.get("target", "A") # Map target_code -> STAG/ArUco ID and start grasping ...
-
On EEG confirmation:
- Unity picks the current target (A/B/C…)
- Sends HTTP POST to
/target - Robot executes visual recognition + grasping pipeline
Default visual logic (可按需修改):
-
Initialization
- All AR targets are spawned as small white arrows
-
Selection (EEG /left, /right, …)
- Active target turns yellow
- Scale increases slightly to emphasize focus
-
Confirmation (EEG /confirm or /lift)
- Target turns green
- Unity continuously or once-off sends the target ID to the robot controller
- Robot starts grasping procedure
This interface is designed for zero-touch, multimodal interaction, combining EEG intent + AR visualization + robot actions.
-
Add screenshots / demo GIFs of the AR interface
-
Provide example Unity scenes and prefabs for quick start
-
Release sample Python code for:
- BCI OSC sender
- Flask robot controller + MyCobot grasping
-
Link to associated paper / preprint once published
This repository is developed as part of an ongoing research project on multimodal BCI–AR–Robot collaboration. If you use or extend this project for academic research, please consider acknowledging:
Junzhe Wang, et al. “EEG-Driven AR–Robot Grasping System for Zero-Touch Manipulation” (work in progress).
For questions, issues, or collaboration:
- Author: Junzhe Wang
- GitHub: @Junzhe
欢迎提 issue 或者直接联系作者,一起交流脑机接口 + AR + 机器人方向的研究与开发 🙌