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

Switching to example_interfaces #674

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions composition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ find_package(example_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rcutils REQUIRED)
find_package(std_msgs REQUIRED)
find_package(example_interfaces REQUIRED)

include_directories(include)

Expand All @@ -31,7 +31,7 @@ target_compile_definitions(talker_component
ament_target_dependencies(talker_component
"rclcpp"
"rclcpp_components"
"std_msgs")
"example_interfaces")
rclcpp_components_register_nodes(talker_component "composition::Talker")
set(node_plugins "${node_plugins}composition::Talker;$<TARGET_FILE:talker_component>\n")

Expand All @@ -42,7 +42,7 @@ target_compile_definitions(listener_component
ament_target_dependencies(listener_component
"rclcpp"
"rclcpp_components"
"std_msgs")
"example_interfaces")
rclcpp_components_register_nodes(listener_component "composition::Listener")
set(node_plugins "${node_plugins}composition::Listener;$<TARGET_FILE:listener_component>\n")

Expand All @@ -53,7 +53,7 @@ target_compile_definitions(node_like_listener_component
ament_target_dependencies(node_like_listener_component
"rclcpp"
"rclcpp_components"
"std_msgs")
"example_interfaces")
rclcpp_components_register_nodes(node_like_listener_component "composition::NodeLikeListener")
set(node_plugins "${node_plugins}composition::NodeLikeListener;$<TARGET_FILE:node_like_listener_component>\n")

Expand Down
4 changes: 2 additions & 2 deletions composition/include/composition/listener_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

namespace composition
{
Expand All @@ -29,7 +29,7 @@ class Listener : public rclcpp::Node
explicit Listener(const rclcpp::NodeOptions & options);

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

} // namespace composition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

namespace composition
{
Expand All @@ -34,7 +34,7 @@ class NodeLikeListener

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

} // namespace composition
Expand Down
4 changes: 2 additions & 2 deletions composition/include/composition/talker_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

