I am writing a custom Task for simulating pick and place with Franka (standalone application). BaseTask has a pre_step function that gets time_step_index argument. The value of this argument is 2 at the first call to pre_step. Why is it not 0?
Hi @prath4 - The pre_step function in the BaseTask class is called before each simulation step. The time_step_index argument represents the current simulation step index.
The reason it starts from 2 instead of 0 is due to the initialization process of the simulation. The first two steps (0 and 1) are used for setting up the simulation and initializing various components. Therefore, the pre_step function is first called at the third step of the simulation, which is why time_step_index starts from 2.
Thanks @rthaker for the quick reply. I would also like to know if that is deterministic and I will always get 2 for time_step_index in the first callback. Or the value is dependent on the simulation setup? What if I add a task in the middle of the simulation? Does task initialization always require a world reset? If I understand correctly the value counts steps from the last world reset.
Hi @prath4 - The time_step_index argument in the pre_step function of a BaseTask in Isaac Sim represents the current simulation step index. This index is incremented each time the simulation takes a step.
The initial value of time_step_index being 2 is a result of the simulation initialization process and should be consistent across different simulation setups. However, this is an implementation detail of the simulation engine and could potentially change in future versions of the software.
If you add a task in the middle of the simulation, the time_step_index for that task’s pre_step function will start from the current simulation step index, not from 0 or 2. This is because the time_step_index is tied to the simulation itself, not to individual tasks.
Task initialization does not always require a world reset. You can add tasks to the simulation at any time, and they will start running from the current simulation step. However, if you want to reset the state of a task or the entire simulation, you can do so by resetting the world.
You’re correct that the time_step_index counts steps from the last world reset. If you reset the world, the time_step_index will go back to 0, and the next call to pre_step will have a time_step_index of 2.