Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 89 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,61 +1,106 @@
cmake_minimum_required(VERSION 3.16)
project(********** Fill in project name **********)
cmake_minimum_required(VERSION 3.10.2)
project(umrt_ros_poe_cam VERSION 2.9.0 LANGUAGES CXX C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_compile_options(-g)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -fPIC)
## is used, also find other catkin packages
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()

# Fixes intellisense not finding ros2 headers https://youtrack.jetbrains.com/issue/CPP-29747/Certain-ROS2-package-headers-missing-from-Intellisense-when-using-a-Docker-toolchain
include_directories(SYSTEM /opt/ros/$ENV{ROS_DISTRO}/include)
set(_opencv_version 4)
find_package(OpenCV 4 QUIET COMPONENTS imgproc highgui)
if(NOT OpenCV_FOUND)
set(_opencv_version 3)
find_package(OpenCV 3 REQUIRED COMPONENTS imgproc highgui)
endif()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
rclcpp
rclcpp_lifecycle
)
# find_package(depthai CONFIG REQUIRED PATHS "/home/sachin/Desktop/luxonis/depthai-core/build/install/lib/cmake/depthai")
set(mobilenet_blob_name "mobilenet-ssd_openvino_2021.2_6shave.blob")

set(mobilenet_blob "${PROJECT_SOURCE_DIR}/resources/${mobilenet_blob_name}")
file(DOWNLOAD "https://artifacts.luxonis.com/artifactory/luxonis-depthai-data-local/network/mobilenet-ssd_openvino_2021.2_6shave.blob"
${mobilenet_blob}
TIMEOUT 60 # seconds
EXPECTED_HASH SHA1=f0e14978b3f77a4f93b9f969cd39e58bb7aef490
TLS_VERIFY ON)

# find dependencies
find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

