-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add starter node for camera segmentation node
- Loading branch information
Showing
15 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ================= Dependencies =================== | ||
FROM ros:humble AS base | ||
|
||
# ADD DEPENDENCIES HERE | ||
|
||
# fix user permissions when deving in container | ||
COPY docker/fixuid_setup.sh /project/fixuid_setup.sh | ||
RUN /project/fixuid_setup.sh | ||
USER docker:docker | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN sudo chsh -s /bin/bash | ||
ENV SHELL=/bin/bash | ||
|
||
# ================= Repositories =================== | ||
FROM base as repo | ||
|
||
RUN mkdir -p ~/ament_ws/src | ||
WORKDIR /home/docker/ament_ws/src | ||
|
||
COPY src/perception/camera_segmentation/ camera_segmentation | ||
COPY src/wato_msgs/sample_msgs sample_msgs | ||
|
||
WORKDIR /home/docker/ament_ws | ||
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ | ||
rosdep update && \ | ||
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y && \ | ||
colcon build \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release | ||
|
||
# Entrypoint will run before any CMD on launch. Sources ~/opt/<ROS_DISTRO>/setup.bash and ~/ament_ws/install/setup.bash | ||
COPY docker/wato_ros_entrypoint.sh /home/docker/wato_ros_entrypoint.sh | ||
COPY docker/.bashrc /home/docker/.bashrc | ||
ENTRYPOINT ["/usr/local/bin/fixuid", "-q", "/home/docker/wato_ros_entrypoint.sh"] | ||
CMD ["ros2", "launch", "camera_segmentation", "camera_segmentation.launch.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
44 changes: 44 additions & 0 deletions
44
src/perception/camera_segmentation/camera_segmentation/camera_segmentation_node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from std_msgs.msg import String | ||
from sensor_msgs.msg import Image | ||
|
||
class CameraSegmentationNode(Node): | ||
|
||
def __init__(self): | ||
super().__init__('node') | ||
# log initialization | ||
self.get_logger().info('Initializing node...') | ||
# Fetch parameters from yaml file | ||
self.declare_parameter('camera_topic', '/camera_topic') | ||
self.declare_parameter('publish_topic', '/camera_segmentation') | ||
camera_topic = self.get_parameter('camera_topic').get_parameter_value().string_value | ||
publish_topic = self.get_parameter('publish_topic').get_parameter_value().string_value | ||
self.publisher_ = self.create_publisher(Image, publish_topic, 10) | ||
self.subscriber_ = self.create_subscription(Image, camera_topic, self.image_callback, 10) | ||
self.i = 0 | ||
|
||
def image_callback(self): | ||
msg = Image() | ||
self.publisher_.publish(msg) | ||
self.get_logger().info('Publishing image: "%s"' % msg.data) | ||
self.i += 1 | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
node = CameraSegmentationNode() | ||
|
||
rclpy.spin(node) | ||
|
||
# Destroy the node explicitly | ||
# (optional - otherwise it will be done automatically | ||
# when the garbage collector destroys the node object) | ||
node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lane_detection_node: | ||
ros__parameters: | ||
camera_topic: /CAM_FRONT/image_rect_compressed | ||
publish_topic: /image_segmentation |
35 changes: 35 additions & 0 deletions
35
src/perception/camera_segmentation/launch/camera_segmentation.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2023 WATonomous | ||
# | ||
# 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 ament_index_python.packages import get_package_share_directory | ||
|
||
from launch import LaunchDescription | ||
from launch_ros.actions import Node | ||
|
||
def generate_launch_description(): | ||
|
||
param_file_path = os.path.join( | ||
get_package_share_directory('camera_segmentation'), | ||
'config', | ||
'params.yaml' | ||
) | ||
|
||
return LaunchDescription([ | ||
Node( | ||
package='camera_segmentation', | ||
executable='camera_segmentation_node', | ||
parameters=[param_file_path] | ||
) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>camera_segmentation</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">docker</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> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/camera_segmentation | ||
[install] | ||
install_scripts=$base/lib/camera_segmentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from setuptools import find_packages, setup | ||
import os | ||
from glob import glob | ||
from setuptools import setup | ||
|
||
package_name = 'camera_segmentation' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=find_packages(exclude=['test']), | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
(os.path.join('share', package_name), ['package.xml']), | ||
# Include all launch files | ||
(os.path.join('share', package_name, 'launch'), | ||
glob(os.path.join('launch', '*.launch.py'))), | ||
# Include config files for parameters | ||
(os.path.join('share', package_name, 'config'), glob(os.path.join('config', '*.yaml'))), | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='docker', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', | ||
license='TODO: License declaration', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'camera_segmentation_node = camera_segmentation.camera_segmentation_node:main' | ||
], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters