Azure KinectをUbuntu 22.04 ROS2 Humbleで動かす手順
1. Azure Kinect SDKのインストール
1.1. .debファイルのダウンロード
以下のコマンドを実行して、Azure Kinect SDKの.debファイルをダウンロードします。
wget -P /tmp https://github.com/asukiaaa/Azure-Kinect-Sensor-SDK/releases/download/2923-08-26-ubuntu-22-04/libk4a1.4\_1.4.1\_amd64.deb
1.2. .debファイルのインストール
ダウンロードした.debファイルをインストールします。
sudo apt install /tmp/libk4a1.4\_1.4.1\_amd64.deb
1.3. USBの再接続
インストール後、Azure KinectのUSBケーブルを抜き差しして、デバイスを再認識させます。
2. ROS2 Humble用Azure Kinectドライバーの設定
2.1. 99-k4a.rules
ファイルのダウンロードと配置
Azure Kinectをroot権限なしで利用するために、99-k4a.rules
ファイルをダウンロードし、/etc/udev/rules.d/
に配置します。
wget https://raw.githubusercontent.com/microsoft/Azure-Kinect-Sensor-SDK/develop/scripts/99-k4a.rules
sudo cp 99-k4a.rules /etc/udev/rules.d/
2.2. Azure_Kinect_ROS_Driverのビルド
ROS2 Humble用のAzure Kinectドライバーをビルドします。まず、ROS2のワークスペースを作成し、ドライバーのリポジトリをクローンします。
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone -b humble https://github.com/microsoft/Azure_Kinect_ROS_Driver.git
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install
2.3. ROS2ノードの起動確認
ビルドが完了したら、ROS2ノードを起動してAzure Kinectが認識されているか確認します。
source install/setup.bash
ros2 launch azure_kinect_ros_driver driver.launch.py
3. 動作確認 (Python Wrapper)
Azure Kinect SDKのインストールとROS2ドライバーの設定が完了したら、Pythonのwrapper (pyk4a
) を利用して動作確認を行うことができます。
3.1. pyk4a
のインストール
sudo apt install python3-pip
pip3 install pyk4a
3.2. 深度ビューアの実行
pyk4a
のサンプルコードである深度ビューアをダウンロードして実行します。helpers.py
も一緒にダウンロードしてください。
wget -P /tmp https://raw.githubusercontent.com/etiennedub/pyk4a/master/example/helpers.py https://raw.githubusercontent.com/etiennedub/pyk4a/master/example/viewer_depth.py
python3 /tmp/viewer_depth.py
これにより、Azure Kinectから取得した深度情報が表示され、SDKとドライバーが正しく動作していることを確認できます。
4. アンインストール
Azure Kinect SDKをアンインストールする場合は、以下のコマンドを実行します。
sudo apt autoremove libk4a1.4
5. 参考資料
- [1] asukiaaa. 試行錯誤な日々: azure kinectをubuntu22.04で動かすためのdebファイルを作った. (参照 2025-06-11). https://asukiaaa.blogspot.com/2023/08/deb-file-of-azure-kinect-sdk-for-ubuntu-2204.html
- [2] jlblancoc. Install Azure Kinect DK on Ubuntu 22.04 or newer · GitHub. (参照 2025-06-11). https://gist.github.com/jlblancoc/ae2a082b0ed5af2e71645b04b7207210
- [3] microsoft. Azure_Kinect_ROS_Driver. (参照 2025-06-11). https://github.com/microsoft/Azure_Kinect_ROS_Driver/tree/humble