전체 글258 Ros2 비동기적으로 spin( ) subscription 2개 publisher 2개 비동기로 ros spin 돌리는 방법 2개 1. Thread 2. couroutine // asyncio 구조 Ros2Handler -> ThreadAgent Ros2Handler -> AsyncAgent 추가 설명 Thread 같은경우엔 rclpy 에서 제공하는 Excutor Class 를 이용하면 되지만, Asyncio 로 돌리고 싶어도 spin 함수에 들어가면 실행권을 가져올 수 가 없다. spin_once 로 while 문돌려서 실행권을 계속해서 넘기면서 해야 가능함 import asyncio from std_msgs.msg import String import threading import rclpy from rclpy.executors imp.. 2022. 9. 15. spin_until_future_complete 예제 https://github.com/ros2/rclpy/issues/585 `MultiThreadedExecutor:spin_until_future_complete` can block when the future is ready · Issue #585 · ros2/rclpy Bug report Required Info: Operating System: Ubuntu 20.04 Installation type: From source Version or commit hash: Foxy DDS implementation: Fast-RTPS Client library (if applicable): rclpy Steps to rep... github.com 참고 callback 함수를 future 객체 ( 비동기 ).. 2022. 9. 15. SOLID의 단일 책임 원칙 참고 : https://yoongrammer.tistory.com/96 단일 책임 원칙 (SRP: Single Responsibility Principle) 목차 단일 책임 원칙 (SRP: Single Responsibility Principle) 클래스를 변경하는 이유는 단 한 가지여야 한다. 로버트 C. 마틴 단일 책임 원칙(SRP: Single Responsibility Principle)은 다섯 가지 SOLID 애자일.. yoongrammer.tistory.com 쉽게 말해서 client -> handler -> agent -> manager 구조에서 하위단인 client 말고 상위단인 manager 쪽에서 수정할 수 있게끔 코드를 짜야한다. 라는 의미 2022. 9. 14. 코루틴 과 Eventloop 그리고 Future 참고 : https://tech.buzzvil.com/blog/asyncio-no-1-coroutine-and-eventloop/ asyncio 뽀개기 1 - Coroutine과 Eventloop 이 시리즈의 목적은 asyncio의 컴포넌트들과 활용법을 소개하는 것입니다. 최종적으로는 실제 production에 쓰이고 있는 graceful shutdown을 구현하는 것을 목표로 하며, 그 과정에서 필요한 asyncio 지식 tech.buzzvil.com https://tech.buzzvil.com/blog/asyncio-no-2-future/ asyncio 뽀개기 2 - Future의 활용 Future를 잘 활용하면 단순히 await 하는 용도보다 더 다양한 흐름 제어를 할 수 있습니다. 이전 포스트에서.. 2022. 9. 14. agent,handler 모음 (ros2, gmqtt, asyncio.Queue) 원래는 manager가 ros2, gmqtt, queue 각각 3개 agent를 다뤄주고 ros2 와 gmqtt 는 client - handler - agent 구조 queue 는 client - agent 구조 인데 manager 는 아직 구현 안함. client 는 라이브러리라고 생각하면 된다. 지금 코드는 agent 까지만 구현되있어서 agent끼리 구현해볼 수 있게끔 해놈 실행은 agent.py 코드 키면 되고 코드 내부에 출력 결과 적혀있고 subscribe 랑 publish 해보려면 ros2 같은경우엔 명령어로 test gmqtt 같은 경우엔 mqtt box 로 test 함. ( gmqtt 경우엔 docker 로 emqx 올리고 셋업까지 해서 동작 시킴 ) 일단 코드만 올려 놓음 ros2 ha.. 2022. 9. 12. Ros2 Node 클래스 설명 // 노드랑 sub or pub config 값 바인딩 할때 ROS2 에서 self._sub_node_obj = rclpy.create_node(self.sub_node_info.node_name) 으로 노드 생성하고 def _node_obj_create_subscription(self) -> None: """subscribe 노드 생성시 사용 되는 함수""" print("create_subscription on ", flush=True) self._sub_node_obj.Subscription = self._sub_node_obj.create_subscription( self.sub_node_info.msg_type, self.sub_node_info.topic_name, self.sub_node_info.callback, self.sub_node_info.qo.. 2022. 9. 7. 이전 1 ··· 13 14 15 16 17 18 19 ··· 43 다음