Skip to content

Commit

Permalink
Initial vision tutorial for driving using gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
hilary-luo committed Sep 26, 2024
1 parent a11a77d commit 78cd441
Show file tree
Hide file tree
Showing 20 changed files with 1,424 additions and 0 deletions.
8 changes: 8 additions & 0 deletions turtlebot4_vision_tutorials/config/ffmpeg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ffmpeg_encoder:
ros__parameters:
ffmpeg_image_transport:
qmax: 24
preset: ultrafast
tune: zerolatency
bit_rate: 800000
gop_size: 6
62 changes: 62 additions & 0 deletions turtlebot4_vision_tutorials/launch/pose_detection.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3

# Copyright 2024 Clearpath Robotics, 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.
#
# @author Hilary Luo ([email protected])

# from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions.declare_launch_argument import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
namespace = LaunchConfiguration('namespace')
# ffmpeg_param_file = LaunchConfiguration('ffmpeg_param_file')

# turtlebot4_vision_tutorials = get_package_share_directory('turtlebot4_vision_tutorials')

# arg_parameters = DeclareLaunchArgument(
# 'ffmpeg_param_file',
# default_value=PathJoinSubstitution(
# [turtlebot4_vision_tutorials, 'config', 'ffmpeg.yaml']),
# description='Turtlebot4 ffmpeg compression param file'
# )

arg_namespace = DeclareLaunchArgument(
'namespace',
default_value='')

# parameters = RewrittenYaml(
# source_file=ffmpeg_param_file,
# root_key=namespace,
# param_rewrites={},
# convert_types=True)

ffmpeg_node = Node(
package='turtlebot4_vision_tutorials',
executable='pose_detection',
namespace=namespace,
name='pose_detection',
# parameters=[parameters],
)

ld = LaunchDescription()
# ld.add_action(arg_parameters)
ld.add_action(arg_namespace)
ld.add_action(ffmpeg_node)

return ld
69 changes: 69 additions & 0 deletions turtlebot4_vision_tutorials/launch/video_compression.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3

# Copyright 2024 Clearpath Robotics, 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.
#
# @author Hilary Luo ([email protected])

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions.declare_launch_argument import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node

from nav2_common.launch import RewrittenYaml


def generate_launch_description():
namespace = LaunchConfiguration('namespace')
ffmpeg_param_file = LaunchConfiguration('ffmpeg_param_file')

turtlebot4_vision_tutorials = get_package_share_directory('turtlebot4_vision_tutorials')

arg_parameters = DeclareLaunchArgument(
'ffmpeg_param_file',
default_value=PathJoinSubstitution(
[turtlebot4_vision_tutorials, 'config', 'ffmpeg.yaml']),
description='Turtlebot4 ffmpeg compression param file'
)

arg_namespace = DeclareLaunchArgument(
'namespace',
default_value='')

parameters = RewrittenYaml(
source_file=ffmpeg_param_file,
root_key=namespace,
param_rewrites={},
convert_types=True)

ffmpeg_node = Node(
package='image_transport',
executable='republish',
namespace=namespace,
name='ffmpeg_encoder',
remappings=[
('in', "oakd/rgb/preview/image_raw"),
('out/ffmpeg', "oakd/rgb/preview/encoded/ffmpeg"),
],
arguments=['raw', 'ffmpeg'],
parameters=[parameters],
)

ld = LaunchDescription()
ld.add_action(arg_parameters)
ld.add_action(arg_namespace)
ld.add_action(ffmpeg_node)

return ld
65 changes: 65 additions & 0 deletions turtlebot4_vision_tutorials/launch/video_decode.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3

# Copyright 2024 Clearpath Robotics, 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.
#
# @author Hilary Luo ([email protected])

from launch import LaunchDescription
from launch.actions.declare_launch_argument import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
namespace = LaunchConfiguration('namespace')

arg_namespace = DeclareLaunchArgument(
'namespace',
default_value='')

parameters = {
"/cpr_donatello/ffmpeg_decoder": {
"ros__parameters": {
"qos_overrides": {
"/cpr_donatello/oakd/rgb/preview/encoded/ffmpeg": {
"subscriber": {
"reliability": "best_effort",
"depth": 10,
"history": "keep_last"
}
}
}
}
}
}

ffmpeg_node = Node(
package='image_transport',
executable='republish',
namespace=namespace,
name='ffmpeg_decoder',
remappings=[
('in/ffmpeg', "oakd/rgb/preview/encoded/ffmpeg"),
('out', "oakd/rgb/preview/ffmpeg_decoded"),
],
arguments=['ffmpeg', 'raw'],
parameters=[parameters],
)

ld = LaunchDescription()
ld.add_action(arg_namespace)
ld.add_action(ffmpeg_node)

return ld
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions turtlebot4_vision_tutorials/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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>turtlebot4_vision_tutorials</name>
<version>0.0.0</version>
<description>TurtleBot Vision Tutorials</description>
<maintainer email="[email protected]">Hilary Luo</maintainer>
<license>Apache 2.0</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>

<exec_depend>cv_bridge</exec_depend>
<exec_depend>depthai</exec_depend>
<exec_depend>ffmpeg_image_transport</exec_depend>
<exec_depend>irobot_create_msgs</exec_depend>
<exec_depend>rclpy</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file.
4 changes: 4 additions & 0 deletions turtlebot4_vision_tutorials/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script_dir=$base/lib/turtlebot4_vision_tutorials
[install]
install_scripts=$base/lib/turtlebot4_vision_tutorials
33 changes: 33 additions & 0 deletions turtlebot4_vision_tutorials/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from glob import glob
import os

from setuptools import setup

package_name = 'turtlebot4_vision_tutorials'

setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join('share', package_name, 'models'), glob('models/*.blob')),
(os.path.join('share', package_name, 'launch'), glob('launch/*.launch.py')),
(os.path.join('share', package_name, 'config'), glob('config/*.yaml')),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='hilary-luo',
maintainer_email='[email protected]',
description='TurtleBot 4 Vision Tutorials',
license='Apache 2.0',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'pose_detection = turtlebot4_vision_tutorials.pose_detection:main',
'pose_display = turtlebot4_vision_tutorials.pose_display:main',
],
},
)
23 changes: 23 additions & 0 deletions turtlebot4_vision_tutorials/test/test_copyright.py
Original file line number Diff line number Diff line change
@@ -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_copyright.main import main
import pytest


@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
25 changes: 25 additions & 0 deletions turtlebot4_vision_tutorials/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions turtlebot4_vision_tutorials/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -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'
Loading

0 comments on commit 78cd441

Please sign in to comment.