-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is Work-in-Progress to integrate ROS2 code into the existing ROS1 code and make them buildable with both CMake and Colcon. The imported code is from [1] and will be removed. [1] https://github.com/ros2/examples/tree/eloquent/rclcpp/minimal_publisher Signed-off-by: Wook Song <[email protected]>
- Loading branch information
Showing
15 changed files
with
220 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ADD_SUBDIRECTORY(tensor_ros_sink) | ||
ADD_SUBDIRECTORY(tensor_ros_src) | ||
IF(WITH_ROS1) | ||
ADD_SUBDIRECTORY(tensor_ros_sink) | ||
ADD_SUBDIRECTORY(tensor_ros_src) | ||
ENDIF(WITH_ROS1) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<package format="2"> | ||
<name>nns_ros_bridge</name> | ||
<version>0.0.1</version> | ||
<description>A bridge for ROS support within NNStreamer</description> | ||
<maintainer email="[email protected]">Wook Song</maintainer> | ||
<author email="[email protected]">Wook Song</author> | ||
|
||
<license>LGPLv2.1</license> | ||
<buildtool_depend>catkin</buildtool_depend> | ||
<build_depend>roscpp</build_depend> | ||
<build_depend>rosbag</build_depend> | ||
<build_depend>std_msgs</build_depend> | ||
<build_depend>message_generation</build_depend> | ||
<build_export_depend>roscpp</build_export_depend> | ||
<build_export_depend>std_msgs</build_export_depend> | ||
<exec_depend>roscpp</exec_depend> | ||
<exec_depend>rosbag</exec_depend> | ||
<exec_depend>std_msgs</exec_depend> | ||
<exec_depend>message_runtime</exec_depend> | ||
|
||
<export> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PROJECT(nns_ros2_bridge C CXX) | ||
|
||
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
ENDIF() | ||
|
||
FIND_PROGRAM(PYTHON_EXECUTABLE python3 DOC "python interpreter") | ||
IF(PYTHON_EXECUTABLE) | ||
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import platform; ver = platform.python_version_tuple(); print(ver[0] + '.' + ver[1])" | ||
OUTPUT_VARIABLE PYTHON_VER | ||
RESULT_VARIABLE PYTHON_VER_NOT_FOUND | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
ENDIF(PYTHON_EXECUTABLE) | ||
|
||
IF(PYTHON_VER_NOT_FOUND) | ||
MESSAGE(FATAL_ERROR "Failed to find python3 required by ament_cmake") | ||
ENDIF(PYTHON_VER_NOT_FOUND) | ||
|
||
IF(EXISTS ${CMAKE_PREFIX_PATH}/lib/python${PYTHON_VER}/site-packages) | ||
LIST(APPEND PYTHONPATH_CANDIDATES "${CMAKE_PREFIX_PATH}/lib/python${PYTHON_VER}") | ||
ENDIF(EXISTS ${CMAKE_PREFIX_PATH}/lib/python${PYTHON_VER}/site-packages) | ||
|
||
IF(EXISTS ${CMAKE_PREFIX_PATH}/lib/python3/site-packages) | ||
LIST(APPEND PYTHONPATH_CANDIDATES "${CMAKE_PREFIX_PATH}/lib/python3") | ||
ENDIF(EXISTS ${CMAKE_PREFIX_PATH}/lib/python3/site-packages) | ||
|
||
LIST(LENGTH PYTHONPATH_CANDIDATES LEN_PYTHONPATH_CANDIDATES) | ||
IF(${LEN_PYTHONPATH_CANDIDATES} LESS "1") | ||
MESSAGE(FATAL_ERROR "Failed to find python3-related path in ${CMAKE_PREFIX_PATH}/lib") | ||
ENDIF(${LEN_PYTHONPATH_CANDIDATES} LESS "1") | ||
|
||
FOREACH(pythonpath ${PYTHONPATH_CANDIDATES}) | ||
SET(ENV{PYTHONPATH} ${pythonpath}/site-packages:$ENV{PYTHONPATH}) | ||
ENDFOREACH() | ||
|
||
# find dependencies | ||
FIND_PACKAGE(ament_cmake REQUIRED) | ||
FIND_PACKAGE(rclcpp REQUIRED) | ||
FIND_PACKAGE(std_msgs REQUIRED) | ||
|
||
ADD_EXECUTABLE(publisher_member_function node/member_function.cpp) | ||
AMENT_TARGET_DEPENDENCIES(publisher_member_function rclcpp std_msgs) | ||
|
||
INSTALL(TARGETS | ||
publisher_member_function | ||
RUNTIME DESTINATION ${ROS_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${ROS_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${ROS_INSTALL_LIBDIR} | ||
) | ||
|
||
IF(BUILD_TESTING) | ||
FIND_PACKAGE(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# uncomment the line when a copyright and license is not present in all source files | ||
#set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# uncomment the line when this package is not in a git repo | ||
#set(ament_cmake_cpplint_FOUND TRUE) | ||
AMENT_LINT_AUTO_FIND_TEST_DEPENDENCIES() | ||
ENDIF() | ||
|
||
AMENT_PACKAGE() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2016 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <chrono> | ||
#include <memory> | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "std_msgs/msg/string.hpp" | ||
|
||
using namespace std::chrono_literals; | ||
|
||
/* This example creates a subclass of Node and uses std::bind() to register a | ||
* member function as a callback from the timer. */ | ||
|
||
class MinimalPublisher : public rclcpp::Node | ||
{ | ||
public: | ||
MinimalPublisher() | ||
: Node("minimal_publisher"), count_(0) | ||
{ | ||
publisher_ = this->create_publisher<std_msgs::msg::String>("topic", 10); | ||
timer_ = this->create_wall_timer( | ||
500ms, std::bind(&MinimalPublisher::timer_callback, this)); | ||
} | ||
|
||
private: | ||
void timer_callback() | ||
{ | ||
auto message = std_msgs::msg::String(); | ||
message.data = "Hello, world! " + std::to_string(count_++); | ||
RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.data.c_str()); | ||
publisher_->publish(message); | ||
} | ||
rclcpp::TimerBase::SharedPtr timer_; | ||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_; | ||
size_t count_; | ||
}; | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
rclcpp::init(argc, argv); | ||
rclcpp::spin(std::make_shared<MinimalPublisher>()); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>nns_ros2_bridge</name> | ||
<version>0.0.1</version> | ||
<description>A bridge for ROS2 support within NNStreamer</description> | ||
<maintainer email="[email protected]">wook</maintainer> | ||
<author>Wook Song</author> | ||
<license>LGPLv2.1</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<build_depend>rclcpp</build_depend> | ||
<build_depend>std_msgs</build_depend> | ||
|
||
<exec_depend>rclcpp</exec_depend> | ||
<exec_depend>std_msgs</exec_depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ADD_SUBDIRECTORY(tensor_ros_sink) | ||
ADD_SUBDIRECTORY(tensor_ros_src) | ||
IF(WITH_ROS1) | ||
ADD_SUBDIRECTORY(tensor_ros_sink) | ||
ADD_SUBDIRECTORY(tensor_ros_src) | ||
ENDIF(WITH_ROS1) |