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

GR mods #67

Open
wants to merge 10 commits into
base: ros2
Choose a base branch
from
Open
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
64 changes: 26 additions & 38 deletions gst_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if($ENV{CLION_IDE})
set(audio_msgs_DIR "${PROJECT_SOURCE_DIR}/../../../install/audio_msgs/share/audio_msgs/cmake")
endif()

find_package(PkgConfig REQUIRED)

# if(NOT TRACETOOLS_TRACEPOINTS_EXCLUDED)
pkg_search_module(lttng-ust REQUIRED IMPORTED_TARGET lttng-ust)
# endif()

# find dependencies
find_package(ament_cmake REQUIRED)
Expand All @@ -31,35 +36,28 @@ find_package(rclcpp REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# find gstreamer
set(gstreamer_components app pbutils audio fft net)
find_package(GStreamer 1.8.3 REQUIRED COMPONENTS ${gstreamer_components})
pkg_search_module(gstreamer REQUIRED IMPORTED_TARGET gstreamer-1.0)
pkg_search_module(gstreamer-base REQUIRED IMPORTED_TARGET gstreamer-base-1.0)
pkg_search_module(gstreamer-app REQUIRED IMPORTED_TARGET gstreamer-app-1.0)
pkg_search_module(gstreamer-audio REQUIRED IMPORTED_TARGET gstreamer-audio-1.0)
pkg_search_module(gstreamer-video REQUIRED IMPORTED_TARGET gstreamer-video-1.0)


# find glib
set(glib_components gio gio-unix gobject gthread gmodule)
find_package(GLIB 2.28 REQUIRED COMPONENTS ${glib_components})
find_package(GLIB REQUIRED COMPONENTS ${glib_components})

## Include messages
find_package(std_msgs REQUIRED)
find_package(audio_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
# find_package(rosidl_default_generators REQUIRED)

## Generate added messages and services with any dependencies listed here
# rosidl_generate_interfaces(${PROJECT_NAME}
# ${msg_files}
# DEPENDENCIES builtin_interfaces std_msgs
# )



###########
## Build ##
###########




# This is a gstreamer plugin, not a ros node
# the install location needs to be found by gst-inspect

Expand All @@ -74,11 +72,8 @@ add_library(rosgstbridge SHARED
src/rosaudiosrc.cpp
src/rosimagesrc.cpp
src/rostextsrc.cpp
)


#rosidl_target_interfaces(rosgstbridge
# ${PROJECT_NAME} "rosidl_typesupport_cpp")
src/gst_bridge_tpp.cpp
)

# ament has a habit of pruning unused linked functions required by gstreamer
# symptom of this is 'undefined symbol: gst_audio_sink_get_type' on gst-inspect
Expand All @@ -87,12 +82,10 @@ target_include_directories(rosgstbridge PRIVATE
${sensor_msgs_INCLUDE_DIRS}
${audio_msgs_INCLUDE_DIRS}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
${GLIB_INCLUDE_DIRS}
${GOBJECT_INCLUDE_DIR}
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_BASE_INCLUDE_DIRS}
${GST_INCLUDE_DIRS}
)

