Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion ros2component/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_xmllint</test_depend>
<test_depend>composition</test_depend>
<test_depend>python3-pytest</test_depend>
<test_depend>ros2component_fixtures</test_depend>
<test_depend>ros_testing</test_depend>

<export>
Expand Down
6 changes: 3 additions & 3 deletions ros2component/test/test_cli_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def generate_test_description(rmw_implementation, ready_fn):
package='rclcpp_components', node_executable='component_container', output='screen')
listener_command_action = ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Listener'],
'ros2component_fixtures', 'ros2component_fixtures::Listener'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand All @@ -61,7 +61,7 @@ def generate_test_description(rmw_implementation, ready_fn):
on_exit=[
ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Talker'],
'ros2component_fixtures', 'ros2component_fixtures::Talker'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand All @@ -71,7 +71,7 @@ def generate_test_description(rmw_implementation, ready_fn):
on_exit=[
ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Talker'],
'ros2component_fixtures', 'ros2component_fixtures::Talker'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand Down
12 changes: 7 additions & 5 deletions ros2component/test/test_cli_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_load_verb(self):
with self.launch_node_command(
arguments=[
'load', '/ComponentManager',
'composition', 'composition::Talker']) as talker_node:
'ros2component_fixtures', 'ros2component_fixtures::Talker']) as talker_node:
assert talker_node.wait_for_shutdown(timeout=20)
assert talker_node.exit_code == launch_testing.asserts.EXIT_OK
assert launch_testing.tools.expect_output(
Expand All @@ -112,7 +112,8 @@ def test_load_verb(self):
with self.launch_node_command(
arguments=[
'load', '/ComponentManager',
'composition', 'composition::Listener']) as listener_node:
'ros2component_fixtures',
'ros2component_fixtures::Listener']) as listener_node:
assert listener_node.wait_for_shutdown(timeout=20)
assert listener_node.exit_code == launch_testing.asserts.EXIT_OK
assert launch_testing.tools.expect_output(
Expand All @@ -136,7 +137,7 @@ def test_load_verb(self):
with self.launch_node_command(
arguments=[
'load', '/ComponentManager',
'composition', 'composition::Talker']) as talker_node:
'ros2component_fixtures', 'ros2component_fixtures::Talker']) as talker_node:
assert talker_node.wait_for_shutdown(timeout=20)
assert talker_node.exit_code == launch_testing.asserts.EXIT_OK
assert launch_testing.tools.expect_output(
Expand All @@ -150,7 +151,7 @@ def test_load_verb(self):
with self.launch_node_command(
arguments=[
'load', '/ComponentManager',
'composition', 'composition::Talker']) as talker_node:
'ros2component_fixtures', 'ros2component_fixtures::Talker']) as talker_node:
assert talker_node.wait_for_shutdown(timeout=20)
assert talker_node.exit_code == launch_testing.asserts.EXIT_OK
assert launch_testing.tools.expect_output(
Expand All @@ -166,7 +167,8 @@ def test_load_verb_nonexistent_class(self):
with self.launch_node_command(
arguments=[
'load', '/ComponentManager',
'composition', 'composition::NonExistingPlugin']) as command:
'ros2component_fixtures',
'ros2component_fixtures::NonExistingPlugin']) as command:
assert command.wait_for_shutdown(timeout=20)
assert command.exit_code == 1
assert launch_testing.tools.expect_output(
Expand Down
9 changes: 3 additions & 6 deletions ros2component/test/test_cli_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@
from rmw_implementation import get_available_rmw_implementations

DEMO_NODES_TYPES = """\
composition
composition::Talker
composition::Listener
composition::NodeLikeListener
composition::Server
composition::Client
ros2component_fixtures
ros2component_fixtures::Talker
ros2component_fixtures::Listener
"""


Expand Down
6 changes: 3 additions & 3 deletions ros2component/test/test_cli_unload.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def generate_test_description(rmw_implementation, ready_fn):
package='rclcpp_components', node_executable='component_container', output='screen')
listener_command_action = ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Listener'],
'ros2component_fixtures', 'ros2component_fixtures::Listener'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand All @@ -59,7 +59,7 @@ def generate_test_description(rmw_implementation, ready_fn):
on_exit=[
ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Talker'],
'ros2component_fixtures', 'ros2component_fixtures::Talker'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand All @@ -69,7 +69,7 @@ def generate_test_description(rmw_implementation, ready_fn):
on_exit=[
ExecuteProcess(
cmd=['ros2', 'component', 'load', '/ComponentManager',
'composition', 'composition::Talker'],
'ros2component_fixtures', 'ros2component_fixtures::Talker'],
additional_env={
'RMW_IMPLEMENTATION': rmw_implementation,
'PYTHONUNBUFFERED': '1'
Expand Down
60 changes: 60 additions & 0 deletions ros2component_fixtures/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
cmake_minimum_required(VERSION 3.5)

project(ros2component_fixtures)

# 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(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)

include_directories(include)

# create ament index resource which references the libraries in the binary dir
set(node_plugins "")

add_library(talker_component SHARED
src/talker_component.cpp)
target_compile_definitions(talker_component
PRIVATE "ROS2COMPONENT_FIXTURES_BUILDING_DLL")
ament_target_dependencies(talker_component
"rclcpp"
"rclcpp_components"
"std_msgs")
rclcpp_components_register_nodes(talker_component "ros2component_fixtures::Talker")
set(node_plugins "${node_plugins}ros2component_fixtures::Talker;$<TARGET_FILE:talker_component>\n")

add_library(listener_component SHARED
src/listener_component.cpp)
target_compile_definitions(listener_component
PRIVATE "ROS2COMPONENT_FIXTURES_BUILDING_DLL")
ament_target_dependencies(listener_component
"rclcpp"
"rclcpp_components"
"std_msgs")
rclcpp_components_register_nodes(listener_component "ros2component_fixtures::Listener")
set(node_plugins "${node_plugins}ros2component_fixtures::Listener;$<TARGET_FILE:listener_component>\n")

# since the package installs libraries without exporting them
# it needs to make sure that the library path is being exported
if(NOT WIN32)
ament_environment_hooks(
"${ament_cmake_package_templates_ENVIRONMENT_HOOK_LIBRARY_PATH}")
endif()

install(TARGETS
talker_component
listener_component
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2019 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.

#ifndef ROS2COMPONENT_FIXTURES__LISTENER_COMPONENT_HPP_
#define ROS2COMPONENT_FIXTURES__LISTENER_COMPONENT_HPP_

#include "ros2component_fixtures/visibility_control.h"
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

namespace ros2component_fixtures
{

class Listener : public rclcpp::Node
{
public:
ROS2COMPONENT_FIXTURES_PUBLIC
explicit Listener(const rclcpp::NodeOptions & options);

private:
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
};

} // namespace ros2component_fixtures

#endif // ROS2COMPONENT_FIXTURES__LISTENER_COMPONENT_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2019 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.

#ifndef ROS2COMPONENT_FIXTURES__TALKER_COMPONENT_HPP_
#define ROS2COMPONENT_FIXTURES__TALKER_COMPONENT_HPP_

#include "ros2component_fixtures/visibility_control.h"
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

namespace ros2component_fixtures
{

class Talker : public rclcpp::Node
{
public:
ROS2COMPONENT_FIXTURES_PUBLIC
explicit Talker(const rclcpp::NodeOptions & options);

protected:
void on_timer();

private:
size_t count_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
rclcpp::TimerBase::SharedPtr timer_;
};

} // namespace ros2component_fixtures

#endif // ROS2COMPONENT_FIXTURES__TALKER_COMPONENT_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2019 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.

#ifndef ROS2COMPONENT_FIXTURES__VISIBILITY_CONTROL_H_
#define ROS2COMPONENT_FIXTURES__VISIBILITY_CONTROL_H_

#ifdef __cplusplus
extern "C"
{
#endif

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define ROS2COMPONENT_FIXTURES_EXPORT __attribute__ ((dllexport))
#define ROS2COMPONENT_FIXTURES_IMPORT __attribute__ ((dllimport))
#else
#define ROS2COMPONENT_FIXTURES_EXPORT __declspec(dllexport)
#define ROS2COMPONENT_FIXTURES_IMPORT __declspec(dllimport)
#endif
#ifdef ROS2COMPONENT_FIXTURES_BUILDING_DLL
#define ROS2COMPONENT_FIXTURES_PUBLIC ROS2COMPONENT_FIXTURES_EXPORT
#else
#define ROS2COMPONENT_FIXTURES_PUBLIC ROS2COMPONENT_FIXTURES_IMPORT
#endif
#define ROS2COMPONENT_FIXTURES_PUBLIC_TYPE ROS2COMPONENT_FIXTURES_PUBLIC
#define ROS2COMPONENT_FIXTURES_LOCAL
#else
#define ROS2COMPONENT_FIXTURES_EXPORT __attribute__ ((visibility("default")))
#define ROS2COMPONENT_FIXTURES_IMPORT
#if __GNUC__ >= 4
#define ROS2COMPONENT_FIXTURES_PUBLIC __attribute__ ((visibility("default")))
#define ROS2COMPONENT_FIXTURES_LOCAL __attribute__ ((visibility("hidden")))
#else
#define ROS2COMPONENT_FIXTURES_PUBLIC
#define ROS2COMPONENT_FIXTURES_LOCAL
#endif
#define ROS2COMPONENT_FIXTURES_PUBLIC_TYPE
#endif

#ifdef __cplusplus
}
#endif

#endif // ROS2COMPONENT_FIXTURES__VISIBILITY_CONTROL_H_
27 changes: 27 additions & 0 deletions ros2component_fixtures/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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>ros2component_fixtures</name>
<version>0.1.0</version>
<description>Examples for ros2component cli</description>
<maintainer email="[email protected]">Dirk Thomas</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_components</build_depend>
<build_depend>std_msgs</build_depend>

<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_components</exec_depend>
<exec_depend>std_msgs</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading