Git Product home page Git Product logo

Comments (9)

jacquelinekay avatar jacquelinekay commented on July 18, 2024

Can you make this a test case in system_tests/test_rclcpp instead? (I meant to post this comment on the pull request in examples, sorry if that was confusing.)

from rclcpp.

jacquelinekay avatar jacquelinekay commented on July 18, 2024

Are you working on a fix for this right now? I will take a look if you're not actively working on it.

from rclcpp.

tfoote avatar tfoote commented on July 18, 2024

@esteve found a workaround to use a lambda function. I'll add a unit test for it too.

from rclcpp.

jacquelinekay avatar jacquelinekay commented on July 18, 2024

You mean using a lambda function in the example? Or to make bound functions work as the input to create_subscription?

None of our tested rclcpp code so far uses std::bind. Any code that captures arguments does so using lambdas.

Playing around with this, I found another "workaround" that compiles:

std::function<void(const std_msgs::msg::String::SharedPtr)> callback = std::bind(&Chatter::chatterCallback, &chatter, std::placeholders::_1);
  auto sub = node->create_subscription<std_msgs::msg::String>(
    "chatter", callback, rmw_qos_profile_default);

Ideally we would support any valid callback signature for create_subscription, so I think we should do the necessary work to make your example compile.

from rclcpp.

esteve avatar esteve commented on July 18, 2024

@tfoote could you have a look at this branch and see if it works? Thanks.

https://github.com/ros2/rclcpp/tree/std_bind_function_traits

from rclcpp.

esteve avatar esteve commented on July 18, 2024

@tfoote I got your example compiling with my branch, I'll clean up the changes here and submit them for review.

from rclcpp.

tfoote avatar tfoote commented on July 18, 2024

@esteve I can confirm that your branch works for me, but I see it's not a cross platform solution unfortunately :-(

from rclcpp.

esteve avatar esteve commented on July 18, 2024

@tfoote I got the workaround to compile on all three platforms in #183, I'll see if I can compile the std::bind test in ros2/system_tests#88

from rclcpp.

tfoote avatar tfoote commented on July 18, 2024

fixed in #183

from rclcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.