Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 03116af

Browse files
authored
Updates to readme and camera node selection based on OS. (#17)
* Updates to readme and camera node selection based on OS. * removed the engine block stl and added instructions to download. * Updated date. * README fixes for Linux * c_str to fix build error on linux. * Fixed link in README * Made path to STL explicit in README. * Switched to OTL cv_camera for linux and formatted link in README
1 parent c2fa5f2 commit 03116af

File tree

5 files changed

+121
-52
lines changed

5 files changed

+121
-52
lines changed

README.md

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
# ONNX (Open Neural Network Exchange) ROS Node
1+
# ONNX (Open Neural Network Exchange) ROS 1 Node
22

3-
## Consuming Onnx
4-
Requirements:
3+
[ONNX Runtime](https://github.com/microsoft/onnxruntime) is an open source inference engine for ONNX Models.
4+
ONNX Runtime Execution Providers (EPs) enables the execution of any ONNX model using a single set of inference APIs that provide access to the best hardware acceleration available.
55

6-
* Install Visual Studio 2019 with UWP development
7-
* ROS Noetic for Windows
6+
In simple terms, developers no longer need to worry about the nuances of hardware specific custom libraries to accelerate their machine learning models.
7+
This repository demonstrates that by enabling the same code with ROS 2 to run on different hardware platforms using their respective AI acceleration libraries for optimized execution of the ONNX model.
88

9-
The Onnx ROS Node is distrubted as source. To consume it in your robot, clone the ros_msft_onnx sources into your workspace.
9+
## System Requirement
10+
11+
* Microsoft Windows 10 64-bit or Ubuntu 20.04 LTS x86_64
12+
* ROS Noetic
13+
* To make use of the hardware acceleration, the system is required to be compatible with [**CUDA 10.1**](https://developer.nvidia.com/cuda-toolkit) and [**cuDNN 7.6.5**](https://developer.nvidia.com/cudnn).
1014

11-
For example:
15+
> For GPU support, please follow the installation steps on NVIDIA portal before proceeding.
16+
17+
## How to Build
18+
The Onnx ROS Node is distrubted as source. To consume it in your robot, clone the ros_msft_onnx sources into your workspace.
1219

20+
* Windows
1321
```Batchfile
1422
mkdir c:\workspace\onnx_demo\src
1523
cd c:\workspace\onnx_demo\src
@@ -19,9 +27,66 @@ git clone https://github.com/ms-iot/ros_msft_onnx -b noetic-devel
1927
git clone https://github.com/ms-iot/ros_msft_camera --recursive
2028
```
2129

22-
There are two launch files included as samples in the launch folder. `tracker.launch` demonstrates tracking people in images/video and `pose.launch` demonstrates estimating the position and rotation of an engine block from images\video. To run the engine pose demo, copy the [Engine pose ONNX model](https://github.com/ms-iot/ros_msft_onnx_demo/releases/download/0.0/engine.onnx) to `ros_msft_onnx/testdata/`.
30+
* Ubuntu
31+
```sh
32+
mkdir -p onnx_demo/src
33+
cd onnx_demo/src
34+
git clone https://github.com/ms-iot/ros_msft_onnx -b noetic-devel
35+
36+
#For running the samples, clone `ros_msft_camera` as well
37+
git clone https://github.com/OTL/cv_camera --recursive
38+
```
39+
40+
## Building
41+
ONNX Runtime team is releasing different binaries for CPU and GPU (CUDA) support. To switch between the two, a workspace rebuild is required.
42+
43+
44+
Make sure to source your ROS version before building.
45+
46+
* CPU Processing
47+
48+
```Batchfile
49+
cd onnx_demo
50+
51+
catkin_make -DCUDA_SUPPORT=OFF
52+
```
53+
54+
* GPU Processing (CUDA)
55+
56+
```Batchfile
57+
cd onnx_demo
58+
59+
catkin_make -DCUDA_SUPPORT=ON
60+
```
61+
62+
## Running the samples
63+
There are two launch files included as samples in the launch folder.
64+
An object tracking demo and a deep pose detection demo.
65+
66+
### Person Tracker Demo
67+
`tracker.launch` demonstrates tracking people in images/video.
68+
69+
To run the person tracking detection demo, source the workspace and then roslaunch the launch file.
70+
71+
```Batchfile
72+
c:\workspace\devel\setup.bat
73+
roslaunch ros_msft_onnx tracker.launch
74+
```
75+
76+
In another command prompt or terminal, run rviz and add the `/tracked_objects/image` topic to see the highlighted people when they have been detected.
77+
```Batchfile
78+
rosrun rviz rviz
79+
```
2380

24-
To use hardware accelleration, install [CUDA Toolkit 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base) and [cuDNN v7 for CUDA 10.1](https://developer.nvidia.com/rdp/cudnn-archive).
81+
### Deep Pose Detection Demo
82+
`pose.launch` demonstrates estimating the position and rotation of an engine block from images\video.In preperation for running the engine pose demo:
83+
* Copy [Engine pose ONNX model](https://github.com/ms-iot/ros_msft_onnx_demo/releases/download/0.0/engine.onnx) to `ros_msft_onnx/testdata/`.
84+
* Download the `Engine_Block_-_Scaled.stl` mesh from [Thingiverse](https://www.thingiverse.com/thing:1911808) designed by Eric Harrell, and used with permission. Move or copy it into `ros_msft_onnx/testdata/`.
85+
86+
To run the engine pose detection demo, source the workspace and then roslaunch the launch file.
87+
```Batchfile
88+
roslaunch ros_msft_onnx pose.launch
89+
```
2590

2691
For your own project, you can create a launch file in the following format:
2792

@@ -54,7 +119,7 @@ For your own project, you can create a launch file in the following format:
54119
</launch>
55120
```
56121

57-
> While 'Pose' processing is enabled, the service required to generate the model has not been published as of October 2020
122+
> While 'Pose' processing is enabled, the service required to generate the model has not been published as of April 2021
58123
59124
## Property Descriptions
60125

@@ -75,29 +140,6 @@ For your own project, you can create a launch file in the following format:
75140
| model_bounds| 9 coordinates used to perform the point in perspective caluclation for pose |
76141
| calibration | Path to the OpenCV calibration file for point in persective |
77142

78-
## Building
79-
Make sure to source your ROS version before building. Then use catkin_make to build.
80-
```Batchfile
81-
cd c:\workspace\src
82-
catkin_make
83-
```
84-
85-
## Running the samples
86-
To run the samples, first source the workspace:
87-
```Batchfile
88-
cd c:\workspace\devel\setup.bat
89-
```
90-
91-
Then, for the tracker sample run:
92-
```Batchfile
93-
roslaunch ros_msft_onnx tracker.launch
94-
```
95-
96-
For the engine pose sample run:
97-
```Batchfile
98-
roslaunch ros_msft_onnx pose.launch
99-
```
100-
101143
## Subscriptions
102144
Onnx subscribes to the topic listed in the `image_topic` property, or `/camera/image_raw`
103145

ros_msft_onnx/launch/pose.launch

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<launch>
22
<!-- The engine ONNX model can be optained from the release on github and added to the testdata folder. -->
33
<arg name="onnx_model_path_arg" default="$(find ros_msft_onnx)/testdata/engine.onnx"/>
4+
<arg name="os_windows_arg" value="$(eval 'false' if not optenv('OS', 'unknown').lower().startswith('windows') else 'true')" />
45
<arg name="model_bounds_arg" default="[0.00, -56.00, 0.00, -80.48, -112.00, -90.82, 80.48, -112.00, -90.82,80.48, 0.00, -90.82,-80.48, 0.00, -90.82,-80.48, -112.00, 90.82,80.48, -112.00, 90.82, 80.48, 0.00, 90.82,-80.48, 0.00, 90.82]"/>
56
<arg name="tracker_type_arg" default="pose"/>
6-
<arg name="mesh_resource_arg" default="package://ros_msft_onnx/testdata/meshes/Engine_Block.stl"/>
7+
<arg name="mesh_resource_arg" default="package://ros_msft_onnx/testdata/Engine_Block_-_Scaled.stl"/>
78
<arg name="ros_msft_onnx_fake_arg" default="false"/>
89
<arg name="mesh_rotation_arg" default="[0, 0, 1.57]"/>
910
<arg name="confidence_arg" default=".5"/>
@@ -21,20 +22,31 @@
2122
<param name="mesh_scale" type="yaml" value="$(arg mesh_scale_arg)"/>
2223
<param name="ros_msft_onnx_fake" value="$(arg ros_msft_onnx_fake_arg)"/>
2324
<param name="link_name" value="$(arg ros_msft_onnx_link_name_arg)"/>
24-
<param name="image_topic" value="/camera/image_raw" />
25+
<param name="image_topic" value="$(eval '/camera/image_raw' if os_windows_arg else '/cv_camera/image_raw')"/>
2526
<param name="debug" value="$(arg debug_arg)" />
2627
<!-- param name="calibration" value="$(find k4a_arm_support)/calibration/ost.yaml" if="$(arg use_ros_msft_onnx)"/ -->
2728

2829
<!-- param name="image_topic" value="/image_publisher/image_raw" / -->
2930
</node>
3031

31-
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
32-
<node pkg="ros_msft_camera" type="ros_msft_camera_node" name="camera">
33-
<param name="camera_info_url" value="file://$(find ros_msft_camera)/config/default_calibration.yaml" />
34-
<param name="frame_id" value="camera" />
35-
<param name="image_width" value="1280" />
36-
<param name="image_height" value="720" />
37-
<param name="frame_rate" value="30.0" />
38-
</node>
32+
<!-- The camera node will be selected based on os. ros_msft_camera for Windows and cv_camera for others. -->
33+
<group if="$(arg os_windows_arg)" >
34+
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
35+
<node pkg="ros_msft_camera" type="ros_msft_camera_node" name="camera">
36+
<param name="camera_info_url" value="file://$(find ros_msft_camera)/config/default_calibration.yaml" />
37+
<param name="frame_id" value="camera" />
38+
<param name="image_width" value="1280" />
39+
<param name="image_height" value="720" />
40+
<param name="frame_rate" value="30.0" />
41+
</node>
42+
</group>
3943

44+
<group unless="$(arg os_windows_arg)" >
45+
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
46+
<node pkg="cv_camera" type="cv_camera_node" name="cv_camera" output="screen">
47+
<param name="rate" type="double" value="5.0"/>
48+
<param name="image_width" type="double" value="640"/>
49+
<param name="image_height" type="double" value="480"/>
50+
</node>
51+
</group>
4052
</launch>

ros_msft_onnx/launch/tracker.launch

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
<launch>
22
<arg name="onnx_model_path_arg" default="$(find ros_msft_onnx)/testdata/model.onnx"/>
3+
<arg name="os_windows_arg" value="$(eval 'false' if not optenv('OS', 'unknown').lower().startswith('windows') else 'true')" />
4+
35
<node pkg="ros_msft_onnx" type="ros_msft_onnx_node" name="ros_msft_onnx" output="screen">
46
<param name="onnx_model_path" value="$(arg onnx_model_path_arg)"/>
57
<param name="confidence" value="0.5"/>
68
<param name="tensor_width" value="416"/>
79
<param name="tensor_height" value="416"/>
810
<param name="tracker_type" value="yolo"/>
911
<param name="image_processing" value="resize"/>
12+
<param name="image_topic" value="$(eval '/camera/image_raw' if os_windows_arg else '/cv_camera/image_raw')"/>
1013
<param name="debug" value="true"/>
1114
</node>
1215

13-
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
14-
<node pkg="ros_msft_camera" type="ros_msft_camera_node" name="camera">
15-
<param name="camera_info_url" value="file://$(find ros_msft_camera)/config/default_calibration.yaml" />
16-
<param name="frame_id" value="camera" />
17-
<param name="image_width" value="1280" />
18-
<param name="image_height" value="720" />
19-
<param name="frame_rate" value="30.0" />
20-
</node>
16+
<!-- The camera node will be selected based on os. ros_msft_camera for Windows and cv_camera for others. -->
17+
<group if="$(arg os_windows_arg)" >
18+
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
19+
<node pkg="ros_msft_camera" type="ros_msft_camera_node" name="camera">
20+
<param name="camera_info_url" value="file://$(find ros_msft_camera)/config/default_calibration.yaml" />
21+
<param name="frame_id" value="camera" />
22+
<param name="image_width" value="1280" />
23+
<param name="image_height" value="720" />
24+
<param name="frame_rate" value="30.0" />
25+
</node>
26+
</group>
27+
28+
<group unless="$(arg os_windows_arg)" >
29+
<!-- NOTE: The image properties need to be valid for the camera, or the node will auto select the closest values -->
30+
<node pkg="cv_camera" type="cv_camera_node" name="cv_camera" output="screen">
31+
<param name="rate" type="double" value="5.0"/>
32+
<param name="image_width" type="double" value="640"/>
33+
<param name="image_height" type="double" value="480"/>
34+
</node>
35+
</group>
2136

2237
<node pkg="tf" type="static_transform_publisher" name="onnx_link"
2338
args="0 -0.02 0 0 0 0 map base_link 100" />

ros_msft_onnx/src/ros_msft_onnx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool OnnxProcessor::init(ros::NodeHandle& nh, ros::NodeHandle& nhPrivate)
5858
}
5959
else
6060
{
61-
ROS_WARN("ONNX: unknown image processing type: %s", imageProcessingType);
61+
ROS_WARN("ONNX: unknown image processing type: %s", imageProcessingType.c_str());
6262
// default;
6363
}
6464
}
-18.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)