Robotics StackExchange | Archived questions

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.

Asked by aks on 2018-05-21 06:43:33 UTC

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.

Asked by PeteBlackerThe3rd on 2018-05-21 07:58:36 UTC

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

Asked by aks on 2018-05-21 08:33:44 UTC

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

Asked by PeteBlackerThe3rd on 2018-05-21 10:19:56 UTC

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

Asked by gvdhoorn on 2018-05-21 10:21:36 UTC

Answers