My question is related to this one (here) but not exactly. Assume now I have 4 topics: topic_A,topic_B,topic_C,topic_D. Inside my control loop, I need to read the sensor values from the first three topics (all of them are publishing at 1000 Hz for example), calculate my control input and publish the control input to topic_D for each iteration. My question is related to how to write the control loop properly. My current pseudo code is summarized as below:
1) I used the rospy.wait_for_message
because it guarantees that my control_input is being calculated from the most recent sensor values (a few ms before I calculate my control_input). Now I want to replace them because it seems like the subscriber callback function is faster, which is very important for my application.
2) In terms of code structure, I didn't use subscriber because I didn't know how to incorporate three callback functions properly to publish my control gain (I need to the three sensor values to update even though I'm running the while loop in the main_control_loop
function to get my control).
Based on the discussion from here. It looks like I can have several subscribers running together for rospy. Now assume I have three subscribers running as listed below, will the sensor_X_value be updated in each iteration of my main_control_loop
function?