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 devel #6

Merged
merged 20 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 18 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
141 changes: 70 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,88 +1,87 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(laser_proc)

## 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 roscpp sensor_msgs rosconsole nodelet pluginlib)

###################################################
## Declare things to be passed to other projects ##
###################################################

## 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 laser_proc_library laser_publisher laser_transport laser_proc_ROS LaserProcNodelet
CATKIN_DEPENDS roscpp sensor_msgs rosconsole nodelet
DEPENDS
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(class_loader REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

add_library(laser_proc
src/laser_proc.cpp
src/laser_publisher.cpp
src/laser_transport.cpp)
target_include_directories(laser_proc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(laser_proc
rclcpp
sensor_msgs
)

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

## Specify additional locations of header files
include_directories(include ${catkin_INCLUDE_DIRS})

## Library that does actual conversion
add_library(laser_proc_library src/LaserProc.cpp)
target_link_libraries(laser_proc_library ${catkin_LIBRARIES})

## Publisher library
add_library(laser_publisher src/LaserPublisher.cpp)
target_link_libraries(laser_publisher laser_proc_library ${catkin_LIBRARIES})

## Factory for making LaserPublishers
add_library(laser_transport src/LaserTransport.cpp)
target_link_libraries(laser_transport laser_publisher ${catkin_LIBRARIES})

## ROS Library
add_library(laser_proc_ROS src/LaserProcROS.cpp)
target_link_libraries(laser_proc_ROS laser_transport ${catkin_LIBRARIES})
add_library(laser_proc_ros src/laser_proc_ros.cpp)
target_link_libraries(laser_proc_ros laser_proc)
target_include_directories(laser_proc_ros
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(laser_proc_ros
rclcpp
sensor_msgs
)

## Nodelet wrapper
add_library(LaserProcNodelet src/LaserProcNodelet.cpp)
target_link_libraries(LaserProcNodelet laser_proc_ROS ${catkin_LIBRARIES})
add_library(laser_proc_nodelet src/laser_proc_nodelet.cpp)
target_link_libraries(laser_proc_nodelet laser_proc)
ament_target_dependencies(laser_proc_nodelet
clalancette marked this conversation as resolved.
Show resolved Hide resolved
class_loader
)

## Node wrapper
add_executable(laser_proc src/laser_proc.cpp)
target_link_libraries(laser_proc laser_proc_ROS ${catkin_LIBRARIES})

#############
## Install ##
#############

## Mark executables and/or libraries for installation
install(TARGETS laser_proc_library laser_publisher laser_transport laser_proc_ROS LaserProcNodelet laser_proc
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
add_executable(laser_proc_node src/laser_proc_node.cpp)
target_include_directories(laser_proc_node
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(laser_proc_node laser_proc_ros)
ament_target_dependencies(laser_proc_node
sensor_msgs
)

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
install(TARGETS laser_proc laser_proc_ros laser_proc_nodelet laser_proc
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(TARGETS laser_proc_node
RUNTIME DESTINATION lib/${PROJECT_NAME}/
)

## Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES nodelets.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(DIRECTORY include/
DESTINATION include
)

#############
## Testing ##
#############
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
ament_export_dependencies(rclcpp)
ament_export_dependencies(sensor_msgs)
ament_export_include_directories(include)
ament_export_libraries(laser_proc laser_proc_ros laser_proc_nodelet)

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
ament_package()
111 changes: 0 additions & 111 deletions include/laser_proc/LaserPublisher.h

This file was deleted.

79 changes: 79 additions & 0 deletions include/laser_proc/laser_proc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2013, 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 copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. 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 FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/*
* Author: Chad Rockey
*/

#ifndef LASER_PROC__LASER_PROC_HPP_
#define LASER_PROC__LASER_PROC_HPP_

#include <algorithm>
#include <limits>
#include <stdexcept>
#include <sstream>
#include <vector>

#include "sensor_msgs/msg/laser_scan.hpp"
#include "sensor_msgs/msg/multi_echo_laser_scan.hpp"
#include "sensor_msgs/msg/laser_echo.hpp"
Karsten1987 marked this conversation as resolved.
Show resolved Hide resolved

namespace laser_proc
{
class LaserProc
{
public:
static sensor_msgs::msg::LaserScan getFirstScan(
const sensor_msgs::msg::MultiEchoLaserScan & msg);

static sensor_msgs::msg::LaserScan getLastScan(
const sensor_msgs::msg::MultiEchoLaserScan & msg);

static sensor_msgs::msg::LaserScan getMostIntenseScan(
const sensor_msgs::msg::MultiEchoLaserScan & msg);

private:
static void fillLaserScan(
const sensor_msgs::msg::MultiEchoLaserScan & msg, sensor_msgs::msg::LaserScan & out);

static size_t getFirstValue(
const sensor_msgs::msg::LaserEcho & ranges, float & range);

static size_t getLastValue(
const sensor_msgs::msg::LaserEcho & ranges, float & range);

static void getMostIntenseValue(
const sensor_msgs::msg::LaserEcho & ranges,
const sensor_msgs::msg::LaserEcho & intensities,
float & range,
float & intensity);
};
} // namespace laser_proc

#endif // LASER_PROC__LASER_PROC_HPP_
Loading