Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for AsyncSpinner #335

Closed
Karsten1987 opened this issue Jun 5, 2017 · 4 comments
Closed

support for AsyncSpinner #335

Karsten1987 opened this issue Jun 5, 2017 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@Karsten1987
Copy link
Contributor

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);
@Karsten1987 Karsten1987 added the question Further information is requested label Jun 5, 2017
@Karsten1987 Karsten1987 self-assigned this Jun 5, 2017
@wjwwood
Copy link
Member

wjwwood commented Jun 5, 2017

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));

@Karsten1987
Copy link
Contributor Author

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

@itfanr
Copy link

itfanr commented Jun 26, 2019

For ros2 dashing:

    using rclcpp::executors::MultiThreadedExecutor;
    MultiThreadedExecutor executor;
    executor.add_node(xxx_node);

@pankhurivanjani
Copy link

pankhurivanjani commented Jul 21, 2019

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.

DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this issue Aug 5, 2022
* serialize and deserialize QoS in metadata

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants