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

[ROS2:Foxy] Added ros2 support #5

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
76f55e7
moved headers to include
MRo47 Aug 21, 2022
5634504
infolist modified
MRo47 Aug 21, 2022
9f47322
modified with shared pointers
MRo47 Aug 21, 2022
d2bea17
updated imagelist for ros2
MRo47 Aug 21, 2022
3907a62
tmestamp corrector updated for ros2
MRo47 Aug 21, 2022
1f19228
updated package xml for ros2
MRo47 Aug 21, 2022
ec725fc
modifying node for ros2
MRo47 Aug 22, 2022
731ab33
updates to cam infor subs
MRo47 Aug 23, 2022
b5acd65
updated camera info publisher
MRo47 Aug 23, 2022
3726c14
updated servers
MRo47 Aug 23, 2022
21760d1
image publisher updated
MRo47 Aug 24, 2022
4a0e337
cam info pub updated with shared ptr
MRo47 Aug 24, 2022
21ce43d
non const messages
MRo47 Aug 24, 2022
ca6712c
non const messages
MRo47 Aug 24, 2022
69a1280
time of type builtin interfaces
MRo47 Aug 24, 2022
67251a7
updated complete genicam camera node
MRo47 Aug 24, 2022
ee96f22
renamed main nodelet to node
MRo47 Aug 25, 2022
5fb2c3f
removed ros1 steadytime check
MRo47 Aug 25, 2022
0c6d1dd
updated node main
MRo47 Aug 25, 2022
e0cb531
remove nested cmakelists
MRo47 Aug 25, 2022
ff04721
corrected header path
MRo47 Aug 27, 2022
402cc26
pcakage xml remove builtin interface depend
MRo47 Aug 27, 2022
fb01377
moved interfaces out
MRo47 Aug 28, 2022
f68df4e
added service args as ptrs + compiled successfully
MRo47 Aug 28, 2022
f7ec9ca
fixed cmakelists able to run
MRo47 Aug 28, 2022
fb47e3a
name_[node] for exec
MRo47 Aug 28, 2022
63284b7
added launch and config
MRo47 Aug 28, 2022
3f71fdd
readme update for rosdep install
MRo47 Aug 28, 2022
96d9ccb
run on init for node
MRo47 Sep 3, 2022
ea37923
cleanup logging + more messages in grab
MRo47 Sep 3, 2022
efabe52
added config files and install commands
MRo47 Sep 3, 2022
7cec128
ran clang format + added clang command file
MRo47 Sep 3, 2022
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
149 changes: 61 additions & 88 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)

project(rc_genicam_camera)
include(cmake/project_version.cmake)
Expand All @@ -9,17 +9,14 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "Build type: DEBUG or RELEASE" FORCE)
endif ()

# - Standard definitions -
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

add_definitions(-Wall)
if (CMAKE_MAJOR_VERSION VERSION_LESS "3.1.0")
add_definitions(-std=c++11)
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()

add_definitions(-Wall)
add_definitions(-Wno-unknown-pragmas)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# checking for intel architecture and activating SSSE3 for optimization of
# rotating images
Expand All @@ -37,97 +34,73 @@ if (USE_SSSE3)
add_definitions(-mssse3)
endif ()

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
nodelet
roscpp
std_srvs
sensor_msgs
image_transport
dynamic_reconfigure
message_generation
)
find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rc_genicam_camera_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(RC_GENICAM_API REQUIRED)

