Skip to content

Commit

Permalink
Incremental progress on ROS2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
amarburg committed Aug 15, 2023
1 parent a2a7079 commit 8ee30c6
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 219 deletions.
1 change: 1 addition & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ USER $USERNAME
# Install the default ROS entrypoint
COPY --chmod=0755 ros2_entrypoint.sh /home/$USERNAME/ros2_entrypoint.sh
ENTRYPOINT [ "/home/ros/ros2_entrypoint.sh" ]
CMD ["/bin/bash"]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This build path clones from github
Expand Down
64 changes: 27 additions & 37 deletions arena_camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
rclcpp_components
ament_cmake
camera_control_msgs
camera_info_manager
image_transport
imaging_msgs
)

Expand Down Expand Up @@ -52,58 +54,66 @@ endforeach()
set(arena_camera_lib ${PROJECT_NAME})

add_library( ${arena_camera_lib}
SHARED
src/encoding_conversions.cpp
src/arena_camera_parameter.cpp
src/base_node.cpp
src/polled_node.cpp
src/streaming_node.cpp
)

ament_target_dependencies(${arena_camera_lib} ${THIS_PACKAGE_INCLUDE_DEPENDS})

target_include_directories( ${arena_camera_lib}
PRIVATE ${arena_sdk_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

target_link_libraries( ${arena_camera_lib}
${arena_sdk_LIBRARIES}
)

rclcpp_components_register_nodes(${arena_camera_lib} "arena_camera::ArenaCameraPolledNode")
rclcpp_components_register_nodes(${arena_camera_lib} "arena_camera::ArenaCameraStreamingNode")
#set_target_properties(${arena_camera_lib} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)

# rclcpp_components_register_nodes(${arena_camera_lib} "arena_camera::ArenaCameraPolledNode")
# rclcpp_components_register_nodes(${arena_camera_lib} "arena_camera::ArenaCameraStreamingNode")

## Build stand-alone executables
foreach(Executable IN ITEMS polled_node streaming_node)

add_executable(${Executable} src/nodes/${Executable}_main.cpp)

target_include_directories( ${Executable}
PRIVATE ${arena_sdk_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(${Executable} ${arena_camera_lib})

endforeach()

# Install launch files, library and executables
install(DIRECTORY
include/
DESTINATION include
)

# Install
install(
TARGETS ${arena_camera_lib}
DESTINATION lib/${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

# install(DIRECTORY
# include/
# DESTINATION include
# )
install(TARGETS polled_node streaming_node
DESTINATION lib/${PROJECT_NAME}
)

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

ament_export_targets(export_${arena_camera_lib} HAS_LIBRARY_TARGET)


if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)

Expand All @@ -118,32 +128,12 @@ endif()

ament_package()

# #
# # ARENA_CAMERA_NODES
# #

# set(streaming_arena_camera_node streaming_arena_camera)
# set(polled_arena_camera_node polled_arena_camera)

# add_executable( ${streaming_arena_camera_node}
# src/nodes/streaming_node_main.cpp
# )

# add_executable( ${polled_arena_camera_node}
# src/nodes/polled_node_main.cpp
# )

# foreach( camera_node ${streaming_arena_camera_node} ${polled_arena_camera_node} )

# target_include_directories( ${camera_node}
# PRIVATE ${catkin_INCLUDE_DIRS}
# )

# target_link_libraries( ${camera_node}
# ${catkin_LIBRARIES}
# )

# endforeach()
##
## !! ROS1 Cruft below. To be removed when obsoleted
##
##


#
Expand Down
20 changes: 13 additions & 7 deletions arena_camera/include/arena_camera/arena_camera_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@

#pragma once

#include <camera_info_manager/camera_info_manager.hpp>
#include <image_transport/image_transport.hpp>
#include <imaging_msgs/msg/imaging_metadata.hpp>
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include <string>

#include "rclcpp/rclcpp.hpp"

// ROS
// #include <actionlib/server/simple_action_server.h>
// #include <camera_control_msgs/GrabImagesAction.h>
Expand All @@ -53,13 +55,11 @@
// #include <diagnostic_updater/publisher.h>
// #include <dynamic_reconfigure/server.h>
// #include <image_geometry/pinhole_camera_model.h>
// #include <image_transport/image_transport.h>
// #include <Node/Node.h>
// #include <ros/ros.h>
// #include <sensor_msgs/CameraInfo.h>
// #include <sensor_msgs/image_encodings.h>

// Arena
// LucidVision Arena SDK
#include <ArenaApi.h>

// #include <arena_camera/arena_camera.h>
Expand Down Expand Up @@ -266,6 +266,14 @@ class ArenaCameraBaseNode : public rclcpp::Node {

bool is_streaming_;

image_transport::CameraPublisher img_raw_pub_;
std::shared_ptr<camera_info_manager::CameraInfoManager> camera_info_manager_;

rclcpp::Publisher<imaging_msgs::msg::ImagingMetadata>::SharedPtr
metadata_pub_;

std::shared_ptr<rclcpp::ParameterEventHandler> param_subscriber_;

// Hardware accessor functions
// These might have originally been in arena_camera.h?
// sensor_msgs::RegionOfInterest currentROI();
Expand All @@ -292,8 +300,6 @@ class ArenaCameraBaseNode : public rclcpp::Node {
// // Don't like using this global member
// sensor_msgs::Image img_raw_msg_;

// camera_info_manager::CameraInfoManager *camera_info_manager_;

// std::vector<std::size_t> sampling_indices_;
// // std::array<float, 256> brightness_exp_lut_;

Expand Down
12 changes: 0 additions & 12 deletions arena_camera/launch/arena_camera_grab_and_save_as.launch

This file was deleted.

32 changes: 0 additions & 32 deletions arena_camera/launch/arena_camera_node.launch

This file was deleted.

48 changes: 0 additions & 48 deletions arena_camera/launch/arena_camera_node_multi_device_example.launch

This file was deleted.

57 changes: 0 additions & 57 deletions arena_camera/launch/arena_camera_nodelet.launch

This file was deleted.

52 changes: 52 additions & 0 deletions arena_camera/launch/streaming_arena_camera.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2023 University of Washington
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


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


def generate_launch_description() -> LaunchDescription:
"""Generate a launch description for a generic Arean camera driver
Returns:
LaunchDescription: The arena_camera_ros2 launch description.
"""
args = [
DeclareLaunchArgument(
"device_user_id",
default_value="",
description="User ID of camera. Takes priority over serial_number.",
),
DeclareLaunchArgument(
"serial_number",
default_value="",
description="Serial number of camera.",
),
]

nodes = [
Node(
package="arena_camera",
executable="streaming_node",
name="arena_camera",
output="screen",
parameters=[
{"device_user_id": LaunchConfiguration("device_user_id"),
"serial_number": LaunchConfiguration("serial_number")},
],
),
]

return LaunchDescription(args + nodes)
Loading

0 comments on commit 8ee30c6

Please sign in to comment.