"template argument deduction/substitution failed:" error on using rclcpp::Node::create_wall_timer function
Hi,
When using the rclcpp::Node::create_wall_timer function with std::bind , I am getting the following error
no matching function for call to ‘composition::Talker::create_wall_timer(std::chrono::seconds, std::_Bind_helper<false, void="" (composition::talker::*)(int),="" composition::talker*,="" int="">::type)’
The error can be reproducer if one changes std::bind function inside the create_wall_timer () to add extra arguments to the function pointer.
I am attaching the code for your kind reference.
#include "composition/talker_component.hpp"
#include <chrono>
#include <iostream>
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
using namespace std::chrono_literals;
namespace composition
{
Talker::Talker()
: Node("talker"), count_(0)
{
// Create a publisher of "std_mgs/String" messages on the "chatter" topic.
pubbase_= this->create_publisher<std_msgs::msg::String>("chatter");
pub_ = create_publisher<std_msgs::msg::String>("chatter");
timer_ = create_wall_timer(1s, std::bind(&Talker::on_timer, this,95));
}
void Talker::on_timer(int level)
{
auto msg = std::make_shared<std_msgs::msg::String>();
msg->data = "Hello World: " + std::to_string(++count_);
// Put the message into a queue to be processed by the middleware.
// This call is non-blocking.
pub_->publish(msg);
}
@Skyking please don't use the backtick formatting for code blocks. This is for single code Statements.
Just Highlight the copy-pasted code block and click the preformatted text button (the one with 10101010) on it. Thanks.
Thanks @mig