Edge TPU Accelerator + Posenet + Python + Sync + LaptopPC "+ ROS2".
Inspired by google-coral/project-posenet and PINTO0309/TPU-Posenet.
This repository makes it possible to perform Posenet estimation using TPU on ROS2.
Image messange publishing is slow (about 5Hz) because cv_bridge.cv2_to_imgmsg is slow on ROS2(ros2/rosidl_python#79). If you use opencv window, you can show fast results (about 50Hz) using single TPU.
1. Environment
2. Inference result
3. Introduction procedure
4. Usage
5. Reference articles
- Ubuntu 16.04
- (ROS 1 Kinetic) -> not need. But if you have already installed, you can ros1-ros2 bridge.
- ROS 2 Ardent
- OpenCV4.1.1-openvino
- Cv_bridge on python3
- Coral Edge TPU Accelerator
- USB Camera or ROSBAG
- Self-powered USB 3.0 Hub
- Python 3.5.2+
Install Edge TPU API and download models.
$ sudo apt-get update;sudo apt-get upgrade -y
$ sudo apt-get install -y python3-pip
$ sudo pip3 install pip --upgrade
$ sudo pip3 install numpy
$ wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
$ tar xzf edgetpu_api.tar.gz
$ sudo edgetpu_api/install.sh
$ git clone https://github.com/shunchan0677/TPU-Posenet-ROS2.git
$ cd TPU-Posenet-ROS2
$ cd models;./download.sh;cd ..
Install ROS2 and Cv_bridge.
### Install ROS2
sudo apt update && sudo apt install curl gnupg2 lsb-release
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
export CHOOSE_ROS_DISTRO=ardent
sudo apt update
sudo apt install ros-$CHOOSE_ROS_DISTRO-desktop
sudo apt update
sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-opensplice-cpp # for OpenSplice
sudo apt install ros-$CHOOSE_ROS_DISTRO-rmw-connext-cpp # for RTI Connext (requires license agreement)
### for ros1-ros2 bridge
sudo apt update
sudo apt install ros-$CHOOSE_ROS_DISTRO-ros1-bridge
### Build cv_bridge for python3
git clone https://github.com/ros-perception/vision_opencv.git
cd vision_opencv
git checkout ros2
vim CMakeLists.txt # Change Boost REQUIRED python -> python3(line18, 22)
colcon build --symlink-install
Publish image topic on ROS2 (need usb-camera)
source /opt/ros/ardent/setup.bash
ros2 run image_tools cam2image
Subscrive image topic and Estimate pose
source /opt/ros/ardent/setup.bash
source /home/<user>/vision_opencv/install/local_setup.bash
python3 pose_camera_sigle_tpu.py
Show Result Image on Rviz2
source /opt/ros/ardent/setup.bash
rviz2
If you want to ROS2-ROS1 bridge...(need to launch roscore)
source /opt/ros/ardent/setup.bash
ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
Edge TPU USB Accelerator analysis - I/O data transfer - Qiita - iwatake2222
ROS index : Installing ROS2 via Debian Packages (https://index.ros.org/doc/ros2/Installation/Crystal/Linux-Install-Debians/#install-additional-packages-using-ros-1-packages)
ROS index : cv_bridge (https://index.ros.org//p/cv_bridge/github-ros-perception-vision_opencv/)
ROS 1とROS 2のつながり(ros1_bridge) (https://gbiggs.github.io/rosjp_ros2_intro/ros1_bridge.html)
image callback in python very slow(ros2/ros2#509)