add manual spin
This commit is contained in:
@@ -22,6 +22,10 @@ class ApiListener(Node):
|
||||
self.last_battery_percentage = msg.battery_percentage
|
||||
self.last_cpu_usage = msg.cpu_usage
|
||||
|
||||
def spin(self):
|
||||
while rclpy.ok():
|
||||
rclpy.spin_once(self,timeout_sec=0.1)
|
||||
|
||||
async def handle_api(self):
|
||||
self.get_logger().info('Starting API')
|
||||
self.server = await websockets.serve(self.api_handler, '0.0.0.0', 9001)
|
||||
@@ -46,7 +50,7 @@ async def main(args=None):
|
||||
|
||||
# start the websockets api in its own task wrapper
|
||||
asyncio.ensure_future(api_listener.handle_api())
|
||||
rclpy.spin(api_listener)
|
||||
api_listener.spin()
|
||||
|
||||
api_listener.destroy_node()
|
||||
rclpy.shutdown()
|
||||
|
||||
Reference in New Issue
Block a user