target_link_libraries(rosgstbridge PUBLIC
Expand All @@ -102,12 +95,12 @@ target_link_libraries(rosgstbridge PUBLIC
${GLIB_LIBRARIES}
${GLIB_GIO_LIBRARIES}
${GLIB_GOBJECT_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GSTREAMER_AUDIO_LIBRARIES}
${GSTREAMER_APP_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${GSTREAMER_BASE_LIBRARIES}
${GST_LIBRARIES}
PkgConfig::gstreamer
PkgConfig::gstreamer-app
PkgConfig::gstreamer-audio
PkgConfig::gstreamer-base
PkgConfig::gstreamer-video
PkgConfig::lttng-ust
)


Expand All @@ -123,27 +116,22 @@ target_include_directories(gst_bridge PUBLIC
$<INSTALL_INTERFACE:include>
${GLIB_INCLUDE_DIRS}
${GOBJECT_INCLUDE_DIR}
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_BASE_INCLUDE_DIRS}
${GST_INCLUDE_DIRS}
)
target_link_libraries(gst_bridge PUBLIC
${rclcpp_LIBRARIES}
${sensor_msgs_LIBRARIES}
${audio_msgs_LIBRARIES}
${GLIB_LIBRARIES}
${GLIB_GIO_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GSTREAMER_AUDIO_LIBRARIES}
${GSTREAMER_APP_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${GSTREAMER_BASE_LIBRARIES}
${GST_LIBRARIES}
PkgConfig::gstreamer
PkgConfig::gstreamer-app
PkgConfig::gstreamer-audio
PkgConfig::gstreamer-base
PkgConfig::gstreamer-video
)


ament_export_include_directories(include)
#ament_export_libraries(gst_bridge src/gst_bridge.cpp)
ament_export_libraries(gst_bridge)

install(DIRECTORY include/
Expand Down
135 changes: 0 additions & 135 deletions gst_bridge/cmake/FindGStreamer.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions gst_bridge/include/gst_bridge/rosbasesink.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct _RosBaseSink
GstBaseSink parent;
gchar* node_name;
gchar* node_namespace;
gint64 offset_time_ns;

rclcpp::Context::SharedPtr ros_context;
rclcpp::Executor::SharedPtr ros_executor;
rclcpp::Node::SharedPtr node;
rclcpp::Logger logger;
Expand Down Expand Up @@ -72,7 +72,7 @@ struct _RosBaseSinkClass


/*
* destroy the ros publisher(s) and unregister your callbacks and timers and prepare for ros_context->shutdown()
* destroy the ros publisher(s) and unregister your callbacks and timers and prepare for the shutdown of the rclcpp context
* called at gstbasesink->change_state() GST_STATE_CHANGE_READY_TO_NULL
* timers and reconf callbacks are currently broken, needs a new thread with an executor, patches welcome
*/
Expand Down
6 changes: 4 additions & 2 deletions gst_bridge/include/gst_bridge/rosbasesrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

//include ROS and ROS message formats
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/experimental/executors/events_executor/events_executor.hpp>

G_BEGIN_DECLS

Expand All @@ -44,7 +45,6 @@ struct _RosBaseSrc
gchar* node_name;
gchar* node_namespace;

rclcpp::Context::SharedPtr ros_context;
rclcpp::Executor::SharedPtr ros_executor;
rclcpp::Node::SharedPtr node;
rclcpp::Logger logger;
Expand Down Expand Up @@ -72,12 +72,14 @@ struct _RosBaseSrcClass


/*
* destroy the ros subscription(s) and unregister your callbacks and timers and prepare for ros_context->shutdown()
* destroy the ros subscription(s) and unregister your callbacks and timers and prepare for shutdown of the rclcpp context
* called at gstbasesrc->change_state() GST_STATE_CHANGE_READY_TO_NULL
* timers and reconf callbacks are currently broken, needs a new thread with an executor, patches welcome
*/
gboolean (*close) (RosBaseSrc * src);

gboolean (*notify_thread) (RosBaseSrc * src);

};

GType rosbasesrc_get_type (void);
Expand Down
1 change: 1 addition & 0 deletions gst_bridge/include/gst_bridge/rosimagesink.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

//include ROS and ROS message formats
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/duration.hpp>
#include <sensor_msgs/msg/image.hpp>


Expand Down
4 changes: 2 additions & 2 deletions gst_bridge/include/gst_bridge/rosimagesrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//include ROS and ROS message formats
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <queue> // std::queue
#include <deque>
#include <mutex> // std::mutex, std::unique_lock
#include <condition_variable> // std::condition_variable

Expand Down Expand Up @@ -56,7 +56,7 @@ struct _Rosimagesrc

// XXX this is too much boilerplate.
size_t msg_queue_max;
std::queue<sensor_msgs::msg::Image::ConstSharedPtr> msg_queue;
std::deque<sensor_msgs::msg::Image::ConstSharedPtr> msg_queue;
std::mutex msg_queue_mtx;
std::condition_variable msg_queue_cv;

Expand Down
2 changes: 2 additions & 0 deletions gst_bridge/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<build_depend>libgstreamer1.0-dev</build_depend>
<build_depend>libgstreamer-plugins-base1.0-dev</build_depend>

<depend>liblttng-ust-dev</depend>
<depend>liblttng-ctl-dev</depend>
<build_depend>std_msgs</build_depend>
<build_depend>audio_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
Expand Down
2 changes: 2 additions & 0 deletions gst_bridge/src/gst_bridge_tpp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
#include "gst_bridge_tpp.h"
Loading