ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error occurs when trying to build in eloquent

asked 2021-04-12 11:22:45 -0500

fnax8902 gravatar image

Hello, I recently tried to update my ROS2 version from dashing to eloquent. I do have a good number of publishers and all are building without any problem. But one of them gives me an error which I cannot resolve. Can anyone give me a clue on what the problem could be?

error: no matching function for call to 'rclcpp::Publisher<common::msg::Stanag4586Wrapper_<std::allocator<void> > >::publish(std::shared_ptr<common::msg::Stanag4586Wrapper_<std::allocator<void> > >&)'

I am building with colcon build. Thank you.

edit retag flag offensive close merge delete

Comments

It would be helpful if you supply the code where you try to call publish and where you create the publisher (ideally an MWE, as well as the full error message instead of just a single line of it. Without that context it's very difficult to get a clue

sgvandijk gravatar image sgvandijk  ( 2021-04-12 11:33:26 -0500 )edit

In Header-file: rclcpp::Publisher<common::msg::Stanag4586Wrapper>::SharedPtr pub_stanag_u2g_;

void U2gLink::init_publisher()
{
  pub_stanag_u2g_ = this->create_publisher<common::msg::Stanag4586Wrapper>("/stanag/u2g", 10);
}

void U2gLink::some_void()
{
    auto msg = std::make_shared<common::msg::Stanag4586Wrapper>();
    pub_stanag_u2g_->publish(msg);
}
fnax8902 gravatar image fnax8902  ( 2021-04-12 13:02:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-12 15:41:43 -0500

https://docs.ros2.org/eloquent/api/rc...

As the docs show, you can either publish a message or a unique pointer to a message, but not a shared pointer.

edit flag offensive delete link more

Comments

Okay, and I guess in ROS2 Dashing shared pointers were accepted as well, right?

fnax8902 gravatar image fnax8902  ( 2021-04-12 16:10:51 -0500 )edit

Correct. If this answers your question can you mark this answer as correct to remove from unanswered questions queue?

stevemacenski gravatar image stevemacenski  ( 2021-04-12 21:10:32 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-04-12 11:22:45 -0500

Seen: 73 times

Last updated: Apr 12 '21