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

Noetic devel #69

Open
wants to merge 3 commits into
base: master
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
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# this is .traivs.yml written by ./create_travis_settings.py
# this is .traivs.yml written by -

# https://github.com/ros-infrastructure/ros_buildfarm/blob/master/doc/jobs/devel_jobs.rst
# https://github.com/ros-infrastructure/ros_buildfarm/blob/master/doc/jobs/prerelease_jobs.rst
Expand All @@ -8,16 +7,13 @@ sudo: true
dist: trusty
language: python
python:
- "3.4"
- "3.6"
env:
global:
- JOB_PATH=/tmp/devel_job
- ABORT_ON_TEST_FAILURE=1
matrix:
- ROS_DISTRO_NAME=indigo OS_NAME=ubuntu OS_CODE_NAME=trusty ARCH=amd64
- ROS_DISTRO_NAME=kinetic OS_NAME=ubuntu OS_CODE_NAME=xenial ARCH=amd64
- ROS_DISTRO_NAME=lunar OS_NAME=ubuntu OS_CODE_NAME=xenial ARCH=amd64
- ROS_DISTRO_NAME=melodic OS_NAME=ubuntu OS_CODE_NAME=bionic ARCH=amd64
- ROS_DISTRO_NAME=noetic OS_NAME=ubuntu OS_CODE_NAME=focal ARCH=amd64
# matrix:
# allow_failures:
# - env: ROS_DISTRO_NAME=kinetic OS_NAME=ubuntu OS_CODE_NAME=xenial ARCH=amd64
Expand Down
176 changes: 69 additions & 107 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.0.2)

project(gscam)

# System Dependencies
find_package(PkgConfig)
# pkg-config libraries
find_package(PkgConfig REQUIRED)

#
# For Noetic
# - removed ROSBUILD target (deprecated)
# - should remove gstreamer-0.10 support (old)
#

pkg_check_modules(GSTREAMER QUIET gstreamer-0.10)
if(NOT GSTREAMER_FOUND)
Expand All @@ -19,112 +26,67 @@ else()
pkg_check_modules(GST_APP REQUIRED gstreamer-app-0.10)
endif()

if(USE_ROSBUILD)
# Use rosbuild
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

include_directories(${GLIB_INCLUDE_DIRS} ${GST_APP_INCLUDE_DIRS})

rosbuild_add_library(gscam src/gscam.cpp)
target_link_libraries(gscam
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})

rosbuild_add_executable(gscam_node src/gscam_node.cpp)
target_link_libraries(gscam_node gscam
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})
set_target_properties(gscam_node PROPERTIES OUTPUT_NAME gscam)

rosbuild_add_library(GSCamNodelet src/gscam_nodelet.cpp)
target_link_libraries(GSCamNodelet gscam
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})

else()
# Use Catkin
find_package(catkin REQUIRED
COMPONENTS roscpp image_transport sensor_msgs nodelet
camera_calibration_parsers camera_info_manager
)

catkin_package(
INCLUDE_DIRS include
LIBRARIES gscam
CATKIN_DEPENDS roscpp nodelet image_transport sensor_msgs
camera_calibration_parsers camera_info_manager
DEPENDS GSTREAMER GST_APP
)

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

add_library(gscam src/gscam.cpp)
target_link_libraries(gscam
${catkin_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})

add_executable(gscam_node src/gscam_node.cpp)
target_link_libraries(gscam_node gscam
${catkin_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})
set_target_properties(gscam_node PROPERTIES OUTPUT_NAME gscam)

add_library(GSCamNodelet src/gscam_nodelet.cpp)
target_link_libraries(GSCamNodelet gscam
${catkin_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES})

# Install directives

install(TARGETS gscam gscam_node GSCamNodelet
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
PATTERN ".svn" EXCLUDE)

install(FILES nodelet_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(FILES
examples/v4l.launch
examples/gscam_nodelet.launch
examples/nodelet_pipeline.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(FILES examples/uncalibrated_parameters.ini
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/examples
)

# Interim compatibility
# Remove this in the next release
install(FILES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gscam_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
set(EXECUTABLE_OUTPUT_PATH ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME})
endif()
# Use Catkin build tools.
find_package(catkin REQUIRED COMPONENTS roscpp image_transport sensor_msgs camera_calibration_parsers camera_info_manager )

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS roscpp image_transport sensor_msgs camera_calibration_parsers camera_info_manager
DEPENDS GSTREAMER GST_APP
)

# Build defs
include_directories(
include
${catkin_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${GST_APP_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} src/gscam.cpp)
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES}
)