namespace composition
{
Expand All @@ -33,7 +33,7 @@ class Talker : public rclcpp::Node

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

Expand Down
4 changes: 2 additions & 2 deletions composition/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_components</build_depend>
<build_depend>rcutils</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>example_interfaces</build_depend>

<exec_depend>example_interfaces</exec_depend>
<exec_depend>launch_ros</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_components</exec_depend>
<exec_depend>rcutils</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>example_interfaces</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
6 changes: 3 additions & 3 deletions composition/src/listener_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <memory>

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "example_interfaces/msg/string.hpp"

namespace composition
{
Expand All @@ -32,7 +32,7 @@ Listener::Listener(const rclcpp::NodeOptions & options)
// Create a callback function for when messages are received.
// Variations of this function also exist using, for example, UniquePtr for zero-copy transport.
auto callback =
[this](std_msgs::msg::String::ConstSharedPtr msg) -> void
[this](example_interfaces::msg::String::ConstSharedPtr msg) -> void
{
RCLCPP_INFO(this->get_logger(), "I heard: [%s]", msg->data.c_str());
std::flush(std::cout);
Expand All @@ -42,7 +42,7 @@ Listener::Listener(const rclcpp::NodeOptions & options)
// compatible ROS publishers.
// Note that not all publishers on the same topic with the same type will be compatible:
// they must have compatible Quality of Service policies.
sub_ = create_subscription<std_msgs::msg::String>("chatter", 10, callback);
sub_ = create_subscription<example_interfaces::msg::String>("chatter", 10, callback);
}

} // namespace composition
Expand Down
6 changes: 3 additions & 3 deletions composition/src/node_like_listener_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <memory>

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "example_interfaces/msg/string.hpp"

namespace composition
{
Expand All @@ -38,7 +38,7 @@ NodeLikeListener::NodeLikeListener(const rclcpp::NodeOptions & options)
// Create a callback function for when messages are received.
// Variations of this function also exist using, for example, UniquePtr for zero-copy transport.
auto callback =
[this](std_msgs::msg::String::ConstSharedPtr msg) -> void
[this](example_interfaces::msg::String::ConstSharedPtr msg) -> void
{
RCLCPP_INFO(this->node_->get_logger(), "I heard: [%s]", msg->data.c_str());
std::flush(std::cout);
Expand All @@ -48,7 +48,7 @@ NodeLikeListener::NodeLikeListener(const rclcpp::NodeOptions & options)
// compatible ROS publishers.
// Note that not all publishers on the same topic with the same type will be compatible:
// they must have compatible Quality of Service policies.
sub_ = this->node_->create_subscription<std_msgs::msg::String>("chatter", 10, callback);
sub_ = this->node_->create_subscription<example_interfaces::msg::String>("chatter", 10, callback);
}

rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
Expand Down
8 changes: 4 additions & 4 deletions composition/src/talker_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <utility>

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "example_interfaces/msg/string.hpp"

using namespace std::chrono_literals;

Expand All @@ -33,16 +33,16 @@ namespace composition
Talker::Talker(const rclcpp::NodeOptions & options)
: Node("talker", options), count_(0)
{
// Create a publisher of "std_mgs/String" messages on the "chatter" topic.
pub_ = create_publisher<std_msgs::msg::String>("chatter", 10);
// Create a publisher of "example_interfaces/msg/String" messages on the "chatter" topic.
pub_ = create_publisher<example_interfaces::msg::String>("chatter", 10);

// Use a timer to schedule periodic message publishing.
timer_ = create_wall_timer(1s, [this]() {return this->on_timer();});
}

void Talker::on_timer()
{
auto msg = std::make_unique<std_msgs::msg::String>();
auto msg = std::make_unique<example_interfaces::msg::String>();
msg->data = "Hello World: " + std::to_string(++count_);
RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", msg->data.c_str());
std::flush(std::cout);
Expand Down
24 changes: 12 additions & 12 deletions demo_nodes_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ find_package(rclcpp_components REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rcutils REQUIRED)
find_package(rmw REQUIRED)
find_package(std_msgs REQUIRED)
find_package(example_interfaces REQUIRED)

function(custom_executable subfolder target)
cmake_parse_arguments(ARG "" "" "DEPENDENCIES" ${ARGN})
Expand Down Expand Up @@ -50,7 +50,7 @@ target_include_directories(allocator_tutorial PRIVATE
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(allocator_tutorial PRIVATE
rclcpp::rclcpp
${std_msgs_TARGETS}
${example_interfaces_TARGETS}
)
install(TARGETS allocator_tutorial
DESTINATION lib/${PROJECT_NAME})
Expand All @@ -71,10 +71,10 @@ custom_executable(parameters set_and_get_parameters_async
DEPENDENCIES rclcpp::rclcpp)

custom_executable(events matched_event_detect
DEPENDENCIES rclcpp::rclcpp ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp ${example_interfaces_TARGETS})

custom_executable(logging use_logger_service
DEPENDENCIES ${rcl_interfaces_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS})
DEPENDENCIES ${rcl_interfaces_TARGETS} rclcpp::rclcpp ${example_interfaces_TARGETS})

function(create_demo_library plugin executable)
cmake_parse_arguments(ARG "" "" "FILES;DEPENDENCIES" ${ARGN})
Expand Down Expand Up @@ -145,28 +145,28 @@ create_demo_library("demo_nodes_cpp::IntrospectionClientNode" introspection_clie
# Topics
create_demo_library("demo_nodes_cpp::ContentFilteringPublisher" content_filtering_publisher
FILES src/topics/content_filtering_publisher.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::ContentFilteringSubscriber" content_filtering_subscriber
FILES src/topics/content_filtering_subscriber.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component rcpputils::rcpputils ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component rcpputils::rcpputils ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::Talker" talker
FILES src/topics/talker.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::LoanedMessageTalker" talker_loaned_message
FILES src/topics/talker_loaned_message.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::SerializedMessageTalker" talker_serialized_message
FILES src/topics/talker_serialized_message.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::Listener" listener
FILES src/topics/listener.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::SerializedMessageListener" listener_serialized_message
FILES src/topics/listener_serialized_message.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})
create_demo_library("demo_nodes_cpp::ListenerBestEffort" listener_best_effort
FILES src/topics/listener_best_effort.cpp
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
DEPENDENCIES rclcpp::rclcpp rclcpp_components::component ${example_interfaces_TARGETS})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion demo_nodes_cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ ros2 run demo_nodes_cpp set_and_get_parameters_async

### Allocator Tutorial

This runs `allocator_tutorial` ROS 2 node that publishes a `std_msgs/msg/UInt32` message that contains an integer representing the number of allocations and deallocations that happened during the program.
This runs `allocator_tutorial` ROS 2 node that publishes a `example_interfaces/msg/UInt32` message that contains an integer representing the number of allocations and deallocations that happened during the program.

```bash
# Open new terminal
Expand Down
4 changes: 2 additions & 2 deletions demo_nodes_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<build_depend>rcpputils</build_depend>
<build_depend>rcutils</build_depend>
<build_depend>rmw</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>example_interfaces</build_depend>

<exec_depend>example_interfaces</exec_depend>
<exec_depend>launch_ros</exec_depend>
Expand All @@ -37,7 +37,7 @@
<exec_depend>rcpputils</exec_depend>
<exec_depend>rcutils</exec_depend>
<exec_depend>rmw</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>example_interfaces</exec_depend>

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
30 changes: 15 additions & 15 deletions demo_nodes_cpp/src/events/matched_event_detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "rclcpp/rclcpp.hpp"

#include "std_msgs/msg/string.hpp"
#include "example_interfaces/msg/string.hpp"

using namespace std::chrono_literals;

Expand Down Expand Up @@ -60,7 +60,7 @@ class MatchedEventDetectNode : public rclcpp::Node
promise_->set_value(true);
};

pub_ = create_publisher<std_msgs::msg::String>(
pub_ = create_publisher<example_interfaces::msg::String>(
pub_topic_name, 10, pub_options);

rclcpp::SubscriptionOptions sub_options;
Expand All @@ -84,10 +84,10 @@ class MatchedEventDetectNode : public rclcpp::Node
}
promise_->set_value(true);
};
sub_ = create_subscription<std_msgs::msg::String>(
sub_ = create_subscription<example_interfaces::msg::String>(
sub_topic_name,
10,
[](std_msgs::msg::String::ConstSharedPtr) {},
[](example_interfaces::msg::String::ConstSharedPtr) {},
sub_options);
}

Expand All @@ -98,8 +98,8 @@ class MatchedEventDetectNode : public rclcpp::Node
}

private:
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr sub_;
rclcpp::Publisher<example_interfaces::msg::String>::SharedPtr pub_;
rclcpp::Subscription<example_interfaces::msg::String>::SharedPtr sub_;
bool any_subscription_connected_{false};
bool any_publisher_connected_{false};
std::shared_ptr<std::promise<bool>> promise_;
Expand All @@ -113,19 +113,19 @@ class MultiSubNode : public rclcpp::Node
topic_name_(topic_name)
{}

rclcpp::Subscription<std_msgs::msg::String>::WeakPtr create_one_sub(void)
rclcpp::Subscription<example_interfaces::msg::String>::WeakPtr create_one_sub(void)
{
RCLCPP_INFO(this->get_logger(), "Create a new subscription.");
auto sub = create_subscription<std_msgs::msg::String>(
auto sub = create_subscription<example_interfaces::msg::String>(
topic_name_,
10,
[](std_msgs::msg::String::ConstSharedPtr) {});
[](example_interfaces::msg::String::ConstSharedPtr) {});

subs_.emplace_back(sub);
return sub;
}

void destroy_one_sub(rclcpp::Subscription<std_msgs::msg::String>::WeakPtr sub)
void destroy_one_sub(rclcpp::Subscription<example_interfaces::msg::String>::WeakPtr sub)
{
auto sub_shared_ptr = sub.lock();
if (sub_shared_ptr == nullptr) {
Expand All @@ -143,7 +143,7 @@ class MultiSubNode : public rclcpp::Node

private:
std::string topic_name_;
std::vector<rclcpp::Subscription<std_msgs::msg::String>::SharedPtr> subs_;
std::vector<rclcpp::Subscription<example_interfaces::msg::String>::SharedPtr> subs_;
};

class MultiPubNode : public rclcpp::Node
Expand All @@ -154,16 +154,16 @@ class MultiPubNode : public rclcpp::Node
topic_name_(topic_name)
{}

rclcpp::Publisher<std_msgs::msg::String>::WeakPtr create_one_pub(void)
rclcpp::Publisher<example_interfaces::msg::String>::WeakPtr create_one_pub(void)
{
RCLCPP_INFO(this->get_logger(), "Create a new publisher.");
auto pub = create_publisher<std_msgs::msg::String>(topic_name_, 10);
auto pub = create_publisher<example_interfaces::msg::String>(topic_name_, 10);
pubs_.emplace_back(pub);

return pub;
}

void destroy_one_pub(rclcpp::Publisher<std_msgs::msg::String>::WeakPtr pub)
void destroy_one_pub(rclcpp::Publisher<example_interfaces::msg::String>::WeakPtr pub)
{
auto pub_shared_ptr = pub.lock();
if (pub_shared_ptr == nullptr) {
Expand All @@ -181,7 +181,7 @@ class MultiPubNode : public rclcpp::Node

private:
std::string topic_name_;
std::vector<rclcpp::Publisher<std_msgs::msg::String>::SharedPtr> pubs_;
std::vector<rclcpp::Publisher<example_interfaces::msg::String>::SharedPtr> pubs_;
};

int main(int argc, char ** argv)
Expand Down
Loading