Difference between revisions of "Advantech Robotic Suite/Container/Openvino Object Detection ROS Container"

From ESS-WIKI
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Openvino Object Detection ROS Container =
 
= Openvino Object Detection ROS Container =
  
A pre-configured container that integrates OpenVINO toolkit with ROS for efficient and accurate object detection in robotic applications.
+
A pre-configured container that integrates the [https://github.com/intel/ros2_openvino_toolkit OpenVINO toolkit with ROS] for efficient and accurate object detection in robotic applications. OpenVINO supports both '''NPU''' and '''iGPU''' acceleration, but the availability depends on the system's hardware and environment compatibility.
  
 
== How To ==
 
== How To ==
  
=== Download container ===
+
=== Download and install container ===
 
 
=== Start docker container ===
 
 
 
'''Step1: Launch the docker container of openvino_object_detection-ros2-humble'''
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ cd /usr/local/Advantech/ros/container/docker
+
$ wget https://iedgeblob.blob.core.windows.net/iedge-public/robotic_suite_extention_container/openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run
$ ./launch.sh dev-ros2-<ROS_DISTRO>
+
$ chmod +x openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run
 +
$ sudo ./openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<br>
  
'''Step2: Accessing the container for development and debugging'''
+
=== Modify config file ===
 +
* Openvino config file
 +
This file can be used to configure the input source, model, output, etc. For detailed configuration instructions, please refer to the [https://github.com/intel/ros2_openvino_toolkit/tree/master/sample/param ros2_openvino_toolkit] GitHub.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ docker exec -it dev-ros2-<ROS_DISTRO> bash
+
$ vim /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble/share/pipeline_object.yaml
 
</syntaxhighlight>
 
</syntaxhighlight>
  
&nbsp;
+
* Openvino launch file
 
+
This file can be used to configure how to launch openvino ros2 node. For detailed configuration instructions, please refer to the [https://github.com/intel/ros2_openvino_toolkit/tree/master/sample/launch ros2_openvino_toolkit] GitHub.
=== Examples ===
 
 
 
Examples demonstration&nbsp;on how to subscribe to and control services of other ROS2 nodes.
 
 
 
*'''[[Advantech_Robotic_Suite/Sample_Node#c.2B.2B_sample|C++ sample]]'''
 
*'''[[Advantech_Robotic_Suite/Sample_Node#rclnodejs_sample|rclnodejs sample]]'''
 
*'''[[Advantech_Robotic_Suite/Sample_Node#rclpy_sample|rclpy sample]]'''
 
*'''[[Advantech_Robotic_Suite/SUSI_Node|SUSI Node]]'''
 
*'''[[Advantech_Robotic_Suite/Modbus-Master_Node|Modbus-Master Node]]'''
 
*'''[[Advantech_Robotic_Suite/OPCUAClient_Node|OPCUAClient Node]]'''<br/> &nbsp;
 
 
 
=== Stop docker container ===
 
 
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ cd /usr/local/Advantech/ros/container/docker
+
$ vim /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble/share/pipeline_object.launch.py
$ ./stop.sh dev-ros2-<ROS_DISTRO>
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<br>
  
&nbsp;
+
=== Start docker container ===
 
+
'''Step1: Launch the docker container of openvino_object_detection-ros2-humble'''
== Build Your Docker Container ==
 
 
 
To build a Docker container for your ROS2 application and integrate Advantech's add-ons services, you can following the steps.
 
 
 
=== Step1: Define a Dockerfile ===
 
 
 
Create a file called "Dockerfile" that specifies the instructions for building the container based on '''dev-ros2-<ROS_DISTRO>'''. This file includes details such as the base image, dependencies, environment variables, and commands to run inside the container.
 
<pre>FROM advigw/dev-ros2-<ROS_DISTRO>:1.0.0
 
 
 
# 1. Copy prerequisites of your application into the container
 
# WORKDIR /root
 
# COPY prerequisite/<your_application> /root/prerequisite
 
 
 
# 2. Install dependencies or libraries
 
# RUN apt-get update
 
# RUN apt-get install <some_dependency>
 
 
 
# 3. Execute your application automatically upon container startup.
 
# CMD [<application_command>]
 
</pre>
 
 
 
=== Step2: Build the Docker image ===
 
 
 
Use the Docker command-line to build the Docker image based on the Dockerfile. This process involves pulling the necessary base image, executing the instructions in the Dockerfile, and creating a layered image with all the specified components.
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ docker build -t ros-example -f Dockerfile .
+
$ cd /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble
 +
$ ./launch.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Step3: Define the Docker Compose services ===
+
'''Step2: Launch rviz2 in [[Advantech Robotic Suite/Container/Utility ROS Container#Launch_RViz2|util-ros2-humble]] container'''
 
 
Create a file called "docker-compose.yml", in the Docker Compose file, define the services, their image references, and any necessary configurations such as environment variables, port mappings, volume bindings, etc. Use the syntax provided by Docker Compose to define each service.
 
<pre>version: '2.1'
 
 
 
services:
 
  ros-example:
 
    image: ros-example
 
    container_name: ros-example
 
    restart: always
 
    networks:
 
    - adv-ros-network
 
    logging:
 
      options:
 
      max-size: 10M
 
    environment:
 
    - ROS_DOMAIN_ID=${ROS_DOMAIN_ID}
 
 
 
networks:
 
  adv-ros-network:
 
    name: adv-ros-network
 
</pre>
 
 
 
=== Step4: Start the containers using Docker Compose ===
 
 
 
Execute the docker-compose up command in the directory where the Docker Compose file is located. This command will start the containers as defined in the Compose file.<br/> <span style="color:red;">Note: When using the docker-compose command, please avoid using 'sudo' if you need to use the ROS_DOMAIN_ID environment variable. Otherwise, the variable may not be found during execution.</span>
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ docker-compose -f docker-compose.yml up -d
+
$ cd /usr/local/Advantech/ros/container/docker
 +
$ ./launch.sh util-ros2-humble
 +
$ docker exec -it util-ros2-humble bash
 +
$ rviz2
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
[[File:ROS2 openvino object detection rviz.png|none|ROS2 openvino object detection rviz]]
 +
&nbsp;
 +
<br>
  
=== Step5: Test and validate ===
+
=== Quick start script ===
 
+
A quickstart script for launch OpenVINO object detection and RViz2. Users can customize this script for their own projects.
Open a new interactive bash shell within the container.
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ docker exec -it ros-example bash
+
$ cd /usr/local/Advantech/ros/container/docker/user-quick-scripts
 +
$ ./openvino-object-detection_rviz2.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Then test [[#Examples|ROS2 Example]] and your applications in container.
 

Latest revision as of 03:10, 17 December 2024

Openvino Object Detection ROS Container

A pre-configured container that integrates the OpenVINO toolkit with ROS for efficient and accurate object detection in robotic applications. OpenVINO supports both NPU and iGPU acceleration, but the availability depends on the system's hardware and environment compatibility.

How To

Download and install container

$ wget https://iedgeblob.blob.core.windows.net/iedge-public/robotic_suite_extention_container/openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run
$ chmod +x openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run
$ sudo ./openvino_object_detection-ros2-humble-1.0.0-Ubuntu_x86.run


Modify config file

  • Openvino config file

This file can be used to configure the input source, model, output, etc. For detailed configuration instructions, please refer to the ros2_openvino_toolkit GitHub.

$ vim /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble/share/pipeline_object.yaml
  • Openvino launch file

This file can be used to configure how to launch openvino ros2 node. For detailed configuration instructions, please refer to the ros2_openvino_toolkit GitHub.

$ vim /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble/share/pipeline_object.launch.py


Start docker container

Step1: Launch the docker container of openvino_object_detection-ros2-humble

$ cd /usr/local/Advantech/ros/container/ros-extension/openvino_object_detection-ros2-humble
$ ./launch.sh

Step2: Launch rviz2 in util-ros2-humble container

$ cd /usr/local/Advantech/ros/container/docker
$ ./launch.sh util-ros2-humble
$ docker exec -it util-ros2-humble bash
$ rviz2
ROS2 openvino object detection rviz

 

Quick start script

A quickstart script for launch OpenVINO object detection and RViz2. Users can customize this script for their own projects.

$ cd /usr/local/Advantech/ros/container/docker/user-quick-scripts
$ ./openvino-object-detection_rviz2.sh