ros2_python/Ros2 msg,srv,action,parm15 ros2 topic spin 중에 등록해도 동작할까 결론 : ㅇㅋ 됨 터미널 3개 띄우고 python ros2_sub_test.py ros2 topic pub /test_1 std_msgs/msg/String data:\ \'\'\ ros2 topic pub /test_2 std_msgs/msg/String data:\ \'\'\ 각각 킨 후, python ros2_sub_test.py 내부에선 spin 은 쓰레딩으로 돌리고 /test_1 토픽 등록 --> 5초후 /test_2 토픽 등록 5초후 둘다 받음 테스트 예제 import rclpy from rclpy.node import Node from std_msgs.msg import String import time import threading class MinimalSubscriber(): def _.. 2023. 8. 28. ROS2_Action simple example code https://docs.ros.org/en/eloquent/Tutorials/Actions/Writing-a-Py-Action-Server-Client.html Writing an action server and client (Python) — ROS 2 Documentation: Eloquent documentation You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Iron. Writing an action .. 2023. 7. 3. ROS2 service blocking 피하는 방법 동작 방식 : 1. main_job sub_job service_call_job 이 동시에 돌아감. 2. main_job sub_job 은 1초마다 프린트함. 3. service_call_job 는 서비스 콜을 동작하는 task req를 인자로 받고 "로스Client.call_async(req)" 를 쏜 후, spin_until_future_complete time_out: print(f"{limit}초 동안 response 가 없으므로 타임아웃 ") return "Response Timeout 으로 인해 종료처리함." if _future.done(): # rclpy.spin() 을 돌리는 상황이면 done() 체킹을 꼭 해줘야함. 왜냐면 done() 상황이 아닌 future는 "future.result.. 2023. 7. 1. Service 비교 ROS1 vs ROS2 (spin돌려야되나?) ROS1 결론 : spin을 돌릴 필요가 없다. SERVER 는 블럭해주기만 하면 되고 CLIENT 는 그냥 req 날리고 res 기다린다. 이유 : rospy에서 spin 은 'roscore' 가 켜졌는지 확인하고 'roscore'가 종료 될때 까지 blocking 루프 돌리는게 다이기 때문.. 예시 # SERVER #!/usr/bin/env python import time import rospy from std_srvs.srv import SetBool, SetBoolResponse def handle_set_bool(req): if req.data: rospy.loginfo("Received a request to set the value to True.") else: rospy.loginfo(".. 2023. 7. 1. 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. 이전 1 2 3 다음