add_executable(${PROJECT_NAME}
src/project_name.cpp
src/example_node.cpp
message(STATUS "------------------------------------------")
message(STATUS "Depthai Bridge is being built using AMENT.")
message(STATUS "------------------------------------------")

find_package(camera_info_manager REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(depthai CONFIG REQUIRED)
find_package(depthai_ros_msgs REQUIRED)
find_package(depthai_bridge REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(stereo_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(vision_msgs REQUIRED)
find_package(foxglove_msgs REQUIRED)

set(dependencies
camera_info_manager
cv_bridge
depthai_ros_msgs
depthai_bridge
rclcpp
sensor_msgs
stereo_msgs
std_msgs
vision_msgs
foxglove_msgs
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
ament_target_dependencies(
${PROJECT_NAME} PUBLIC
${THIS_PACKAGE_INCLUDE_DEPENDS}

include_directories(
include
${ament_INCLUDE_DIRS}
)

# Parse version number from the file
file(READ "version" version_input)
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _ ${version_input})
# Macro to add nodes
macro(dai_add_node_ros2 node_name node_src)
add_executable("${node_name}" "${node_src}")

# Fill version number into package.xml
configure_file(
package.in.xml
${CMAKE_CURRENT_SOURCE_DIR}/package.xml
@ONLY
)
target_link_libraries("${node_name}"
depthai::core
opencv_imgproc
opencv_highgui)

# INSTALL
install(TARGETS
${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)
ament_target_dependencies("${node_name}"
${dependencies})

install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}/
)
endmacro()

# Add MobileNet Publisher Node
dai_add_node_ros2(mobilenet_node src/mobilenet_publisher.cpp)

target_compile_definitions(mobilenet_node PRIVATE BLOB_NAME="${mobilenet_blob_name}")

# Add Video Decoder Node
# dai_add_node_ros2(video_decoder_node src/video_decoder_node.cpp)

if($ENV{ROS_DISTRO} STREQUAL "galactic")
target_compile_definitions(rgb_stereo_node PRIVATE IS_GALACTIC)
endif()

# Install parameters, resources, and launch files
install(DIRECTORY params DESTINATION share/${PROJECT_NAME})
install(DIRECTORY resources DESTINATION share/${PROJECT_NAME})
install(DIRECTORY launch/ DESTINATION share/${PROJECT_NAME}/launch
FILES_MATCHING PATTERN "*.py")

# Install targets
install(TARGETS
mobilenet_node
# video_decoder_node
DESTINATION lib/${PROJECT_NAME})

ament_package()
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "********** Project name **********"
PROJECT_NAME = "UMRT PoE Camera ROS Package"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# UMRT ROS Template
ROS project repository template for the University of Manitoba Robotics Team.
# UMRT ROS PoE Camera
ROS project repository for the ROS PoE Camera.

TO BE UPDATED

New projects should be **forked** from this repo (not using this as a template, as that prevents template changes from
trickling down). Each new project must:
Expand All @@ -16,10 +18,17 @@ trickling down). Each new project must:
8. Write something in mainpage.dox
9. Replace example files with real code, add source files to CMake targets, document it with Doxygen, and proceed

TO DO:
Check H265
Update Doxyfile
Update CMakeLists.txt to match the umrt-template-ros
Removal of unecesary src files
Separating mobule_publisher.cpp to different cpp and hpp files

---
# Project Name
# UMRT ROS PoE Camera

This library/executable/project implements XYZ functionality for the University of Manitoba Robotics Team's
This library/executable/project implements PoE Camera functionality for the University of Manitoba Robotics Team's
rover/robotic arm.

[See the documentation](https://umroboticsteam.github.io/********** project-name **********/)
[See the documentation](https://umroboticsteam.github.io/umrt-ros-poe-cam/)
139 changes: 139 additions & 0 deletions launch/mobile_publisher.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription, launch_description_sources
from launch.actions import IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
import launch_ros.actions
import launch_ros.descriptions
from launch_ros.parameter_descriptions import ParameterValue

def generate_launch_description():
umrt_ros_poe_cam_path = get_package_share_directory('umrt_ros_poe_cam')
default_rviz = os.path.join(umrt_ros_poe_cam_path, 'rviz', 'pointCloud.rviz')
default_resources_path = os.path.join(umrt_ros_poe_cam_path, 'resources')

urdf_launch_dir = os.path.join(get_package_share_directory('depthai_descriptions'), 'launch')

camera_model = LaunchConfiguration('camera_model', default = 'OAK-D')
tf_prefix = LaunchConfiguration('tf_prefix', default = 'oak')
base_frame = LaunchConfiguration('base_frame', default = 'oak-d_frame')
parent_frame = LaunchConfiguration('parent_frame', default = 'oak-d-base-frame')
cam_pos_x = LaunchConfiguration('cam_pos_x', default = '0.0')
cam_pos_y = LaunchConfiguration('cam_pos_y', default = '0.0')
cam_pos_z = LaunchConfiguration('cam_pos_z', default = '0.0')
cam_roll = LaunchConfiguration('cam_roll', default = '0.0')
cam_pitch = LaunchConfiguration('cam_pitch', default = '0.0')
cam_yaw = LaunchConfiguration('cam_yaw', default = '0.0')

camera_param_uri = LaunchConfiguration('camera_param_uri', default = 'package://umrt-ros-poe-cam/params/camera')
sync_nn = LaunchConfiguration('sync_nn', default = True)
nnName = LaunchConfiguration('nnName', default = "x")
resourceBaseFolder = LaunchConfiguration('resourceBaseFolder', default = default_resources_path)

declare_camera_model_cmd = DeclareLaunchArgument(
'camera_model',
default_value=camera_model,
description='The model of the camera. Using a wrong camera model can disable camera features. Valid models: `OAK-D, OAK-D-LITE`.')

declare_tf_prefix_cmd = DeclareLaunchArgument(
'tf_prefix',
default_value=tf_prefix,
description='The name of the camera. It can be different from the camera model and it will be used in naming TF.')

declare_base_frame_cmd = DeclareLaunchArgument(
'base_frame',
default_value=base_frame,
description='Name of the base link.')

declare_parent_frame_cmd = DeclareLaunchArgument(
'parent_frame',
default_value=parent_frame,
description='Name of the parent link from other a robot TF for example that can be connected to the base of the OAK.')

declare_pos_x_cmd = DeclareLaunchArgument(
'cam_pos_x',
default_value=cam_pos_x,
description='Position X of the camera with respect to the base frame.')

declare_pos_y_cmd = DeclareLaunchArgument(
'cam_pos_y',
default_value=cam_pos_y,
description='Position Y of the camera with respect to the base frame.')

declare_pos_z_cmd = DeclareLaunchArgument(
'cam_pos_z',
default_value=cam_pos_z,
description='Position Z of the camera with respect to the base frame.')

declare_roll_cmd = DeclareLaunchArgument(
'cam_roll',
default_value=cam_roll,
description='Roll orientation of the camera with respect to the base frame.')

declare_pitch_cmd = DeclareLaunchArgument(
'cam_pitch',
default_value=cam_pitch,
description='Pitch orientation of the camera with respect to the base frame.')

declare_yaw_cmd = DeclareLaunchArgument(
'cam_yaw',
default_value=cam_yaw,
description='Yaw orientation of the camera with respect to the base frame.')

declare_camera_param_uri_cmd = DeclareLaunchArgument(
'camera_param_uri',
default_value=camera_param_uri,
description='Sending camera yaml path')

declare_sync_nn_cmd = DeclareLaunchArgument(
'sync_nn',
default_value=sync_nn,
description='Syncs the image output with the Detection.')

declare_nnName_cmd = DeclareLaunchArgument(
'nnName',
default_value=nnName,
description='Path to the object detection blob needed for detection')

declare_resourceBaseFolder_cmd = DeclareLaunchArgument(
'resourceBaseFolder',
default_value=resourceBaseFolder,
description='Path to the resources folder which contains the default blobs for the network')

mobilenet_node = launch_ros.actions.Node(
package='umrt_ros_poe_cam', executable='mobilenet_node',
output='screen',
parameters=[{'tf_prefix': 'oak'},
{'camera_param_uri': camera_param_uri},
{'sync_nn': sync_nn},
{'nnName': nnName},
{'resourceBaseFolder': resourceBaseFolder}])
rviz_node = launch_ros.actions.Node(
package='rviz2', executable='rviz2', output='screen',
arguments=['--display-config', default_rviz])

ld = LaunchDescription()
ld.add_action(declare_tf_prefix_cmd)
ld.add_action(declare_camera_model_cmd)
ld.add_action(declare_base_frame_cmd)
ld.add_action(declare_parent_frame_cmd)
ld.add_action(declare_pos_x_cmd)
ld.add_action(declare_pos_y_cmd)
ld.add_action(declare_pos_z_cmd)
ld.add_action(declare_roll_cmd)
ld.add_action(declare_pitch_cmd)
ld.add_action(declare_yaw_cmd)
ld.add_action(declare_camera_param_uri_cmd)
ld.add_action(declare_sync_nn_cmd)
ld.add_action(declare_nnName_cmd)
ld.add_action(declare_resourceBaseFolder_cmd)
ld.add_action(mobilenet_node)

# ld.add_action(urdf_launch)
# ld.add_action(metric_converter_node)
# ld.add_action(point_cloud_node)
# ld.add_action(rviz_node)

return ld
7 changes: 7 additions & 0 deletions nodelet_plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<library path="lib/libnodelet_stereo">
<class name="depthai_examples/StereoNodelet" type="depthai_examples::StereoNodelet" base_class_type="nodelet::Nodelet">
<description>
This is stereo publishing nodelet.
</description>
</class>
</library>
24 changes: 22 additions & 2 deletions package.in.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?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>********** Fill in project name **********</name>
<name>umrt_ros_poe_cam</name>
<version>@version_input@</version> <!-- Version number parsed from version file, replaced here by CMake -->
<description>********** Fill in project description **********</description>
<description>UMRT PoE Camera ROS Package</description>
<maintainer email="***** email *****">***** First Last *****</maintainer>
<license>MPL-2.0</license>

Expand All @@ -15,6 +15,26 @@
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<!-- Package dependencies -->
<depend>cv_bridge</depend>
<depend>camera_info_manager</depend>
<depend>depthai</depend>
<depend>depthai_ros_msgs</depend>
<depend>depthai_bridge</depend>
<depend>depthai_descriptions</depend>
<depend>image_transport</depend>
<depend>libopencv-dev</depend>
<depend>ros_environment</depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>stereo_msgs</depend>
<depend>vision_msgs</depend>

<!-- Execution dependencies -->
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>depth_image_proc</exec_depend>
<exec_depend>xacro</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
Loading
Loading