Skip to content

Commit 42d5575

Browse files
committed
Initial vision tutorial for driving using gestures
1 parent a11a77d commit 42d5575

20 files changed

+1424
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ffmpeg_encoder:
2+
ros__parameters:
3+
ffmpeg_image_transport:
4+
qmax: 24
5+
preset: ultrafast
6+
tune: zerolatency
7+
bit_rate: 800000
8+
gop_size: 6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2024 Clearpath Robotics, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# @author Hilary Luo ([email protected])
18+
19+
# from ament_index_python.packages import get_package_share_directory
20+
from launch import LaunchDescription
21+
from launch.actions.declare_launch_argument import DeclareLaunchArgument
22+
from launch.substitutions import LaunchConfiguration
23+
from launch_ros.actions import Node
24+
25+
26+
def generate_launch_description():
27+
namespace = LaunchConfiguration('namespace')
28+
# ffmpeg_param_file = LaunchConfiguration('ffmpeg_param_file')
29+
30+
# turtlebot4_vision_tutorials = get_package_share_directory('turtlebot4_vision_tutorials')
31+
32+
# arg_parameters = DeclareLaunchArgument(
33+
# 'ffmpeg_param_file',
34+
# default_value=PathJoinSubstitution(
35+
# [turtlebot4_vision_tutorials, 'config', 'ffmpeg.yaml']),
36+
# description='Turtlebot4 ffmpeg compression param file'
37+
# )
38+
39+
arg_namespace = DeclareLaunchArgument(
40+
'namespace',
41+
default_value='')
42+
43+
# parameters = RewrittenYaml(
44+
# source_file=ffmpeg_param_file,
45+
# root_key=namespace,
46+
# param_rewrites={},
47+
# convert_types=True)
48+
49+
ffmpeg_node = Node(
50+
package='turtlebot4_vision_tutorials',
51+
executable='pose_detection',
52+
namespace=namespace,
53+
name='pose_detection',
54+
# parameters=[parameters],
55+
)
56+
57+
ld = LaunchDescription()
58+
# ld.add_action(arg_parameters)
59+
ld.add_action(arg_namespace)
60+
ld.add_action(ffmpeg_node)
61+
62+
return ld
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2024 Clearpath Robotics, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# @author Hilary Luo ([email protected])
18+
19+
from ament_index_python.packages import get_package_share_directory
20+
from launch import LaunchDescription
21+
from launch.actions.declare_launch_argument import DeclareLaunchArgument
22+
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
23+
from launch_ros.actions import Node
24+
25+
from nav2_common.launch import RewrittenYaml
26+
27+
28+
def generate_launch_description():
29+
namespace = LaunchConfiguration('namespace')
30+
ffmpeg_param_file = LaunchConfiguration('ffmpeg_param_file')
31+
32+
turtlebot4_vision_tutorials = get_package_share_directory('turtlebot4_vision_tutorials')
33+
34+
arg_parameters = DeclareLaunchArgument(
35+
'ffmpeg_param_file',
36+
default_value=PathJoinSubstitution(
37+
[turtlebot4_vision_tutorials, 'config', 'ffmpeg.yaml']),
38+
description='Turtlebot4 ffmpeg compression param file'
39+
)
40+
41+
arg_namespace = DeclareLaunchArgument(
42+
'namespace',
43+
default_value='')
44+
45+
parameters = RewrittenYaml(
46+
source_file=ffmpeg_param_file,
47+
root_key=namespace,
48+
param_rewrites={},
49+
convert_types=True)
50+
51+
ffmpeg_node = Node(
52+
package='image_transport',
53+
executable='republish',
54+
namespace=namespace,
55+
name='ffmpeg_encoder',
56+
remappings=[
57+
('in', "oakd/rgb/preview/image_raw"),
58+
('out/ffmpeg', "oakd/rgb/preview/encoded/ffmpeg"),
59+
],
60+
arguments=['raw', 'ffmpeg'],
61+
parameters=[parameters],
62+
)
63+
64+
ld = LaunchDescription()
65+
ld.add_action(arg_parameters)
66+
ld.add_action(arg_namespace)
67+
ld.add_action(ffmpeg_node)
68+
69+
return ld
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2024 Clearpath Robotics, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# @author Hilary Luo ([email protected])
18+
19+
from launch import LaunchDescription
20+
from launch.actions.declare_launch_argument import DeclareLaunchArgument
21+
from launch.substitutions import LaunchConfiguration
22+
from launch_ros.actions import Node
23+
24+
25+
def generate_launch_description():
26+
namespace = LaunchConfiguration('namespace')
27+
28+
arg_namespace = DeclareLaunchArgument(
29+
'namespace',
30+
default_value='')
31+
32+
parameters = {
33+
"/cpr_donatello/ffmpeg_decoder": {
34+
"ros__parameters": {
35+
"qos_overrides": {
36+
"/cpr_donatello/oakd/rgb/preview/encoded/ffmpeg": {
37+
"subscriber": {
38+
"reliability": "best_effort",
39+
"depth": 10,
40+
"history": "keep_last"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
48+
ffmpeg_node = Node(
49+
package='image_transport',
50+
executable='republish',
51+
namespace=namespace,
52+
name='ffmpeg_decoder',
53+
remappings=[
54+
('in/ffmpeg', "oakd/rgb/preview/encoded/ffmpeg"),
55+
('out', "oakd/rgb/preview/ffmpeg_decoded"),
56+
],
57+
arguments=['ffmpeg', 'raw'],
58+
parameters=[parameters],
59+
)
60+
61+
ld = LaunchDescription()
62+
ld.add_action(arg_namespace)
63+
ld.add_action(ffmpeg_node)
64+
65+
return ld
Binary file not shown.
Binary file not shown.
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>turtlebot4_vision_tutorials</name>
5+
<version>0.0.0</version>
6+
<description>TurtleBot Vision Tutorials</description>
7+
<maintainer email="[email protected]">Hilary Luo</maintainer>
8+
<license>Apache 2.0</license>
9+
10+
<test_depend>ament_copyright</test_depend>
11+
<test_depend>ament_flake8</test_depend>
12+
<test_depend>ament_pep257</test_depend>
13+
<test_depend>python3-pytest</test_depend>
14+
15+
<exec_depend>cv_bridge</exec_depend>
16+
<exec_depend>depthai</exec_depend>
17+
<exec_depend>ffmpeg_image_transport</exec_depend>
18+
<exec_depend>irobot_create_msgs</exec_depend>
19+
<exec_depend>rclpy</exec_depend>
20+
<exec_depend>geometry_msgs</exec_depend>
21+
<exec_depend>sensor_msgs</exec_depend>
22+
<exec_depend>std_msgs</exec_depend>
23+
24+
<export>
25+
<build_type>ament_python</build_type>
26+
</export>
27+
</package>

turtlebot4_vision_tutorials/resource/turtlebot4_vision_tutorials

Whitespace-only changes.

turtlebot4_vision_tutorials/setup.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[develop]
2+
script_dir=$base/lib/turtlebot4_vision_tutorials
3+
[install]
4+
install_scripts=$base/lib/turtlebot4_vision_tutorials

turtlebot4_vision_tutorials/setup.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from glob import glob
2+
import os
3+
4+
from setuptools import setup
5+
6+
package_name = 'turtlebot4_vision_tutorials'
7+
8+
setup(
9+
name=package_name,
10+
version='0.0.0',
11+
packages=[package_name],
12+
data_files=[
13+
('share/ament_index/resource_index/packages',
14+
['resource/' + package_name]),
15+
('share/' + package_name, ['package.xml']),
16+
(os.path.join('share', package_name, 'models'), glob('models/*.blob')),
17+
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
18+
(os.path.join('share', package_name, 'config'), glob('config/*.yaml')),
19+
],
20+
install_requires=['setuptools'],
21+
zip_safe=True,
22+
maintainer='hilary-luo',
23+
maintainer_email='[email protected]',
24+
description='TurtleBot 4 Vision Tutorials',
25+
license='Apache 2.0',
26+
tests_require=['pytest'],
27+
entry_points={
28+
'console_scripts': [
29+
'pose_detection = turtlebot4_vision_tutorials.pose_detection:main',
30+
'pose_display = turtlebot4_vision_tutorials.pose_display:main',
31+
],
32+
},
33+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2015 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from ament_copyright.main import main
16+
import pytest
17+
18+
19+
@pytest.mark.copyright
20+
@pytest.mark.linter
21+
def test_copyright():
22+
rc = main(argv=['.', 'test'])
23+
assert rc == 0, 'Found errors'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2017 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from ament_flake8.main import main_with_errors
16+
import pytest
17+
18+
19+
@pytest.mark.flake8
20+
@pytest.mark.linter
21+
def test_flake8():
22+
rc, errors = main_with_errors(argv=[])
23+
assert rc == 0, \
24+
'Found %d code style errors / warnings:\n' % len(errors) + \
25+
'\n'.join(errors)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2015 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from ament_pep257.main import main
16+
import pytest
17+
18+
19+
@pytest.mark.linter
20+
@pytest.mark.pep257
21+
def test_pep257():
22+
rc = main(argv=['.', 'test'])
23+
assert rc == 0, 'Found code style errors / warnings'

0 commit comments

Comments
 (0)