switch to threading

This commit is contained in:
Sem van der Hoeven
2023-05-22 12:10:29 +02:00
parent 18546545a4
commit 2ee2536007

View File

@@ -3,13 +3,15 @@ from rclpy.node import Node
import asyncio
import websockets.server
import threading
class ApiListener(Node):
def __init__(self):
super().__init__('api_listener')
self.get_logger().info('ApiListener node started')
self.api_coro = asyncio.to_thread(self.run_api)
self.server_task = asyncio.create_task(self.api_coro)
self.angle = 30
server_thread = threading.Thread(target=self.run_api)
server_thread.start()
async def run_api(self):
self.get_logger().info('Starting API')