ROS 2 C++ Tutorial: Simple Publisher & Subscriber Explained!

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 4

  • @sohampadhye5408
    @sohampadhye5408 18 วันที่ผ่านมา

    Dear Karan, good work.
    Actually I have one doubt, if I have two subscribers sb1 and sb2, and if sb2 callback depends on sb1 callback then how to ensure that sb1 callback will run before sb2 callback.
    PS:- sb2 callback is heavily coded as compared with sb1 as its critical callback

    • @fusybots
      @fusybots  18 วันที่ผ่านมา

      Hello Soham
      Actually it depends on which topic is getting the msg first.
      But if somehow both of your topics are getting msg at the same time then the callback of 1st object will be called first because it will be placed first in the queue callback of ros spin. But to avoid the case when sub2 topic is getting msg first, then you can guard the function of sub2 with variable update form sub1. This will ensure that once the variable gets updated from sub1 then only it will execute sub2. And if you are not using any parallel executors or threads your callbacks will always work in sequence one by one depending on the frequency of message.

    • @sohampadhye5408
      @sohampadhye5408 18 วันที่ผ่านมา +1

      @fusybots currently I'm guarding sub2 .

    • @fusybots
      @fusybots  18 วันที่ผ่านมา

      Nice!