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

Chuck Claunch's profile - activity

2023-04-16 04:05:02 -0500 received badge  Great Question (source)
2022-11-21 10:00:15 -0500 received badge  Self-Learner (source)
2022-11-02 10:16:28 -0500 received badge  Guru (source)
2022-11-02 10:16:28 -0500 received badge  Great Answer (source)
2022-09-09 17:42:07 -0500 received badge  Good Question (source)
2022-09-08 01:47:03 -0500 received badge  Nice Question (source)
2022-05-11 10:12:12 -0500 received badge  Enlightened (source)
2022-05-11 10:12:12 -0500 received badge  Good Answer (source)
2022-04-24 21:53:18 -0500 received badge  Nice Question (source)
2022-04-24 21:52:54 -0500 received badge  Notable Question (source)
2022-04-24 21:52:54 -0500 received badge  Popular Question (source)
2022-04-24 21:52:54 -0500 received badge  Famous Question (source)
2022-02-23 16:03:58 -0500 asked a question Setting loglevel for tf2 and/or console_bridge

Setting loglevel for tf2 and/or console_bridge We use tf2 and tf2_ros pretty extensively and would like to suppress or c

2021-09-10 16:36:16 -0500 received badge  Nice Answer (source)
2021-07-19 14:48:43 -0500 received badge  Self-Learner (source)
2021-07-15 16:59:33 -0500 received badge  Famous Question (source)
2021-07-05 23:00:46 -0500 received badge  Famous Question (source)
2021-06-02 07:43:43 -0500 received badge  Notable Question (source)
2021-05-07 06:25:54 -0500 received badge  Favorite Question (source)
2021-05-06 14:29:19 -0500 received badge  Popular Question (source)
2021-05-06 14:24:44 -0500 marked best answer Spinning multiple nodes across multiple threads

I have an application which dynamically spins up multiple nodes and needs to spin them (as they have subscribers). Quick example, stolen from here: https://answers.ros.org/question/3583...

import threading
import rclpy
rclpy.init()
node = rclpy.create_node('simple_node')
# Spin in a separate thread
thread = threading.Thread(target=rclpy.spin, args=(node, ), daemon=True)
thread.start()
rate = node.create_rate(2)
try:
    while rclpy.ok():
        print('Help me body, you are my only hope')
        rate.sleep()
except KeyboardInterrupt:
    pass
rclpy.shutdown()
thread.join()

This example works totally fine and allows the spin to happen in a separate thread (which is what I want because my nodes do other threaded things as well). The issue I get is when i add a second node and attempt to spin it, I get ValueError: generator already executing. See this second example:

import threading
import rclpy
rclpy.init()
node = rclpy.create_node('simple_node')
node2 = rclpy.create_node('simpler_node')
# Spin in a separate thread
thread = threading.Thread(target=rclpy.spin, args=(node, ), daemon=True)
thread2 = threading.Thread(target=rclpy.spin, args=(node2, ), daemon=True)
thread.start()
thread2.start()
rate = node.create_rate(2)
try:
    while rclpy.ok():
        print('Help me body, you are my only hope')
        rate.sleep()
except KeyboardInterrupt:
    pass
rclpy.shutdown()
thread.join()
thread2.join()

This results in an Exception being thrown in the second thread:

Exception in thread Thread-2:
Help me body, you are my only hope
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
    executor.spin_once()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 703, in spin_once
    handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 689, in wait_for_ready_callbacks
    return next(self._cb_iter)
ValueError: generator already executing

I realize there are other methods of composing multiple nodes but as I said, the nodes I'm building do a lot of other things in threads and are spun up dynamically by another process. Is there some method I'm missing to tell rclpy to spin all nodes? It seems the rclpy.spin() method _requires_ the node argument.

edit: Quick addition. The nodes I'm building inherit from rclpy.node.Node and I also attempted to rclpy.spin_once(self) from within those nodes in their main thread (thread that does other things) and I end up at the same ValueError: generator already executing error.

2021-05-06 14:24:44 -0500 received badge  Scholar (source)
2021-05-06 14:24:40 -0500 received badge  Rapid Responder (source)
2021-05-06 14:24:40 -0500 answered a question Spinning multiple nodes across multiple threads

Of course I waited a while to post this after not finding an answer and now I have it. I just needed to use a multi-thr

2021-05-06 11:25:54 -0500 edited question Spinning multiple nodes across multiple threads

Spinning multiple nodes across multiple threads I have an application which dynamically spins up multiple nodes and need

2021-05-06 11:14:41 -0500 asked a question Spinning multiple nodes across multiple threads

Spinning multiple nodes across multiple threads I have an application which dynamically spins up multiple nodes and need

2021-05-04 12:17:55 -0500 received badge  Enthusiast
2021-04-21 10:38:42 -0500 received badge  Notable Question (source)
2021-04-21 09:15:31 -0500 received badge  Rapid Responder (source)
2021-04-21 09:15:31 -0500 answered a question Execute another process on process exit

Interesting finding here, this works if I use OpaqueFunction as my on_exit action. This will for for my needs, but I st

2021-04-21 07:57:42 -0500 commented answer Execute another process on process exit

Something doesn't make sense though with that logic. If the whole program is terminated at the CTRL-C, then how could i

2021-04-21 07:46:24 -0500 received badge  Popular Question (source)
2021-04-20 16:04:01 -0500 asked a question Execute another process on process exit

Execute another process on process exit I am attempting to use ROS2 launch to kick off a non-ROS-node executable (a long

2018-09-27 04:11:26 -0500 received badge  Famous Question (source)
2014-01-28 17:29:39 -0500 marked best answer rosmsg show in C++

Hello, I'd like a way I can recursively iterate all topics/types in C++. Essentially a rosmsg show through all types, down to the basic types. I've seen it done in Python using the function get_topic_class() but I have thoroughly searched and been unable to find a way to do this in C++. Anyone have any ideas? I really don't want to have to hard code all of my message types (we have about thirty custom message types). Thanks!

2014-01-28 17:28:19 -0500 marked best answer rqt cpp plugin won't load

I've been attempting to create a cpp plugin for rqt and am having trouble. I managed to create a base plugin and in trying to get ros messages to the plugin, my callback never gets called. That being said, I decided to go back to the tutorial (tried to post a link to it but failed) and build the complete basic plugin from scratch and just add a subscriber. Upon doing that I cannot get rqt to load the plugin. It shows in the plugins list but is not clickable (suggests I need to build it). I copied the code verbatim from the tutorial (although not positive if the CMakeLists.txt I did is correct or not) and it builds a library file. I'd really like to make the sample tutorial work as I'm not certain how my other plugin is working but the sample isn't. Any ideas or suggestions would be appreciated.

Update: So we found the issue, apparently the rqt_gui cpp architecture is not calling any kind of rosspin() so that's why the callback isn't happening. Does this mean any C++ based rqt plugin will have to handle and thread its own rosspin()?

2013-12-11 05:16:56 -0500 received badge  Taxonomist
2013-05-07 22:41:16 -0500 received badge  Notable Question (source)