# Force/Torque control with simulation substepping

**URL:** <https://forums.developer.nvidia.com/t/force-torque-control-with-simulation-substepping/196332>\
**Category:** Isaac Gym\
**Tags:** reinforcement-learning, dynamic-control\
**Created:** [November 26, 2021, 10:57am UTC](https://forums.developer.nvidia.com/t/force-torque-control-with-simulation-substepping/196332 "2021-11-26T10:57:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniels.ordonez](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daniels.ordonez/32/124889_2.png) [@daniels.ordonez](https://forums.developer.nvidia.com/u/daniels.ordonez)\
**Post date:** [November 26, 2021, 10:57am UTC](https://forums.developer.nvidia.com/t/force-torque-control-with-simulation-substepping/196332/1 "2021-11-26T10:57:27Z")

</div>

Good Day,

According to the documentation of ISAAC GYM, when using EFFORT control for the drive of the dof, it is mentioned that the user should provide target values per each iteration, whereas, for POS and VEL control, the user could/should only provide targets values when these change.

With this in consideration, I have doubts about the simulation’s behavior when using a non-zero number of simulation substeps. More specifically, I have doubts about the EFFORT values in the simulation between each timestep, that is, the EFFORTS applied during each substep, and used by the internal integration algorithms of the simulation.

Let’s say I have one revolut DoF, and that I am applying EFFORT control. I have a timestep of `dt=0.1s` and one substeps `dt_sub=0.05`. Additionally, at the beginning of my simulation `t=0.0` by DoF is at rest with no force applied `tau(t=0.0) = 0.0`, before i step my simulation I set the DoF effort to `tau=10 [Nm]`, and at the next timestep `t=0.1` I will change my effort to `tau=20[Nm].

It is unclear to me what value of EFFORT the DoF will use during each timestep and intermediate sub-time steps. Will the effort change discontinuously, will it be interpolated, or will every substep have the efforts reset to 0?. Perhaps the image could help to understand what are the possible cases.

 ![tau](https://global.discourse-cdn.com/nvidia/original/3X/b/d/bd1e293bff36f188f5510657786fe526609d4b0a.jpeg)

I believe this information is of key-value if we intend to do direct torque control.

I have a similar doubt regarding position and velocity control. Would the internal drive position and velocity errors `tau (t) = Kp * pos_error(t) * Kd * vel_error(t)` be updated at each simulation SUBtimestep? or will the values of the errors be those of the previous timestep?.

---

<div class="post-metadata">

**Author:** ![lwawrzyniak](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/lwawrzyniak/32/55627_2.png) [@lwawrzyniak](https://forums.developer.nvidia.com/u/lwawrzyniak)\
**Post date:** [November 30, 2021, 3:44pm UTC](https://forums.developer.nvidia.com/t/force-torque-control-with-simulation-substepping/196332/2 "2021-11-30T15:44:42Z")

</div>

Hello!

For position and velocity control, the internal drive position and velocity errors are updated at each substep. This is something that happens at the physics engine level (i.e. in PhysX or Flex).

The efforts are forces that remain constant during each substep, corresponding to the blue lines in your plot. They are not one-time impulses. They are scaled by the substep dt in the solver, so in theory the behaviour should be independent of the number of substeps, because it’s the same force acting over the same amount of time. In practice, some differences in behaviour are unavoidable when you change the number of substeps, due to numerical factors.

The `python/examples/dof_controls.py` example can be used to experiment with this.
