Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Transport rework port in progress for review #84

Merged
merged 25 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
defbba4
Remove boost where possible.
mjcarroll Jul 18, 2018
fe68da5
ros::VoidPtr to std::shared_ptr<void>
mjcarroll Jul 16, 2018
01cfc33
Conversions around boost where necessary.
mjcarroll Jul 18, 2018
e7dd7fe
Ignore other packages for now.
mjcarroll Jul 16, 2018
09c9ffd
Basic ament_cmake port.
mjcarroll Jul 16, 2018
b08ed32
Port camera_common.
mjcarroll Jul 16, 2018
c95076e
Port publisher.
mjcarroll Jul 16, 2018
23f3617
Convert subscriber.
mjcarroll Jul 17, 2018
d9307c8
Port single_subscriber_publisher.
mjcarroll Jul 17, 2018
f263035
Type updates.
mjcarroll Jul 17, 2018
a86a847
Replace queue_size and latch with qos.
mjcarroll Jul 27, 2018
5560254
Implement simple subscriber and publisher.
mjcarroll Jul 27, 2018
17723b3
Refactor.
mjcarroll Jul 30, 2018
08c7945
Restore comments and naming.
mjcarroll Aug 3, 2018
a5a8c53
Fixup transport and add republisher back in.
mjcarroll Aug 3, 2018
1406eef
Add library export.
mjcarroll Aug 3, 2018
dd2eb98
Address reviewer feedback.
mjcarroll Aug 8, 2018
cc687fb
Clean up a few warnings, remove boost headers.
mjcarroll Aug 9, 2018
de98e0f
compile_definitions -> compile_options
mjcarroll Aug 9, 2018
49ef0d9
Reviewer feedback on necessary includes.
mjcarroll Aug 15, 2018
6aece52
Address comments about CMakeLists and package.
mjcarroll Aug 15, 2018
0b90ac1
Switch to RCLCPP loggers.
mjcarroll Aug 15, 2018
3407982
ERROR -> FATAL where asserts were used.
mjcarroll Aug 15, 2018
e6d4361
Add TODOs for ROS2 assert equivalents back.
mjcarroll Aug 15, 2018
4c838f4
Added a TODO for getNumPublishers.
mjcarroll Aug 17, 2018
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
Empty file.
Empty file.
Empty file added image_common/COLCON_IGNORE
Empty file.
140 changes: 96 additions & 44 deletions image_transport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,69 +1,121 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)

project(image_transport)

find_package(catkin REQUIRED
COMPONENTS
message_filters
pluginlib
rosconsole
roscpp
roslib
sensor_msgs
)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

find_package(Boost REQUIRED)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
DEPENDS message_filters pluginlib rosconsole roscpp roslib sensor_msgs
)
find_package(ament_cmake_ros REQUIRED)

find_package(message_filters REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(include)

# Build libimage_transport
# Build image_transport library
add_library(${PROJECT_NAME}
src/camera_common.cpp
src/publisher.cpp
src/subscriber.cpp
src/single_subscriber_publisher.cpp
src/camera_publisher.cpp
src/camera_subscriber.cpp
src/image_transport.cpp
src/publisher.cpp
src/single_subscriber_publisher.cpp
src/subscriber.cpp
)
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}
${Boost_LIBRARIES}
${catkin_LIBRARIES}

ament_target_dependencies(${PROJECT_NAME}
"message_filters"
"pluginlib"
"rclcpp"
"sensor_msgs"
)

# Build libimage_transport_plugins
add_library(${PROJECT_NAME}_plugins src/manifest.cpp src/raw_publisher.cpp)
target_link_libraries(${PROJECT_NAME}_plugins ${PROJECT_NAME})
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_plugins
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
COMPONENT main
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# Build image_transport_plugins library (raw)
add_library(${PROJECT_NAME}_plugins
src/manifest.cpp
)
target_link_libraries(${PROJECT_NAME}_plugins ${PROJECT_NAME})

# add two execs
# Build list_trasnports
add_executable(list_transports src/list_transports.cpp)
target_link_libraries(list_transports ${PROJECT_NAME})

# Build republish
add_executable(republish src/republish.cpp)
target_link_libraries(republish ${PROJECT_NAME})