add_executable(${PROJECT_NAME}_node src/gscam_node.cpp)
target_link_libraries(${PROJECT_NAME}_node
${PROJECT_NAME}
${catkin_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GST_APP_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME ${PROJECT_NAME})

# Install directives

install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

install(FILES nodelet_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
FILES_MATCHING PATTERN "*.launch"
)

install(FILES examples/uncalibrated_parameters.ini
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/examples
)

set(EXECUTABLE_OUTPUT_PATH ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME})

# Interim compatibility
# Remove this in the next distribution release
configure_file(scripts/gscam_node.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gscam_node)
file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gscam_node
DESTINATION ${EXECUTABLE_OUTPUT_PATH}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)


2 changes: 0 additions & 2 deletions Makefile

This file was deleted.

19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ several fixes incorporated into it to make it broadcast correct
`sensor_msgs/Image` messages with proper frames and timestamps. It also allows
for more ROS-like configuration and more control over the GStreamer interface.

Note that this pacakge can be built both in a rosbuild and catkin workspaces.
Note that this pacakge now only supports building in catkin workspaces.

GStreamer Library Support
-------------------------
Expand Down Expand Up @@ -38,15 +38,15 @@ sudo add-apt-repository ppa:gstreamer-developers/ppa
sudo apt-get install gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev
```

##### 14.04
##### 14.04 + 16.04 + 18.04 + 20.04

```sh
sudo apt-get install gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev
```

#### Usage:
* Use the CMake flag `-DGSTREAMER_VERSION_1_x=On` when building
* See the [Video4Linux2 launchfile example](examples/v4l.launch) for
* See the [Video4Linux2 launchfile example](launch/v4l.launch) for
an example of the differences in the GStreamer config lines

#### Notes:
Expand All @@ -70,7 +70,7 @@ This can be run as both a node and a nodelet.
* `camera/set_camera_info`

#### Parameters
* `~camera_name`: The name of the camera (corrsponding to the camera info)
* `~camera_name`: The name of the camera (corresponding to the camera info - `camera_name/` replaces `camera/` in the topic list)
* `~camera_info_url`: A url (`file://path/to/file`, `package://pkg_name/path/to/file`) to the [camera calibration file](http://www.ros.org/wiki/camera_calibration_parsers#File_formats).
* `~gscam_config`: The GStreamer [configuration string](http://wiki.oz9aec.net/index.php?title=Gstreamer_cheat_sheet&oldid=1829).
* `~frame_id`: The [TF](http://www.ros.org/wiki/tf) frame ID.
Expand All @@ -88,12 +88,15 @@ Examples
See example launchfiles and configs in the examples directory. Currently there
are examples for:

* [Video4Linux2](examples/v4l.launch): Standard
* [Video4Linux2](launch/v4l.launch): Standard
[video4linux](http://en.wikipedia.org/wiki/Video4Linux)-based cameras like
USB webcams.
* ***GST-1.0:*** Use the roslaunch argument `GST10:=True` for GStreamer 1.0 variant
* [Nodelet](examples/gscam_nodelet.launch): Run a V4L-based camera in a nodelet
* [Video File](examples/videofile.launch): Any videofile readable by GStreamer
* [DeckLink](examples/decklink.launch):
* [Nodelet](launch/gscam_nodelet.launch): Run a V4L-based camera in a nodelet
* [Video File](launch/videofile.launch): Any videofile readable by GStreamer
* [DeckLink](launch/decklink.launch):
[BlackMagic](http://www.blackmagicdesign.com/products/decklink/models)
DeckLink SDI capture cards (note: this requires the `gst-plugins-bad` plugins)
* [tdgigevsrc](launch/tdgigev.launch launch/tdgigev_bayer.launch) for GigeVision cameras.
This requires the Teledyne DALSA GigE-V Source plugin for gstreamer-1.0

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions launch/tdgigev.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<launch>
<!-- This launchfile should bring up a node that broadcasts a ros image
transport on /gigev_cam#/image_raw -->

<!-- Select camera by Index or IP or SerialNumber or DeviceName feature (only one though) -->
<!-- Examples shown here...
<arg name="GIGECAMID" default="cam-index=0"/>
<arg name="GIGECAMID" default="cam-ip=169:254:5:20"/>
<arg name="GIGECAMID" default="cam-sn=S1113716"/>
<arg name="GIGECAMID" default="cam-name=A0000546"/>
For multiple cameras - Remember to use unique node names in each launch file -->

<!-- The GStreamer framerate needs to be an integral fraction -->
<arg name="CAMINDEX" default="0"/>
<arg name="GIGECAMID" default="cam-index=$(arg CAMINDEX)"/>
<arg name="PUBLISH_FRAME" default="false"/>
<arg name="CFGFILE" default="false"/>

<node name="gscam" pkg="gscam" type="gscam" output="screen">
<param name="camera_name" value="/gigev_cam$(arg CAMINDEX)"/>
<param unless="$(arg CFGFILE)" name="gscam_config" value="tdgigevsrc $(arg GIGECAMID) bayer-as-mono=1 ! queue ! videoconvert"/>
<param if="$(arg CFGFILE)" name="gscam_config" value="tdgigevsrc $(arg GIGECAMID) cfg-file=$(arg CFGFILE) bayer-as-mono=1 ! queue ! videoconvert"/>
<param name="frame_id" value="default"/>
<param name="sync_sink" value="true"/>
</node>
</launch>
27 changes: 27 additions & 0 deletions launch/tdgigev_bayer.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<launch>
<!-- This launchfile should bring up a node that broadcasts a ros image
transport on /gigev_cam#/image_raw -->


<!-- Select camera by Index or IP or SerialNumber or DeviceName feature (only one though) -->
<!-- Examples shown here...
<arg name="GIGECAMID" default="cam-index=0"/>
<arg name="GIGECAMID" default="cam-ip=169:254:5:20"/>
<arg name="GIGECAMID" default="cam-sn=S1113716"/>
<arg name="GIGECAMID" default="cam-name=A0000546"/>
For multiple cameras - Remember to use unique node names in each launch file -->

<!-- The GStreamer framerate needs to be an integral fraction -->
<arg name="CAMINDEX" default="0"/>
<arg name="GIGECAMID" default="cam-index=$(arg CAMINDEX)"/>
<arg name="PUBLISH_FRAME" default="false"/>
<arg name="CFGFILE" default="false"/>

<node name="gscam" pkg="gscam" type="gscam" output="screen">
<param name="camera_name" value="/gigev_cam$(arg CAMINDEX)"/>
<param unless="$(arg CFGFILE)" name="gscam_config" value="tdgigevsrc $(arg GIGECAMID) ! queue ! bayer2rgb ! videoconvert"/>
<param if="$(arg CFGFILE)" name="gscam_config" value="tdgigevsrc $(arg GIGECAMID) cfg-file=$(arg CFGFILE) ! queue ! bayer2rgb ! videoconvert"/>
<param name="frame_id" value="default"/>
<param name="sync_sink" value="true"/>
</node>
</launch>
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 19 additions & 14 deletions src/gscam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ namespace gscam {
jpeg_pub_ = nh_.advertise<sensor_msgs::CompressedImage>("camera/image_raw/compressed",1);
cinfo_pub_ = nh_.advertise<sensor_msgs::CameraInfo>("camera/camera_info",1);
} else {
camera_pub_ = image_transport_.advertiseCamera("camera/image_raw", 1);
if ( camera_name_.compare("default") ) {
std::string camname_;
camname_ = camera_name_ + "/image_raw";
camera_pub_ = image_transport_.advertiseCamera(camname_.c_str(), 1);
}
else {
camera_pub_ = image_transport_.advertiseCamera("camera/image_raw", 1);
}
}

return true;
Expand Down Expand Up @@ -291,16 +298,6 @@ namespace gscam {
// GST_TIME_AS_USECONDS(buf->timestamp+bt)/1e6+time_offset_, buf->timestamp, bt, time_offset_);


#if 0
GstFormat fmt = GST_FORMAT_TIME;
gint64 current = -1;

Query the current position of the stream
if (gst_element_query_position(pipeline_, &fmt, &current)) {
ROS_INFO_STREAM("Position "<<current);
}
#endif

// Stop on end of stream
if (!buf) {
ROS_INFO("Stream ended.");
Expand All @@ -310,10 +307,10 @@ namespace gscam {
// ROS_DEBUG("Got data.");

// Get the image width and height
GstPad* pad = gst_element_get_static_pad(sink_, "sink");
#if (GST_VERSION_MAJOR == 1)
const GstCaps *caps = gst_pad_get_current_caps(pad);
GstCaps *caps = gst_sample_get_caps(sample);
#else
GstPad* pad = gst_element_get_static_pad(sink_, "sink");
const GstCaps *caps = gst_pad_get_negotiated_caps(pad);
#endif
GstStructure *structure = gst_caps_get_structure(caps,0);
Expand Down Expand Up @@ -389,10 +386,18 @@ namespace gscam {
// Release the buffer
if(buf) {
#if (GST_VERSION_MAJOR == 1)
// Unmap the memory
gst_memory_unmap(memory, &info);
gst_memory_unref(memory);
#endif
gst_buffer_unref(buf);
// Do not unref the buffer obtained by gst_sample_get_buffer
// (We do not own the reference to it!)
// NO : gst_buffer_unref(buf);
//
// Release the sample
if (sample) {
gst_sample_unref(sample);
}
}

ros::spinOnce();
Expand Down