Skip to content

Commit

Permalink
Add docs for simulator callbacks and physics model input
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Feb 5, 2024
1 parent e2aa600 commit fccfe2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/jaxsim/physics/model/physics_model_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ def valid(

@jax_dataclasses.pytree_dataclass
class PhysicsModelInput(JaxsimDataclass):
"""
A class representing the input to a physics model.
This class stores the joint torques and external forces acting on the bodies of a physics model.
Attributes:
tau (jtp.Vector): An array representing the joint torques.
f_ext (jtp.Matrix): A matrix representing the external forces acting on the bodies of the physics model.
"""

tau: jtp.VectorJax
f_ext: jtp.MatrixJax

Expand Down
16 changes: 16 additions & 0 deletions src/jaxsim/simulation/simulator_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@


class SimulatorCallback(abc.ABC):
"""
A base class for simulator callbacks.
"""
pass


class ConfigureCallback(SimulatorCallback):
"""
A class for configuring a simulator callback.
"""
@property
def configure_cb(self) -> ConfigureCallbackSignature:
return lambda sim: self.configure(sim=sim)
Expand All @@ -28,6 +34,9 @@ def configure(self, sim: "jaxsim.JaxSim") -> "jaxsim.JaxSim":


class PreStepCallback(SimulatorCallback):
"""
A callback class for performing actions before each simulation step.
"""
@property
def pre_step_cb(self) -> PreStepCallbackSignature:
return lambda sim: self.pre_step(sim=sim)
Expand All @@ -38,6 +47,10 @@ def pre_step(self, sim: "jaxsim.JaxSim") -> Tuple["jaxsim.JaxSim", jtp.PyTree]:


class PostStepCallback(SimulatorCallback):
"""
A callback class for performing actions after each simulation step.
"""

@property
def post_step_cb(self) -> PostStepCallbackSignature:
return lambda sim, step_data: self.post_step(sim=sim, step_data=step_data)
Expand All @@ -50,4 +63,7 @@ def post_step(


class CallbackHandler(ConfigureCallback, PreStepCallback, PostStepCallback):
"""
A class that handles callbacks for the simulator.
"""
pass

0 comments on commit fccfe2c

Please sign in to comment.