When I follow the course syntax, I encounter some compilation warnings about deprecated syntax as follows: (NOTE: these are warnings, the examples still “work” functionally).
Publisher warning:
Starting >>> topic_subscriber_pkg
--- stderr: topic_publisher_pkg
/home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp: In constructor 'SimplePublisher::SimplePublisher()':
/home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp:13:77: warning: 'std::shared_ptr<PublisherT> rclcpp::Node::create_publisher
(const string&, const rmw_qos_profile_t&, std::shared_ptr<_Up>) [with MessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; AllocatorT =
std::allocator<void>; PublisherT = rclcpp::Publisher<geometry_msgs::msg::Twist_<std::allocator<void> > >; std::__cxx11::string = std::__cxx11::
basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_t]' is deprecated: use create_publisher(const std::string &, const rclcpp::QoS &, ...) i
nstead [-Wdeprecated-declarations]
publisher_ = this->create_publisher<geometry_msgs::msg::Twist>("cmd_vel");
^
In file included from /opt/ros/dashing/include/rclcpp/node.hpp:1206:0,
from /opt/ros/dashing/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/dashing/include/rclcpp/executors.hpp:22,
from /opt/ros/dashing/include/rclcpp/rclcpp.hpp:144,
from /home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp:2:
/opt/ros/dashing/include/rclcpp/node_impl.hpp:96:1: note: declared here
Node::create_publisher(
^~~~
/home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp: In member function 'void SimplePublisher::timer_callback()':
/home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp:23:32: warning: 'void rclcpp::Publisher<MessageT, Alloc>::publish(const std::shared_ptr<const _Tp>&) [with MessageT = geometry_msgs::msg::Twist_<std::allocator<void> >; Alloc = std::allocator<void>]' is deprecated: publishing an unique_ptr is prefered when using intra process communication. If using a shared_ptr, use publish(*msg). [-Wdeprecated-declarations]
publisher_->publish(message);
^
In file included from /opt/ros/dashing/include/rclcpp/callback_group.hpp:24:0,
from /opt/ros/dashing/include/rclcpp/any_executable.hpp:20,
from /opt/ros/dashing/include/rclcpp/memory_strategy.hpp:24,
from /opt/ros/dashing/include/rclcpp/memory_strategies.hpp:18,
from /opt/ros/dashing/include/rclcpp/executor.hpp:33,
from /opt/ros/dashing/include/rclcpp/executors/multi_threaded_executor.hpp:24,
from /opt/ros/dashing/include/rclcpp/executors.hpp:21,
from /opt/ros/dashing/include/rclcpp/rclcpp.hpp:144,
from /home/user/ros2_ws/src/topic_publisher_pkg/src/cmd_vel_publisher.cpp:2:
/opt/ros/dashing/include/rclcpp/publisher.hpp:137:3: note: declared here
publish(const std::shared_ptr<const MessageT> & msg)
^~~~~~~
Subscriber warning:
--- stderr: topic_subscriber_pkg
/home/user/ros2_ws/src/topic_subscriber_pkg/src/simple_topic_subscriber.cpp: In function 'int main(int, char**)':
/home/user/ros2_ws/src/topic_subscriber_pkg/src/simple_topic_subscriber.cpp:14:32: warning: 'std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, CallbackT&&, const rmw_qos_profile_t&, rclcpp::callback_group::CallbackGroup::SharedPtr, bool, typename rclcpp::message_memory_strategy::MessageMemoryStrategy<typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, AllocatorT>::SharedPtr, std::shared_ptr<PublisherT>) [with MessageT = std_msgs::msg::Int32_<std::allocator<void> >; CallbackT = void (&)(std::shared_ptr<std_msgs::msg::Int32_<std::allocator<void> > >); Alloc = std::allocator<void>; SubscriptionT = rclcpp::Subscription<std_msgs::msg::Int32_<std::allocator<void> >,std::allocator<void> >; std::__cxx11::string = std::__cxx11::basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_t; rclcpp::callback_group::CallbackGroup::SharedPtr = std::shared_ptr<rclcpp::callback_group::CallbackGroup>; typename rclcpp::message_memory_strategy::MessageMemoryStrategy<typename rclcpp::subscription_traits::has_message_type<CallbackT>::type, AllocatorT>::SharedPtr = std::shared_ptr<rclcpp::message_memory_strategy::MessageMemoryStrategy<std_msgs::msg::Int32_<std::allocator<void> >, std::allocator<void> > >]' is deprecated: use create_subscription(const std::string &, const rclcpp::QoS &, CallbackT, ...) instead [-Wdeprecated-declarations]
"counter", topic_callback);
^
In file included from /opt/ros/dashing/include/rclcpp/node.hpp:1206:0,
from /opt/ros/dashing/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/dashing/include/rclcpp/executors.hpp:22,
from /opt/ros/dashing/include/rclcpp/rclcpp.hpp:144,
from /home/user/ros2_ws/src/topic_subscriber_pkg/src/simple_topic_subscriber.cpp:1:
/opt/ros/dashing/include/rclcpp/node_impl.hpp:139:1: note: declared here
Node::create_subscription(
^~~~
Is there a more updated syntax we should be using?