How to update a function every time step in ROS2 ?

asked 2018-05-21 06:43:33 -0500

aks gravatar image

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.

edit retag flag offensive close merge delete

Comments

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.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-21 07:58:36 -0500 )edit

Yes, i want it the at a particular frequency : wherein I can do heatflow = simulation_stepsize(1ms)*(tempPM1-tempPM2)/0.2@PeteBlackerThe3rd

aks gravatar image aks  ( 2018-05-21 08:33:44 -0500 )edit

Great, if you look at the timer page I linked you too there are examples of doing exactly this.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-21 10:19:56 -0500 )edit

Please note: the OP is using ROS2. You've linked him to the roscpp wiki page. There is no roscpp in ROS2.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-21 10:21:36 -0500 )edit