add_executable(list_transports src/list_transports.cpp)
target_link_libraries(list_transports
${PROJECT_NAME}
${catkin_LIBRARIES}
# Install plugin descriptions
pluginlib_export_plugin_description_file(image_transport default_plugins.xml)

# Install libraries
install(
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_plugins
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(TARGETS list_transports republish
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# Install executables
install(
TARGETS list_transports republish
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

# add xml file
install(FILES default_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# Install include directories
install(
DIRECTORY include/
DESTINATION include
)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})

ament_export_dependencies(message_filters)
ament_export_dependencies(rclcpp)
ament_export_dependencies(sensor_msgs)
ament_export_dependencies(pluginlib)

if(BUILD_TESTING)
#TODO(ros2) enable linting
#find_package(ament_lint_auto REQUIRED)
#ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gtest)

ament_add_gtest(${PROJECT_NAME}-camera_common test/test_camera_common.cpp)
if(TARGET ${PROJECT_NAME}-camera_common)
target_link_libraries(${PROJECT_NAME}-camera_common ${PROJECT_NAME})
endif()

ament_add_gtest(${PROJECT_NAME}-publisher test/test_publisher.cpp)
if(TARGET ${PROJECT_NAME}-publisher)
target_link_libraries(${PROJECT_NAME}-publisher ${PROJECT_NAME})
endif()

ament_add_gtest(${PROJECT_NAME}-subscriber test/test_subscriber.cpp)
if(TARGET ${PROJECT_NAME}-subscriber)
target_link_libraries(${PROJECT_NAME}-subscriber ${PROJECT_NAME})
endif()

ament_add_gtest(${PROJECT_NAME}-message_passing test/test_message_passing.cpp)
if(TARGET ${PROJECT_NAME}-message_passing)
target_link_libraries(${PROJECT_NAME}-message_passing ${PROJECT_NAME})
endif()

ament_add_gtest(${PROJECT_NAME}-single_subscriber_publisher test/test_single_subscriber_publisher.cpp)
if(TARGET ${PROJECT_NAME}-single_subscriber_publisher)
target_link_libraries(${PROJECT_NAME}-single_subscriber_publisher ${PROJECT_NAME})
endif()
endif()

ament_package()
12 changes: 9 additions & 3 deletions image_transport/default_plugins.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<library path="lib/libimage_transport_plugins">
<class name="image_transport/raw_pub" type="image_transport::RawPublisher" base_class_type="image_transport::PublisherPlugin">
<library path="image_transport_plugins">
<class
name="image_transport/raw_pub"
type="image_transport::RawPublisher"
base_class_type="image_transport::PublisherPlugin">
<description>
This is the default publisher. It publishes the Image as-is on the base topic.
</description>
</class>

<class name="image_transport/raw_sub" type="image_transport::RawSubscriber" base_class_type="image_transport::SubscriberPlugin">
<class
name="image_transport/raw_sub"
type="image_transport::RawSubscriber"
base_class_type="image_transport::SubscriberPlugin">
<description>
This is the default pass-through subscriber for topics of type sensor_msgs/Image.
</description>
Expand Down
17 changes: 11 additions & 6 deletions image_transport/include/image_transport/camera_common.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
Expand All @@ -17,7 +17,7 @@
* * Neither the name of the Willow Garage 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
Expand All @@ -42,11 +42,16 @@ namespace image_transport {
/**
* \brief Form the camera info topic name, sibling to the base topic.
*
* \note This function assumes that the name is completely resolved. If the \c
* base_topic is remapped the resulting camera info topic will be incorrect.
* \note This function assumes that the name is completely resolved. If the \c
* base_topic is remapped the resulting camera info topic will be incorrect.
*/
std::string getCameraInfoTopic(const std::string& base_topic);

/**
* \brief Replacement for uses of boost::erase_last_copy
*/
std::string erase_last_copy(const std::string& input, const std::string& search);

} //namespace image_transport

#endif
49 changes: 23 additions & 26 deletions image_transport/include/image_transport/camera_publisher.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
Expand All @@ -17,7 +17,7 @@
* * Neither the name of the Willow Garage 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
Expand All @@ -35,9 +35,12 @@
#ifndef IMAGE_TRANSPORT_CAMERA_PUBLISHER_H
#define IMAGE_TRANSPORT_CAMERA_PUBLISHER_H

#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <rclcpp/macros.hpp>
#include <rclcpp/node.hpp>

#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/camera_info.hpp>

#include "image_transport/single_subscriber_publisher.h"

namespace image_transport {
Expand All @@ -62,7 +65,14 @@ class ImageTransport;
class CameraPublisher
{
public:
CameraPublisher() {}
CameraPublisher() = default;


CameraPublisher(rclcpp::Node::SharedPtr node,
const std::string& base_topic,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default);

//TODO(ros2) Restore support for SubscriberStatusCallbacks when available.

/*!
* \brief Returns the number of subscribers that are currently connected to
Expand All @@ -85,13 +95,13 @@ class CameraPublisher
/*!
* \brief Publish an (image, info) pair on the topics associated with this CameraPublisher.
*/
void publish(const sensor_msgs::Image& image, const sensor_msgs::CameraInfo& info) const;
void publish(const sensor_msgs::msg::Image& image, const sensor_msgs::msg::CameraInfo& info) const;

/*!
* \brief Publish an (image, info) pair on the topics associated with this CameraPublisher.
*/
void publish(const sensor_msgs::ImageConstPtr& image,
const sensor_msgs::CameraInfoConstPtr& info) const;
void publish(const sensor_msgs::msg::Image::ConstSharedPtr& image,
const sensor_msgs::msg::CameraInfo::ConstSharedPtr& info) const;

/*!
* \brief Publish an (image, info) pair with given timestamp on the topics associated with
Expand All @@ -100,7 +110,7 @@ class CameraPublisher
* Convenience version, which sets the timestamps of both image and info to stamp before
* publishing.
*/
void publish(sensor_msgs::Image& image, sensor_msgs::CameraInfo& info, ros::Time stamp) const;
void publish(sensor_msgs::msg::Image& image, sensor_msgs::msg::CameraInfo& info, rclcpp::Time stamp) const;

/*!
* \brief Shutdown the advertisements associated with this Publisher.
Expand All @@ -113,21 +123,8 @@ class CameraPublisher
bool operator==(const CameraPublisher& rhs) const { return impl_ == rhs.impl_; }

private:
CameraPublisher(ImageTransport& image_it, ros::NodeHandle& info_nh,
const std::string& base_topic, uint32_t queue_size,
const SubscriberStatusCallback& image_connect_cb,
const SubscriberStatusCallback& image_disconnect_cb,
const ros::SubscriberStatusCallback& info_connect_cb,
const ros::SubscriberStatusCallback& info_disconnect_cb,
const ros::VoidPtr& tracked_object, bool latch);

struct Impl;
typedef boost::shared_ptr<Impl> ImplPtr;
typedef boost::weak_ptr<Impl> ImplWPtr;

ImplPtr impl_;

friend class ImageTransport;
std::shared_ptr<Impl> impl_;
};

} //namespace image_transport
Expand Down
Loading