## Generate services in the 'srv' folder
add_service_files(
FILES
GetGenICamParameter.srv
SetGenICamParameter.srv
include_directories(
include
${RC_GENICAM_API_INCLUDE_DIRS}
)

## Generate messages in the 'msg' folder
add_message_files(
FILES
ReturnValue.msg
ament_export_include_directories("include/${PROJECT_NAME}")

add_executable(${PROJECT_NAME}_node
src/genicam_camera_node_main.cc
src/publishers/camera_info_publisher.cc
src/publishers/image_publisher.cc
src/camerainfolist.cc
src/genicam_camera_node.cc
src/imagelist.cc
src/timestamp_corrector.cc
)

## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
ament_target_dependencies(${PROJECT_NAME}_node
rclcpp
sensor_msgs
std_msgs
image_transport
rc_genicam_camera_interfaces
)

## System dependencies are found with CMake's conventions
find_package(RC_GENICAM_API 2.0.3 REQUIRED)

#########################################
## Definitions for dynamic reconfigure ##
#########################################

#generate_dynamic_reconfigure_options(cfg/rc_genicam_camera.cfg)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES rc_stereocamera
CATKIN_DEPENDS nodelet roscpp sensor_msgs std_msgs std_srvs
# DEPENDS
target_link_libraries(${PROJECT_NAME}_node
rc_genicam_api::rc_genicam_api
)

###########
## Build ##
###########
# ############
# # Install ##
# ############

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
${RC_GENICAM_API_INCLUDE_DIRS}
install(TARGETS ${PROJECT_NAME}_node
DESTINATION lib/${PROJECT_NAME}
)

add_subdirectory(src)

#############
## Install ##
#############
# Install launch and config files.
install(DIRECTORY launch config
DESTINATION share/${PROJECT_NAME}/
)

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES
rc_genicam_camera_nodelet.xml
README.md
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
#install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

######################################
## Define information for packaging ##
######################################
# optionally specify dependencies of the debian package here (comma separated!)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # to prevent automatic addition of libs that are ORed in dependencies
set(CPACK_DEBIAN_PACKAGE_DEPENDS "rc-genicam-api (>= 2.0.3) | ros-$ENV{ROS_DISTRO}-rc-genicam-api (>= 2.0.3), ros-$ENV{ROS_DISTRO}-image-pipeline")

include(cmake/package_debian.cmake)
# ## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# rc_genicam_camera_nodelet.xml
# README.md
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
# #install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

# ######################################
# ## Define information for packaging ##
# ######################################
# # optionally specify dependencies of the debian package here (comma separated!)
# set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # to prevent automatic addition of libs that are ORed in dependencies
# set(CPACK_DEBIAN_PACKAGE_DEPENDS "rc-genicam-api (>= 2.0.3) | ros-$ENV{ROS_DISTRO}-rc-genicam-api (>= 2.0.3), ros-$ENV{ROS_DISTRO}-image-pipeline")

# include(cmake/package_debian.cmake)

ament_package()
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
rc_genicam_camera
-----------------
# rc_genicam_camera

This nodelet permits access to the configuration of a GenICam compatible camera
and publishes raw images and camera_info messages according to the ROS image
pipeline.

Configuration
-------------
## Install dependencies
```bash
rosdep update
rosdep install --from-paths src -y --ignore-src
```

## Configuration

#### Parameters
### Parameters

Parameters to be set to the ROS param server before run-time.

Expand Down Expand Up @@ -95,7 +99,7 @@ Parameters to be set to the ROS param server before run-time.
ID < 0. For stereo systems, 0 is used for the left camera and 1 for the right
camera. Default: -1.

#### Parameters for Synchronization
### Parameters for Synchronization

The following parameters are used for receiving and associating the time stamp
from the camera info of a hardware synchronized master camera that is
Expand Down
12 changes: 12 additions & 0 deletions config/basler.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TriggerMode=Off
AcquisitionMode=Continuous
AcquisitionFrameRateEnable=True
AcquisitionFrameRateAbs=30.00
ExposureAuto=Continuous
AutoExposureTimeUpperLimitRaw=14000
AutoExposureTimeLowerLimitRaw=80
# ExposureTime=14000.00
# GainAuto=Continuous
AutoGainRawUpperLimit=20.0
AutoGainRawLowerLimit=1.0
# Gain=14.00
8 changes: 8 additions & 0 deletions config/flir.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
TriggerMode=Off
AcquisitionMode=Continuous
AcquisitionFrameRateEnable=True
AcquisitionFrameRate=30.00
ExposureAuto=Continuous
# ExposureTime=14997.00
GainAuto=Continuous
# Gain=14.00
16 changes: 16 additions & 0 deletions config/rc_genicam_camera_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
rc_genicam_camera_node:
ros__parameters:
device: "23853944" #BASLER
# device: "18486677" #FLIR1
# device: "18486668" #FLIR2
gev_access: "control" #control/exclusive
# frame_id: "cam0" #camera frame ID, default camera[<calib_id>
# image_prefix: "/tmp/cam0" #to store images
rotate: False #True for rotate 180
config_file: "install/rc_genicam_camera/share/rc_genicam_camera/config/basler.config" #genicam config file, set wrt ros2 workspace, this is where it is installed check install config dir in cmakelists. or set absolute path
# calib_file: "/path/to/calib" #camera calib file
# calib_id: -1 #0 for left 1 for right, -1 default
# host_timestamp: True #True for using the host time, False default
# timestamp_tolerance: #Maximum acceptable tolerance in seconds between system and camera clock, default 0.01
# sync_info: #Name of topic that provides CameraInfo messages at the time when image acquisition is triggered via a hardware signal
# sync_tolerance: #Maximum acceptable tolerance in seconds between the CameraInfo timestamps and the image acquisition timestamps
13 changes: 7 additions & 6 deletions src/camerainfolist.h → include/camerainfolist.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
#ifndef RC_GENICAM_CAMERA_CAMERAINFOLIST
#define RC_GENICAM_CAMERA_CAMERAINFOLIST

#include <ros/ros.h>
#include <sensor_msgs/CameraInfo.h>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/camera_info.hpp>

namespace rcgccam
{
Expand Down Expand Up @@ -72,7 +73,7 @@ class CameraInfoList
@return Dropped camera info message, null pointer if nothing is
dropped.
*/
sensor_msgs::CameraInfoPtr add(const sensor_msgs::CameraInfoPtr& info);
sensor_msgs::msg::CameraInfo::SharedPtr add(sensor_msgs::msg::CameraInfo::SharedPtr info);

/**
Remove all camera infos that have a timestamp that is older or equal than
Expand All @@ -81,7 +82,7 @@ class CameraInfoList
@param timestamp Timestamp.
@return Number of removed camera infos.
*/
int removeOld(const ros::Time& timestamp);
int removeOld(const rclcpp::Time& timestamp);

/**
Returns the oldest camera info that has a timestamp within the tolerance
Expand All @@ -92,12 +93,12 @@ class CameraInfoList
@param tolerance Maximum tolarance added or subtracted to the timestamp.
@return Pointer to camera info or 0.
*/
sensor_msgs::CameraInfoPtr find(const ros::Time& timestamp) const;
sensor_msgs::msg::CameraInfo::SharedPtr find(const rclcpp::Time& timestamp) const;

private:
size_t maxsize_;
uint64_t tolerance_;
std::vector<sensor_msgs::CameraInfoPtr> list_;
std::vector<sensor_msgs::msg::CameraInfo::SharedPtr> list_;
};

} // namespace rcgccam
Expand Down
33 changes: 15 additions & 18 deletions src/genicam_camera_nodelet.h → include/genicam_camera_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#include "publishers/camera_info_publisher.h"
#include "publishers/image_publisher.h"

#include <nodelet/nodelet.h>
#include <rclcpp/rclcpp.hpp>
#include <message_filters/subscriber.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/msg/camera_info.hpp>

#include <GenApi/GenApi.h>
#include <rc_genicam_api/device.h>
Expand All @@ -50,41 +50,38 @@
#include <mutex>
#include <atomic>

#include <rc_genicam_camera/GetGenICamParameter.h>
#include <rc_genicam_camera/SetGenICamParameter.h>
#include <rc_genicam_camera_interfaces/srv/set_gen_i_cam_parameter.hpp>
#include <rc_genicam_camera_interfaces/srv/get_gen_i_cam_parameter.hpp>

namespace rcgccam
{

class GenICamCameraNodelet : public nodelet::Nodelet
class GenICamCameraNode : public rclcpp::Node
{
using rcgc_get_srv = rc_genicam_camera_interfaces::srv::GetGenICamParameter;
using rcgc_set_srv = rc_genicam_camera_interfaces::srv::SetGenICamParameter;

public:

GenICamCameraNodelet();
virtual ~GenICamCameraNodelet();
explicit GenICamCameraNode(const std::string& node_name = "rc_genicam_camera_node");
virtual ~GenICamCameraNode();

virtual void onInit();

bool getGenICamParameter(rc_genicam_camera::GetGenICamParameter::Request& req,
rc_genicam_camera::GetGenICamParameter::Response& resp);
bool getGenICamParameter(rcgc_get_srv::Request::SharedPtr req, rcgc_get_srv::Response::SharedPtr resp);

bool setGenICamParameter(rc_genicam_camera::SetGenICamParameter::Request& req,
rc_genicam_camera::SetGenICamParameter::Response& resp);
bool setGenICamParameter(rcgc_set_srv::Request::SharedPtr req, rcgc_set_srv::Response::SharedPtr resp);

void syncInfo(sensor_msgs::CameraInfoPtr info);
void syncInfo(sensor_msgs::msg::CameraInfo::SharedPtr info);

private:

void grab(std::string device, rcg::Device::ACCESS access, std::string config);

double timestamp_tolerance_;
double sync_tolerance_;

ros::Subscriber sub_sync_info_;
rclcpp::Subscription<sensor_msgs::msg::CameraInfo>::SharedPtr sub_sync_info_ptr_;

ros::ServiceServer get_param_service_;
ros::ServiceServer set_param_service_;
rclcpp::Service<rcgc_get_srv>::SharedPtr get_param_service_ptr_;
rclcpp::Service<rcgc_set_srv>::SharedPtr set_param_service_ptr_;

std::string frame_id_;

Expand Down
Loading