From 84ad58143f6c96077d0502b39aea996f092fd4aa Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Wed, 6 Dec 2017 18:08:31 -0800 Subject: [PATCH] Got udev rules working for usb serial devices and cameras on rover --- .../UDEV Rules/99-rover-cameras.rules | 15 + .../UDEV Rules/99-rover-usb-serial.rules | 1 + .../UDEV Rules/install_rules.sh | 3 + rover/CMakeLists.txt | 1 + rover/gscam/CHANGELOG.rst | 105 ----- rover/gscam/CMakeLists.txt | 118 ----- rover/gscam/Makefile | 2 - rover/gscam/README.md | 56 --- rover/gscam/examples/decklink.launch | 22 - rover/gscam/examples/gscam_nodelet.launch | 20 - rover/gscam/examples/minoru.launch | 39 -- rover/gscam/examples/nodelet_pipeline.launch | 41 -- rover/gscam/examples/osx.launch | 20 - .../examples/uncalibrated_parameters.ini | 30 -- rover/gscam/examples/v4l.launch | 19 - rover/gscam/examples/v4ljpeg.launch | 20 - rover/gscam/examples/videofile.launch | 19 - rover/gscam/include/gscam/gscam.h | 69 --- rover/gscam/include/gscam/gscam_nodelet.h | 26 -- rover/gscam/manifest.xml | 25 -- rover/gscam/nodelet_plugins.xml | 11 - rover/gscam/package.xml | 42 -- rover/gscam/rosdep.yaml | 6 - rover/gscam/scripts/gscam_node.in | 5 - rover/gscam/src/gscam.cpp | 403 ------------------ rover/gscam/src/gscam_node.cpp | 14 - rover/gscam/src/gscam_nodelet.cpp | 27 -- rover/uvc_capture/launch/uvc.launch | 8 +- rover/uvc_capture/launch/uvc_one_cam.launch | 13 + rover/zed_wrapper/cfg/Zed.cfg | 0 rover/zed_wrapper/launch/zed_camera.launch | 4 +- 31 files changed, 39 insertions(+), 1145 deletions(-) create mode 100644 environment_reference/UDEV Rules/99-rover-cameras.rules create mode 100644 environment_reference/UDEV Rules/99-rover-usb-serial.rules create mode 100755 environment_reference/UDEV Rules/install_rules.sh create mode 120000 rover/CMakeLists.txt delete mode 100644 rover/gscam/CHANGELOG.rst delete mode 100644 rover/gscam/CMakeLists.txt delete mode 100644 rover/gscam/Makefile delete mode 100644 rover/gscam/README.md delete mode 100644 rover/gscam/examples/decklink.launch delete mode 100644 rover/gscam/examples/gscam_nodelet.launch delete mode 100644 rover/gscam/examples/minoru.launch delete mode 100644 rover/gscam/examples/nodelet_pipeline.launch delete mode 100644 rover/gscam/examples/osx.launch delete mode 100644 rover/gscam/examples/uncalibrated_parameters.ini delete mode 100644 rover/gscam/examples/v4l.launch delete mode 100644 rover/gscam/examples/v4ljpeg.launch delete mode 100644 rover/gscam/examples/videofile.launch delete mode 100644 rover/gscam/include/gscam/gscam.h delete mode 100644 rover/gscam/include/gscam/gscam_nodelet.h delete mode 100644 rover/gscam/manifest.xml delete mode 100644 rover/gscam/nodelet_plugins.xml delete mode 100644 rover/gscam/package.xml delete mode 100644 rover/gscam/rosdep.yaml delete mode 100644 rover/gscam/scripts/gscam_node.in delete mode 100644 rover/gscam/src/gscam.cpp delete mode 100644 rover/gscam/src/gscam_node.cpp delete mode 100644 rover/gscam/src/gscam_nodelet.cpp create mode 100644 rover/uvc_capture/launch/uvc_one_cam.launch mode change 100644 => 100755 rover/zed_wrapper/cfg/Zed.cfg diff --git a/environment_reference/UDEV Rules/99-rover-cameras.rules b/environment_reference/UDEV Rules/99-rover-cameras.rules new file mode 100644 index 0000000..3dbeb02 --- /dev/null +++ b/environment_reference/UDEV Rules/99-rover-cameras.rules @@ -0,0 +1,15 @@ +# udevadm info -a -p $(udevadm info -q path -n /dev/video2) +# ATTRS{serial}=="B9A8A5FF", MODE="0660",GROUP="nvidia", +# SUBSYSTEM=="video4linux",ATTRS{idVendor}=="0x046d",ATTRS{idProduct}=="0x082d",NAME="videoext" + +# The zed camera +KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="2b03", ATTRS{idProduct}=="f580", SYMLINK+="rover/cam_zed" + +# The first C920 Webcam +KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="082d", ATTRS{serial}=="B9A8A5FF", SYMLINK+="rover/cam_undercarriage" + +# The second C920 Webcam +KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="082d", ATTRS{serial}=="A98AA5FF", SYMLINK+="rover/cam_grasper" + +# The special main nav cam +KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="05a3", ATTRS{idProduct}=="9422", ATTRS{serial}=="SN0001", SYMLINK+="rover/cam_main_nav" diff --git a/environment_reference/UDEV Rules/99-rover-usb-serial.rules b/environment_reference/UDEV Rules/99-rover-usb-serial.rules new file mode 100644 index 0000000..553d26e --- /dev/null +++ b/environment_reference/UDEV Rules/99-rover-usb-serial.rules @@ -0,0 +1 @@ +SUBSYSTEM=="tty", ATTRS{serial}=="A5027JQW", SYMLINK+="rover/ttyARM" diff --git a/environment_reference/UDEV Rules/install_rules.sh b/environment_reference/UDEV Rules/install_rules.sh new file mode 100755 index 0000000..a292b6c --- /dev/null +++ b/environment_reference/UDEV Rules/install_rules.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sudo cp 99-rover-cameras.rules /etc/udev/rules.d/. +sudo cp 99-rover-usb-serial.rules /etc/udev/rules.d/. diff --git a/rover/CMakeLists.txt b/rover/CMakeLists.txt new file mode 120000 index 0000000..581e61d --- /dev/null +++ b/rover/CMakeLists.txt @@ -0,0 +1 @@ +/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake \ No newline at end of file diff --git a/rover/gscam/CHANGELOG.rst b/rover/gscam/CHANGELOG.rst deleted file mode 100644 index 58f7c12..0000000 --- a/rover/gscam/CHANGELOG.rst +++ /dev/null @@ -1,105 +0,0 @@ -^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Changelog for package gscam -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -0.1.3 (2013-12-19) ------------------- -* Removed special characters from changelog. - -0.1.2 (2013-12-19) ------------------- -* Added install targets for headers -* Adding note on blackmagic decklink cards -* Make sure nodelets are usable -* Add jpeg direct publishing without decoding -* Added system to use GST timestamps -* Valid test file for jpeg-based publisher -* Prepared for jpeg-only subscription -* Install some launch files + added nodelet pipeline demo -* Added missing bits to install the nodelet -* Support for gray (mono8) cameras. -* Remove unused ``bpp_`` member. -* Expose default settings for ``image_encodings`` to the ros master. -* Add in support for mono cameras. -* Contributors: Cedric Pradalier, Holger Rapp, Jonathan Bohren, Russell Toris, Severin Lemaignan - -0.1.1 (2013-05-30) ------------------- -* adding missing nodelet dep -* Contributors: Jonathan Bohren - -0.1.0 (2013-05-28) ------------------- -* adding maintainer/authors -* making node name backwards compatible -* re-adding package.xml -* more info spam -* removing old camera parameters file -* updating gscam to use ``camera_info_manager`` -* Fixing nodelet, adding example -* Making gscam a node and nodeelt -* adding a note on the videofile player and wrapping readme -* adding option to reopen a stream on EOF and adding a videofile example -* Hybrid catkin-rosbuild buildsystem -* adding minoru example -* putting example nodes into namespaces, adding correct error check in gscam source, making tf frame publishing optional -* rst->md -* making gscam conform to standard ``camera_drivers`` ROS API, note, still need to add polled mode -* fixes for decklink capture, adding another example -* can't have manifest.xml and package.xml in same directory -* removing unneeded find-pkgs -* building in catkin ws -* hybrid rosbuild/catkin buildsystem -* Adding changes that were made to the distribution branch that - should have gone into the exerpeimental branch in r2862. - Added a bunch of enhancements and fixed bugs involving data - missing fromthe image message headers. - Index: src/gscam.cpp - =================================================================== - Added ``camera_name`` and ``camera_parameters_file`` globals for camera - info. - Moved ros init to the top of the main function. - Gets the gstreamer configuration either from environment variable - ``GSCAM_CONFIG`` or ROS param ``~/gscam_config``. - Gets the camera calibration parameters from the file located at ROS - param ``~/camera_parameters_file``, will look at - "../camera_settings.txt" by default. - A bunch of re-indenting for consistency. - Updated a lot of error fprintfs to ``ROS_ERROR`` calls. - Gets the TF ``frame_id`` from the ROS param ``~/frame_id``, can be over- - written by camera parameters. - Now sets the appropriate ROS timestap in the image message header. - Now sets the appropriate TF frame in the image message header. - Added more detailed info/error/warn messages. - Modified the warning / segfault avoidance added to experimental in - r2756. Instead of skipping the frame, it just copies only the - amount of data that it was received, and reports the warning each - time, instead of just once. In a large scale system with lots of - messages, a single warning might easily get lost in the noise. - Index: examples/webcam_parameters.txt - =================================================================== - Added example camera parameters (uncalibrated) for a laptop webcam. - Index: examples/webcam.launch - =================================================================== - Added a launchfile that makes use of the new rosparam options and - TF frame. -* avoid segfault when buffer size is too small -* ROSProcessingjs clean-up -* makefile so rosmake is more reliable -* gscam build tweak for oneiric -* fixes for Natty build per Willow request -* stop node on EOS -* File support courtesy of John Hoare of the University of Tennesse at Knoxville -* more conservative license policy -* fps workaround -* ding gscam -* back to before -* two publishers -* Lots of changes. AR Alpha now expects files in the bin directory, to facilitate roslaunch. Gscam must be started from the bin directory, or, again, using roslaunch. The localizer code now works correctly and has been tested on a Create, but has problems cause by AR alpha's processing delays. -* Bugfix: supply default camera parameters when real ones are unavailable. -* Fully-functional calibration file writing. -* Partial changes for file-writing gscam. -* Gscam now fits into an image processing pipeline with rectified images. TODO: Save camera configuration info. -* Handles built for camera info services, but no testing. -* Changed the name of the GStreamer camera package. probe will henceforth be known as gscam. -* Contributors: Jonathan Bohren, chriscrick, evan.exe@gmail.com, nevernim@gmail.com, trevorjay diff --git a/rover/gscam/CMakeLists.txt b/rover/gscam/CMakeLists.txt deleted file mode 100644 index 4d80953..0000000 --- a/rover/gscam/CMakeLists.txt +++ /dev/null @@ -1,118 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) - -project(gscam) - -# System Dependencies -find_package(PkgConfig) -pkg_check_modules(GSTREAMER REQUIRED gstreamer-0.10) -pkg_check_modules(GST_APP REQUIRED gstreamer-app-0.10) - -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() - -# 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) - - diff --git a/rover/gscam/Makefile b/rover/gscam/Makefile deleted file mode 100644 index 73e8a91..0000000 --- a/rover/gscam/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -EXTRA_CMAKE_FLAGS = -DUSE_ROSBUILD:BOOL=1 -include $(shell rospack find mk)/cmake.mk diff --git a/rover/gscam/README.md b/rover/gscam/README.md deleted file mode 100644 index 907ba88..0000000 --- a/rover/gscam/README.md +++ /dev/null @@ -1,56 +0,0 @@ -GSCam -===== - -This is a ROS package originally developed by the [Brown Robotics -Lab](http://robotics.cs.brown.edu/) for broadcasting any -[GStreamer](http://gstreamer.freedesktop.org/)-based video stream via the -standard [ROS Camera API](http://ros.org/wiki/camera_drivers). This fork has -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. - -ROS API (stable) ----------------- - -### gscam - -This can be run as both a node and a nodelet. - -#### Nodes - * `gscam` - -#### Topics - * `camera/image_raw` - * `camera/camera_info` - -#### Services - * `camera/set_camera_info` - -#### Parameters - * `~camera_name`: The name of the camera (corrsponding to the camera info) - * `~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. - * `~reopen_on_eof`: Re-open the stream if it ends (EOF). - * `~sync_sink`: Synchronize the app sink (sometimes setting this to `false` can resolve problems with sub-par framerates). - -C++ API (unstable) ------------------- - -The gscam c++ library can be used, but it is not guaranteed to be stable. - -Examples --------- - -See example launchfiles and configs in the examples directory. Currently there -are examples for: - * [Video4Linux2](examples/v4l.launch): Standard - [video4linux](http://en.wikipedia.org/wiki/Video4Linux)-based cameras like - USB webcams - * [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): - [BlackMagic](http://www.blackmagicdesign.com/products/decklink/models) - DeckLink SDI capture cards (note: this requires the `gst-plugins-bad` plugins) diff --git a/rover/gscam/examples/decklink.launch b/rover/gscam/examples/decklink.launch deleted file mode 100644 index 4c758b5..0000000 --- a/rover/gscam/examples/decklink.launch +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/gscam_nodelet.launch b/rover/gscam/examples/gscam_nodelet.launch deleted file mode 100644 index fdb760a..0000000 --- a/rover/gscam/examples/gscam_nodelet.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/minoru.launch b/rover/gscam/examples/minoru.launch deleted file mode 100644 index 9fabf80..0000000 --- a/rover/gscam/examples/minoru.launch +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/nodelet_pipeline.launch b/rover/gscam/examples/nodelet_pipeline.launch deleted file mode 100644 index 4681735..0000000 --- a/rover/gscam/examples/nodelet_pipeline.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/osx.launch b/rover/gscam/examples/osx.launch deleted file mode 100644 index 7973851..0000000 --- a/rover/gscam/examples/osx.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/uncalibrated_parameters.ini b/rover/gscam/examples/uncalibrated_parameters.ini deleted file mode 100644 index 9b5165b..0000000 --- a/rover/gscam/examples/uncalibrated_parameters.ini +++ /dev/null @@ -1,30 +0,0 @@ -# Camera intrinsics - -[image] - -width -320 - -height -240 - -[default] - -camera matrix -467.14110 0.00000 158.56653 -0.00000 465.42608 131.37432 -0.00000 0.00000 1.00000 - -distortion --0.16999 0.31931 0.00929 0.00040 0.00000 - - -rectification -1.00000 0.00000 0.00000 -0.00000 1.00000 0.00000 -0.00000 0.00000 1.00000 - -projection -458.62505 0.00000 158.11160 0.00000 -0.00000 457.90904 131.91881 0.00000 -0.00000 0.00000 1.00000 0.00000 diff --git a/rover/gscam/examples/v4l.launch b/rover/gscam/examples/v4l.launch deleted file mode 100644 index 52a4107..0000000 --- a/rover/gscam/examples/v4l.launch +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/v4ljpeg.launch b/rover/gscam/examples/v4ljpeg.launch deleted file mode 100644 index 78902be..0000000 --- a/rover/gscam/examples/v4ljpeg.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/examples/videofile.launch b/rover/gscam/examples/videofile.launch deleted file mode 100644 index 6b3b6a6..0000000 --- a/rover/gscam/examples/videofile.launch +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/include/gscam/gscam.h b/rover/gscam/include/gscam/gscam.h deleted file mode 100644 index e4b4ee2..0000000 --- a/rover/gscam/include/gscam/gscam.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __GSCAM_GSCAM_H -#define __GSCAM_GSCAM_H - -extern "C"{ -#include -#include -} - -#include - -#include -#include - -#include -#include -#include - -#include - -namespace gscam { - - class GSCam { - public: - GSCam(ros::NodeHandle nh_camera, ros::NodeHandle nh_private); - ~GSCam(); - - bool configure(); - bool init_stream(); - void publish_stream(); - void cleanup_stream(); - - void run(); - - private: - // General gstreamer configuration - std::string gsconfig_; - - // Gstreamer structures - GstElement *pipeline_; - GstElement *sink_; - - // Appsink configuration - bool sync_sink_; - bool preroll_; - bool reopen_on_eof_; - bool use_gst_timestamps_; - - // Camera publisher configuration - std::string frame_id_; - int width_, height_; - std::string image_encoding_; - std::string camera_name_; - std::string camera_info_url_; - - // ROS Inteface - // Calibration between ros::Time and gst timestamps - double time_offset_; - ros::NodeHandle nh_, nh_private_; - image_transport::ImageTransport image_transport_; - camera_info_manager::CameraInfoManager camera_info_manager_; - image_transport::CameraPublisher camera_pub_; - // Case of a jpeg only publisher - ros::Publisher jpeg_pub_; - ros::Publisher cinfo_pub_; - }; - -} - -#endif // ifndef __GSCAM_GSCAM_H diff --git a/rover/gscam/include/gscam/gscam_nodelet.h b/rover/gscam/include/gscam/gscam_nodelet.h deleted file mode 100644 index c450dab..0000000 --- a/rover/gscam/include/gscam/gscam_nodelet.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __GSCAM_GSCAM_NODELET_H -#define __GSCAM_GSCAM_NODELET_H - -#include - -#include - -#include -#include - -namespace gscam { - class GSCamNodelet : public nodelet::Nodelet - { - public: - GSCamNodelet(); - ~GSCamNodelet(); - - virtual void onInit(); - - private: - boost::scoped_ptr gscam_driver_; - boost::scoped_ptr stream_thread_; - }; -} - -#endif // infdef __GSCAM_GSCAM_NODELET_H diff --git a/rover/gscam/manifest.xml b/rover/gscam/manifest.xml deleted file mode 100644 index f7188ab..0000000 --- a/rover/gscam/manifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - -A ROS camera driver that uses gstreamer to connect to devices such as webcams. - - Graylin Trevor Jay, Christopher Crick - tjay@cs.brown.edu, chriscrick@cs.brown.edu - LGPL - - - - - - - - - - - - - - - - - - diff --git a/rover/gscam/nodelet_plugins.xml b/rover/gscam/nodelet_plugins.xml deleted file mode 100644 index 25cfd05..0000000 --- a/rover/gscam/nodelet_plugins.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Nodelet for publishing a ROS camera interface from a GStreamer stream. - - - - diff --git a/rover/gscam/package.xml b/rover/gscam/package.xml deleted file mode 100644 index 458be1f..0000000 --- a/rover/gscam/package.xml +++ /dev/null @@ -1,42 +0,0 @@ - - gscam - 0.1.3 - - A ROS camera driver that uses gstreamer to connect to - devices such as webcams. - - Jonathan Bohren - BSD - - Jonathan Bohren - Graylin Trevor Jay - Christopher Crick - - catkin - - libgstreamer0.10-dev - libgstreamer-plugins-base0.10-dev - - nodelet - cv_bridge - roscpp - image_transport - sensor_msgs - camera_calibration_parsers - camera_info_manager - - nodelet - cv_bridge - roscpp - image_transport - sensor_msgs - camera_calibration_parsers - camera_info_manager - - - - - - - - diff --git a/rover/gscam/rosdep.yaml b/rover/gscam/rosdep.yaml deleted file mode 100644 index b33fd50..0000000 --- a/rover/gscam/rosdep.yaml +++ /dev/null @@ -1,6 +0,0 @@ -libgstreamer0.10-dev: - ubuntu: - libgstreamer0.10-dev -libgstreamer-plugins-base0.10-dev: - ubuntu: - libgstreamer-plugins-base0.10-dev diff --git a/rover/gscam/scripts/gscam_node.in b/rover/gscam/scripts/gscam_node.in deleted file mode 100644 index fbeff2b..0000000 --- a/rover/gscam/scripts/gscam_node.in +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -echo '[WARNING] gscam_node is an interim dependency and will be removed in the next release! Please change all launchfiles back to use "gscam" instead of "gscam_node"' - -${EXECUTABLE_OUTPUT_PATH}/gscam diff --git a/rover/gscam/src/gscam.cpp b/rover/gscam/src/gscam.cpp deleted file mode 100644 index dc96c22..0000000 --- a/rover/gscam/src/gscam.cpp +++ /dev/null @@ -1,403 +0,0 @@ - -#include -#include -#include -#include - - -#include -extern "C"{ -#include -#include -} - -#include - -#include -#include - - -#include -#include -#include -#include -#include - -#include - -#include - -namespace gscam { - - GSCam::GSCam(ros::NodeHandle nh_camera, ros::NodeHandle nh_private) : - gsconfig_(""), - pipeline_(NULL), - sink_(NULL), - nh_(nh_camera), - nh_private_(nh_private), - image_transport_(nh_camera), - camera_info_manager_(nh_camera) - { - } - - GSCam::~GSCam() - { - } - - bool GSCam::configure() - { - // Get gstreamer configuration - // (either from environment variable or ROS param) - std::string gsconfig_rosparam = ""; - bool gsconfig_rosparam_defined = false; - char *gsconfig_env = NULL; - - gsconfig_rosparam_defined = nh_private_.getParam("gscam_config",gsconfig_rosparam); - gsconfig_env = getenv("GSCAM_CONFIG"); - - if (!gsconfig_env && !gsconfig_rosparam_defined) { - ROS_FATAL( "Problem getting GSCAM_CONFIG environment variable and 'gscam_config' rosparam is not set. This is needed to set up a gstreamer pipeline." ); - return false; - } else if(gsconfig_env && gsconfig_rosparam_defined) { - ROS_FATAL( "Both GSCAM_CONFIG environment variable and 'gscam_config' rosparam are set. Please only define one." ); - return false; - } else if(gsconfig_env) { - gsconfig_ = gsconfig_env; - ROS_INFO_STREAM("Using gstreamer config from env: \""<message ); - return false; - } - - // Create RGB sink - sink_ = gst_element_factory_make("appsink",NULL); - GstCaps * caps = NULL; - if (image_encoding_ == sensor_msgs::image_encodings::RGB8) { - caps = gst_caps_new_simple("video/x-raw-rgb", NULL); - } else if (image_encoding_ == sensor_msgs::image_encodings::MONO8) { - caps = gst_caps_new_simple("video/x-raw-gray", NULL); - } else if (image_encoding_ == "jpeg") { - caps = gst_caps_new_simple("image/jpeg", NULL); - } - gst_app_sink_set_caps(GST_APP_SINK(sink_), caps); - gst_caps_unref(caps); - - // Set whether the sink should sync - // Sometimes setting this to true can cause a large number of frames to be - // dropped - gst_base_sink_set_sync( - GST_BASE_SINK(sink_), - (sync_sink_) ? TRUE : FALSE); - - if(GST_IS_PIPELINE(pipeline_)) { - GstPad *outpad = gst_bin_find_unlinked_pad(GST_BIN(pipeline_), GST_PAD_SRC); - g_assert(outpad); - - GstElement *outelement = gst_pad_get_parent_element(outpad); - g_assert(outelement); - gst_object_unref(outpad); - - if(!gst_bin_add(GST_BIN(pipeline_), sink_)) { - ROS_FATAL("gst_bin_add() failed"); - gst_object_unref(outelement); - gst_object_unref(pipeline_); - return false; - } - - if(!gst_element_link(outelement, sink_)) { - ROS_FATAL("GStreamer: cannot link outelement(\"%s\") -> sink\n", gst_element_get_name(outelement)); - gst_object_unref(outelement); - gst_object_unref(pipeline_); - return false; - } - - gst_object_unref(outelement); - } else { - GstElement* launchpipe = pipeline_; - pipeline_ = gst_pipeline_new(NULL); - g_assert(pipeline_); - - gst_object_unparent(GST_OBJECT(launchpipe)); - - gst_bin_add_many(GST_BIN(pipeline_), launchpipe, sink_, NULL); - - if(!gst_element_link(launchpipe, sink_)) { - ROS_FATAL("GStreamer: cannot link launchpipe -> sink"); - gst_object_unref(pipeline_); - return false; - } - } - - // Calibration between ros::Time and gst timestamps - GstClock * clock = gst_system_clock_obtain(); - ros::Time now = ros::Time::now(); - GstClockTime ct = gst_clock_get_time(clock); - gst_object_unref(clock); - time_offset_ = now.toSec() - GST_TIME_AS_USECONDS(ct)/1e6; - ROS_INFO("Time offset: %.3f",time_offset_); - - gst_element_set_state(pipeline_, GST_STATE_PAUSED); - - if (gst_element_get_state(pipeline_, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE) { - ROS_FATAL("Failed to PAUSE stream, check your gstreamer configuration."); - return false; - } else { - ROS_DEBUG_STREAM("Stream is PAUSED."); - } - - // Create ROS camera interface - if (image_encoding_ == "jpeg") { - jpeg_pub_ = nh_.advertise("camera/image_raw/compressed",1); - cinfo_pub_ = nh_.advertise("camera/camera_info",1); - } else { - camera_pub_ = image_transport_.advertiseCamera("camera/image_raw", 1); - } - - return true; - } - - void GSCam::publish_stream() - { - ROS_INFO_STREAM("Publishing stream..."); - - // Pre-roll camera if needed - if (preroll_) { - ROS_DEBUG("Performing preroll..."); - - //The PAUSE, PLAY, PAUSE, PLAY cycle is to ensure proper pre-roll - //I am told this is needed and am erring on the side of caution. - gst_element_set_state(pipeline_, GST_STATE_PLAYING); - if (gst_element_get_state(pipeline_, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE) { - ROS_ERROR("Failed to PLAY during preroll."); - return; - } else { - ROS_DEBUG("Stream is PLAYING in preroll."); - } - - gst_element_set_state(pipeline_, GST_STATE_PAUSED); - if (gst_element_get_state(pipeline_, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE) { - ROS_ERROR("Failed to PAUSE."); - return; - } else { - ROS_INFO("Stream is PAUSED in preroll."); - } - } - - if(gst_element_set_state(pipeline_, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { - ROS_ERROR("Could not start stream!"); - return; - } - ROS_INFO("Started stream."); - - // Poll the data as fast a spossible - while(ros::ok()) { - // This should block until a new frame is awake, this way, we'll run at the - // actual capture framerate of the device. - // ROS_DEBUG("Getting data..."); - GstBuffer* buf = gst_app_sink_pull_buffer(GST_APP_SINK(sink_)); - GstClockTime bt = gst_element_get_base_time(pipeline_); - // ROS_INFO("New buffer: timestamp %.6f %lu %lu %.3f", - // 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, ¤t)) { - ROS_INFO_STREAM("Position "<header.stamp = ros::Time(GST_TIME_AS_USECONDS(buf->timestamp+bt)/1e6+time_offset_); - } else { - cinfo->header.stamp = ros::Time::now(); - } - // ROS_INFO("Image time stamp: %.3f",cinfo->header.stamp.toSec()); - cinfo->header.frame_id = frame_id_; - if (image_encoding_ == "jpeg") { - sensor_msgs::CompressedImagePtr img(new sensor_msgs::CompressedImage()); - img->header = cinfo->header; - img->format = "jpeg"; - img->data.resize(buf->size); - std::copy(buf->data, (buf->data)+(buf->size), - img->data.begin()); - jpeg_pub_.publish(img); - cinfo_pub_.publish(cinfo); - } else { - // Complain if the returned buffer is smaller than we expect - const unsigned int expected_frame_size = - image_encoding_ == sensor_msgs::image_encodings::RGB8 - ? width_ * height_ * 3 - : width_ * height_; - - if (buf->size < expected_frame_size) { - ROS_WARN_STREAM( "GStreamer image buffer underflow: Expected frame to be " - << expected_frame_size << " bytes but got only " - << (buf->size) << " bytes. (make sure frames are correctly encoded)"); - } - - // Construct Image message - sensor_msgs::ImagePtr img(new sensor_msgs::Image()); - - img->header = cinfo->header; - - // Image data and metadata - img->width = width_; - img->height = height_; - img->encoding = image_encoding_; - img->is_bigendian = false; - img->data.resize(expected_frame_size); - - // Copy only the data we received - // Since we're publishing shared pointers, we need to copy the image so - // we can free the buffer allocated by gstreamer - if (image_encoding_ == sensor_msgs::image_encodings::RGB8) { - img->step = width_ * 3; - } else { - img->step = width_; - } - std::copy( - buf->data, - (buf->data)+(buf->size), - img->data.begin()); - - // Publish the image/info - camera_pub_.publish(img, cinfo); - } - - // Release the buffer - gst_buffer_unref(buf); - - ros::spinOnce(); - } - } - - void GSCam::cleanup_stream() - { - // Clean up - ROS_INFO("Stopping gstreamer pipeline..."); - if(pipeline_) { - gst_element_set_state(pipeline_, GST_STATE_NULL); - gst_object_unref(pipeline_); - pipeline_ = NULL; - } - } - - void GSCam::run() { - while(ros::ok()) { - if(!this->configure()) { - ROS_FATAL("Failed to configure gscam!"); - break; - } - - if(!this->init_stream()) { - ROS_FATAL("Failed to initialize gscam stream!"); - break; - } - - // Block while publishing - this->publish_stream(); - - this->cleanup_stream(); - - ROS_INFO("GStreamer stream stopped!"); - - if(reopen_on_eof_) { - ROS_INFO("Reopening stream..."); - } else { - ROS_INFO("Cleaning up stream and exiting..."); - break; - } - } - - } - - // Example callbacks for appsink - // TODO: enable callback-based capture - void gst_eos_cb(GstAppSink *appsink, gpointer user_data ) { - } - GstFlowReturn gst_new_preroll_cb(GstAppSink *appsink, gpointer user_data ) { - return GST_FLOW_OK; - } - GstFlowReturn gst_new_asample_cb(GstAppSink *appsink, gpointer user_data ) { - return GST_FLOW_OK; - } - -} diff --git a/rover/gscam/src/gscam_node.cpp b/rover/gscam/src/gscam_node.cpp deleted file mode 100644 index f7d01c9..0000000 --- a/rover/gscam/src/gscam_node.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -#include -#include - -int main(int argc, char** argv) { - ros::init(argc, argv, "gscam_publisher"); - ros::NodeHandle nh, nh_private("~"); - - gscam::GSCam gscam_driver(nh, nh_private); - gscam_driver.run(); - - return 0; -} - diff --git a/rover/gscam/src/gscam_nodelet.cpp b/rover/gscam/src/gscam_nodelet.cpp deleted file mode 100644 index d3e98d7..0000000 --- a/rover/gscam/src/gscam_nodelet.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -#include -#include -#include -#include - -PLUGINLIB_DECLARE_CLASS(gscam, GSCamNodelet, gscam::GSCamNodelet, nodelet::Nodelet) - -namespace gscam { - GSCamNodelet::GSCamNodelet() : - nodelet::Nodelet(), - gscam_driver_(NULL), - stream_thread_(NULL) - { - } - - GSCamNodelet::~GSCamNodelet() - { - stream_thread_->join(); - } - - void GSCamNodelet::onInit() - { - gscam_driver_.reset(new gscam::GSCam(this->getNodeHandle(), this->getPrivateNodeHandle())); - stream_thread_.reset(new boost::thread(boost::bind(&GSCam::run, gscam_driver_.get()))); - } -} diff --git a/rover/uvc_capture/launch/uvc.launch b/rover/uvc_capture/launch/uvc.launch index a7b1e0a..75aae59 100644 --- a/rover/uvc_capture/launch/uvc.launch +++ b/rover/uvc_capture/launch/uvc.launch @@ -1,11 +1,11 @@ - + - + @@ -13,11 +13,11 @@ - + - + diff --git a/rover/uvc_capture/launch/uvc_one_cam.launch b/rover/uvc_capture/launch/uvc_one_cam.launch new file mode 100644 index 0000000..d7a6812 --- /dev/null +++ b/rover/uvc_capture/launch/uvc_one_cam.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/rover/zed_wrapper/cfg/Zed.cfg b/rover/zed_wrapper/cfg/Zed.cfg old mode 100644 new mode 100755 diff --git a/rover/zed_wrapper/launch/zed_camera.launch b/rover/zed_wrapper/launch/zed_camera.launch index 417ccdc..e84c326 100644 --- a/rover/zed_wrapper/launch/zed_camera.launch +++ b/rover/zed_wrapper/launch/zed_camera.launch @@ -46,10 +46,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + - +