forked from zbw/yiliao2026
把去年的二维码检测、图生文客户端、锥桶检测v8给加了进来,二维码检测新增深度相机检测
This commit is contained in:
1
src/yolov8_launch/class_list/cone.list
Normal file
1
src/yolov8_launch/class_list/cone.list
Normal file
@@ -0,0 +1 @@
|
||||
cone
|
||||
239
src/yolov8_launch/launch/dnn_node_example.launch.py
Normal file
239
src/yolov8_launch/launch/dnn_node_example.launch.py
Normal file
@@ -0,0 +1,239 @@
|
||||
# Copyright (c) 2024,D-Robotics.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument
|
||||
from launch.actions import IncludeLaunchDescription
|
||||
from launch_ros.actions import Node
|
||||
from launch.substitutions import TextSubstitution
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from ament_index_python import get_package_share_directory
|
||||
from ament_index_python.packages import get_package_prefix
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
|
||||
# args that can be set from the command line or a default will be used
|
||||
config_file_launch_arg = DeclareLaunchArgument(
|
||||
"dnn_example_config_file", default_value=TextSubstitution(text="/root/yolov8workconfig.json")
|
||||
)
|
||||
dump_render_launch_arg = DeclareLaunchArgument(
|
||||
"dnn_example_dump_render_img", default_value=TextSubstitution(text="0")
|
||||
)
|
||||
image_width_launch_arg = DeclareLaunchArgument(
|
||||
"dnn_example_image_width", default_value=TextSubstitution(text="640")
|
||||
)
|
||||
image_height_launch_arg = DeclareLaunchArgument(
|
||||
"dnn_example_image_height", default_value=TextSubstitution(text="480")
|
||||
)
|
||||
msg_pub_topic_name_launch_arg = DeclareLaunchArgument(
|
||||
"dnn_example_msg_pub_topic_name", default_value=TextSubstitution(text="hobot_dnn_detection")
|
||||
)
|
||||
|
||||
camera_type = os.getenv('CAM_TYPE')
|
||||
camera_type = 'usb'
|
||||
print("camera_type is ", camera_type)
|
||||
|
||||
cam_node = None
|
||||
camera_type_mipi = None
|
||||
camera_device_arg = None
|
||||
|
||||
if camera_type == "usb":
|
||||
# usb cam图片发布pkg
|
||||
usb_cam_device_arg = DeclareLaunchArgument(
|
||||
'device',
|
||||
default_value='/dev/video8',
|
||||
description='usb camera device')
|
||||
|
||||
usb_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('hobot_usb_cam'),
|
||||
'launch/hobot_usb_cam.launch.py')),
|
||||
launch_arguments={
|
||||
'usb_image_width': LaunchConfiguration('dnn_example_image_width'),
|
||||
'usb_image_height': LaunchConfiguration('dnn_example_image_height'),
|
||||
'usb_video_device': LaunchConfiguration('device')
|
||||
}.items()
|
||||
)
|
||||
print("using usb cam")
|
||||
cam_node = usb_node
|
||||
camera_type_mipi = False
|
||||
camera_device_arg = usb_cam_device_arg
|
||||
|
||||
elif camera_type == "fb":
|
||||
# 本地图片发布
|
||||
feedback_picture_arg = DeclareLaunchArgument(
|
||||
'publish_image_source',
|
||||
default_value='./config/target.jpg',
|
||||
description='feedback picture')
|
||||
|
||||
publish_image_fps = DeclareLaunchArgument(
|
||||
'publish_image_fps',
|
||||
default_value='5',
|
||||
description='publish_image_fps picture')
|
||||
|
||||
fb_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('hobot_image_publisher'),
|
||||
'launch/hobot_image_publisher.launch.py')),
|
||||
launch_arguments={
|
||||
'publish_image_source': LaunchConfiguration('publish_image_source'),
|
||||
'publish_image_format': LaunchConfiguration('publish_image_format'),
|
||||
'publish_message_topic_name': '/hbmem_img',
|
||||
'publish_fps': LaunchConfiguration('publish_image_fps')
|
||||
}.items()
|
||||
)
|
||||
|
||||
print("using feedback")
|
||||
cam_node = fb_node
|
||||
camera_type_mipi = True
|
||||
camera_device_arg = feedback_picture_arg
|
||||
|
||||
else:
|
||||
if camera_type == "mipi":
|
||||
print("using mipi cam")
|
||||
else:
|
||||
print("invalid camera_type ", camera_type,
|
||||
", which is set with export CAM_TYPE=usb/mipi/fb, using default mipi cam")
|
||||
# mipi cam图片发布pkg
|
||||
mipi_cam_device_arg = DeclareLaunchArgument(
|
||||
'device',
|
||||
default_value='F37',
|
||||
description='mipi camera device')
|
||||
mipi_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('mipi_cam'),
|
||||
'launch/mipi_cam.launch.py')),
|
||||
launch_arguments={
|
||||
'mipi_image_width': LaunchConfiguration('dnn_example_image_width'),
|
||||
'mipi_image_height': LaunchConfiguration('dnn_example_image_height'),
|
||||
'mipi_io_method': 'shared_mem',
|
||||
'mipi_frame_ts_type': 'realtime',
|
||||
'mipi_video_device': LaunchConfiguration('device')
|
||||
}.items()
|
||||
)
|
||||
|
||||
cam_node = mipi_node
|
||||
camera_type_mipi = True
|
||||
camera_device_arg = mipi_cam_device_arg
|
||||
|
||||
# jpeg图片编码&发布pkg
|
||||
jpeg_codec_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('hobot_codec'),
|
||||
'launch/hobot_codec_encode.launch.py')),
|
||||
launch_arguments={
|
||||
'codec_in_mode': 'shared_mem',
|
||||
'codec_out_mode': 'ros',
|
||||
'codec_sub_topic': '/hbmem_img',
|
||||
'codec_pub_topic': '/image'
|
||||
}.items()
|
||||
)
|
||||
|
||||
# nv12图片解码&发布pkg
|
||||
nv12_codec_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('hobot_codec'),
|
||||
'launch/hobot_codec_decode.launch.py')),
|
||||
launch_arguments={
|
||||
'codec_in_mode': 'ros',
|
||||
'codec_out_mode': 'shared_mem',
|
||||
'codec_sub_topic': '/image',
|
||||
'codec_pub_topic': '/hbmem_img'
|
||||
}.items()
|
||||
)
|
||||
|
||||
# web展示pkg
|
||||
web_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('websocket'),
|
||||
'launch/websocket.launch.py')),
|
||||
launch_arguments={
|
||||
'websocket_image_topic': '/image',
|
||||
'websocket_image_type': 'mjpeg',
|
||||
'websocket_smart_topic': LaunchConfiguration("dnn_example_msg_pub_topic_name")
|
||||
}.items()
|
||||
)
|
||||
|
||||
# 算法pkg
|
||||
dnn_node_example_node = Node(
|
||||
package='dnn_node_example',
|
||||
executable='example',
|
||||
output='screen',
|
||||
parameters=[
|
||||
{"config_file": LaunchConfiguration('dnn_example_config_file')},
|
||||
{"dump_render_img": LaunchConfiguration(
|
||||
'dnn_example_dump_render_img')},
|
||||
{"feed_type": 1},
|
||||
{"is_shared_mem_sub": 1},
|
||||
{"msg_pub_topic_name": LaunchConfiguration(
|
||||
"dnn_example_msg_pub_topic_name")}
|
||||
],
|
||||
arguments=['--ros-args', '--log-level', 'warn']
|
||||
)
|
||||
|
||||
shared_mem_node = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(
|
||||
get_package_share_directory('hobot_shm'),
|
||||
'launch/hobot_shm.launch.py'))
|
||||
)
|
||||
|
||||
if camera_type_mipi:
|
||||
return LaunchDescription([
|
||||
camera_device_arg,
|
||||
config_file_launch_arg,
|
||||
dump_render_launch_arg,
|
||||
image_width_launch_arg,
|
||||
image_height_launch_arg,
|
||||
msg_pub_topic_name_launch_arg,
|
||||
# 启动零拷贝环境配置node
|
||||
# shared_mem_node,
|
||||
# 图片发布pkg
|
||||
cam_node,
|
||||
# 图片编解码&发布pkg
|
||||
nv12_codec_node,
|
||||
# 启动example pkg
|
||||
dnn_node_example_node,
|
||||
# 启动web展示pkg
|
||||
web_node
|
||||
])
|
||||
else:
|
||||
return LaunchDescription([
|
||||
camera_device_arg,
|
||||
config_file_launch_arg,
|
||||
dump_render_launch_arg,
|
||||
image_width_launch_arg,
|
||||
image_height_launch_arg,
|
||||
msg_pub_topic_name_launch_arg,
|
||||
# 启动零拷贝环境配置node
|
||||
# shared_mem_node,
|
||||
# 图片发布pkg
|
||||
cam_node,
|
||||
# 图片编解码&发布pkg
|
||||
nv12_codec_node,
|
||||
# 启动example pkg
|
||||
dnn_node_example_node,
|
||||
# 启动web展示pkg
|
||||
web_node
|
||||
])
|
||||
18
src/yolov8_launch/package.xml
Normal file
18
src/yolov8_launch/package.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>yolov8_launch</name>
|
||||
<version>0.0.0</version>
|
||||
<description>TODO: Package description</description>
|
||||
<maintainer email="root@todo.todo">root</maintainer>
|
||||
<license>TODO: License declaration</license>
|
||||
|
||||
<test_depend>ament_copyright</test_depend>
|
||||
<test_depend>ament_flake8</test_depend>
|
||||
<test_depend>ament_pep257</test_depend>
|
||||
<test_depend>python3-pytest</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_python</build_type>
|
||||
</export>
|
||||
</package>
|
||||
0
src/yolov8_launch/resource/yolov8_launch
Normal file
0
src/yolov8_launch/resource/yolov8_launch
Normal file
4
src/yolov8_launch/setup.cfg
Normal file
4
src/yolov8_launch/setup.cfg
Normal file
@@ -0,0 +1,4 @@
|
||||
[develop]
|
||||
script_dir=$base/lib/yolov8_launch
|
||||
[install]
|
||||
install_scripts=$base/lib/yolov8_launch
|
||||
27
src/yolov8_launch/setup.py
Normal file
27
src/yolov8_launch/setup.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from setuptools import find_packages, setup
|
||||
import os
|
||||
from glob import glob
|
||||
package_name = 'yolov8_launch'
|
||||
|
||||
setup(
|
||||
name=package_name,
|
||||
version='0.0.0',
|
||||
packages=find_packages(exclude=['test']),
|
||||
data_files=[
|
||||
('share/ament_index/resource_index/packages',
|
||||
['resource/' + package_name]),
|
||||
('share/' + package_name, ['package.xml']),
|
||||
('share/' + package_name + '/launch', glob('launch/*.launch.py')),
|
||||
],
|
||||
install_requires=['setuptools'],
|
||||
zip_safe=True,
|
||||
maintainer='root',
|
||||
maintainer_email='root@todo.todo',
|
||||
description='TODO: Package description',
|
||||
license='TODO: License declaration',
|
||||
tests_require=['pytest'],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
],
|
||||
},
|
||||
)
|
||||
25
src/yolov8_launch/test/test_copyright.py
Normal file
25
src/yolov8_launch/test/test_copyright.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2015 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_copyright.main import main
|
||||
import pytest
|
||||
|
||||
|
||||
# Remove the `skip` decorator once the source file(s) have a copyright header
|
||||
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
|
||||
@pytest.mark.copyright
|
||||
@pytest.mark.linter
|
||||
def test_copyright():
|
||||
rc = main(argv=['.', 'test'])
|
||||
assert rc == 0, 'Found errors'
|
||||
25
src/yolov8_launch/test/test_flake8.py
Normal file
25
src/yolov8_launch/test/test_flake8.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2017 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_flake8.main import main_with_errors
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.flake8
|
||||
@pytest.mark.linter
|
||||
def test_flake8():
|
||||
rc, errors = main_with_errors(argv=[])
|
||||
assert rc == 0, \
|
||||
'Found %d code style errors / warnings:\n' % len(errors) + \
|
||||
'\n'.join(errors)
|
||||
23
src/yolov8_launch/test/test_pep257.py
Normal file
23
src/yolov8_launch/test/test_pep257.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2015 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_pep257.main import main
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.linter
|
||||
@pytest.mark.pep257
|
||||
def test_pep257():
|
||||
rc = main(argv=['.', 'test'])
|
||||
assert rc == 0, 'Found code style errors / warnings'
|
||||
0
src/yolov8_launch/yolov8_launch/__init__.py
Normal file
0
src/yolov8_launch/yolov8_launch/__init__.py
Normal file
Reference in New Issue
Block a user