Skip to content

Commit

Permalink
Make Interbotix executor multithreaded
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeschmitt-tr committed Jun 26, 2024
1 parent 4f4f21a commit 150e42b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from interbotix_common_modules.common_robot.exceptions import InterbotixException
import rclpy
from rclpy.duration import Duration
from rclpy.executors import MultiThreadedExecutor
from rclpy.node import Node
from rclpy.task import Future

Expand Down Expand Up @@ -96,7 +97,13 @@ def __start(node: InterbotixRobotNode, daemon: bool = True) -> None:
raise InterbotixException('Startup has already been requested.')
__interbotix_is_up = True
global __interbotix_execution_thread
__interbotix_execution_thread = Thread(target=rclpy.spin, args=(node,), daemon=daemon)
global __interbotix_executor
__interbotix_executor = MultiThreadedExecutor()
def spin(node: InterbotixRobotNode) -> None:
while rclpy.ok():
__interbotix_executor.add_node(node=node)
__interbotix_executor.spin()
__interbotix_execution_thread = Thread(target=spin, args=(node,), daemon=daemon)
__interbotix_execution_thread.start()


Expand Down

0 comments on commit 150e42b

Please sign in to comment.