Skip to content

support for AsyncSpinner #335

Closed
Closed

Description

@Karsten1987

As we currently don't have the ROS2 equivalent for the AsyncSpinner, I helped myself out by excluding the executor::spin() function and running this in a separate thread.
Is that the recommended way and how such an asyncspinner could look like in the ROS2 world?

void
spin(rclcpp::executors::multi_threaded_executor::MultiThreadedExecutor * exe)
{
    exe->spin();
}

// main

rclcpp::executors::multi_threaded_executor::MultiThreadedExecutor executor;
auto future_handle = std::async(std::launch::async, spin, &executor);

Activity

  1. added
    question
    on Jun 5, 2017
  2. self-assigned this
    on Jun 5, 2017
  3. wjwwood commented on Jun 5, 2017

    @wjwwood
    Member

    This was already asked in the forum (at least I think it is a duplicate):

    https://discourse.ros.org/t/async-executor-in-ros2/1575

    I'd recommend what I put in the discourse thread or this:

    using rclcpp::executors::multi_threaded_executor::MultiThreadedExecutor;
    MultiThreadedExecutor executor;
    // executor.add_node(...);
    std::thread executor_thread(std::bind(&MultiThreadedExecutor::spin, &executor));
  4. Karsten1987 commented on Jun 5, 2017

    @Karsten1987
    ContributorAuthor

    great. thanks for the link. I didn't see that.

  5. itfanr commented on Jun 26, 2019

    @itfanr

    For ros2 dashing:

        using rclcpp::executors::MultiThreadedExecutor;
        MultiThreadedExecutor executor;
        executor.add_node(xxx_node);
    
  6. pankhurivanjani commented on Jul 21, 2019

    @pankhurivanjani

    Hello @itfanr !
    I am having issues in implementing it in ROS dashing.

    With ROS1 I was using start and stop. What to do in this case?

    Also if I have:

    lc2->start();
    std::cout << "hi";
     std::cout << "hey"; 
    

    where start:

    void start(){
     RCLCPP_INFO(this->get_logger(), "starting");
    this->executor->spin();
    }
    

    My code is not printing "hi" and "hey". It is not moving to further lines wheras with ROS since I used asyncspinner I had no problem.

  7. added a commit that references this issue on Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions