How to update a function every time step in ROS2 ?
I have a function which should update itself in every time step. How can i implement this ? I want something like this :
float calculateheatFlow(time, heatflow, tempPM1, tempPM2)
{ heatflow = (tempPM1-tempPM2)/0.2; //update the value every time step ?? how ??
return heatflow;
}
this value would then be used by another function.
Time step of what? Do you want this function to be executed at a fixed frequency? You can use the Timer object for this if so.
Yes, i want it the at a particular frequency : wherein I can do
heatflow = simulation_stepsize(1ms)*(tempPM1-tempPM2)/0.2
@PeteBlackerThe3rdGreat, if you look at the timer page I linked you too there are examples of doing exactly this.
Please note: the OP is using ROS2. You've linked him to the
roscpp
wiki page. There is noroscpp
in ROS2.