engine

struct jiminy::systemHolder_t

Public Functions

systemHolder_t(void)
systemHolder_t(std::string const &systemNameIn, std::shared_ptr<Robot> robotIn, std::shared_ptr<AbstractController> controllerIn, callbackFunctor_t callbackFctIn)
systemHolder_t(systemHolder_t const &other) = default
systemHolder_t(systemHolder_t &&other) = default
systemHolder_t &operator=(systemHolder_t const &other) = default
systemHolder_t &operator=(systemHolder_t &&other) = default
~systemHolder_t(void) = default

Public Members

std::string name
std::shared_ptr<Robot> robot
std::shared_ptr<AbstractController> controller
callbackFunctor_t callbackFct
struct jiminy::stepperState_t

Public Functions

inline stepperState_t(void)
inline void reset(float64_t const &dtInit, std::vector<vectorN_t> const &qSplitInit, std::vector<vectorN_t> const &vSplitInit, std::vector<vectorN_t> const &aSplitInit)

Public Members

uint32_t iter
uint32_t iterFailed
float64_t t
float64_t tPrev
float64_t tError

Internal buffer used for Kahan algorithm storing the residual sum of errors.

float64_t dt
float64_t dtLargest
float64_t dtLargestPrev
std::vector<vectorN_t> qSplit
std::vector<vectorN_t> vSplit
std::vector<vectorN_t> aSplit
struct jiminy::systemState_t

Public Functions

systemState_t(void)
~systemState_t(void) = default
hresult_t initialize(Robot const &robot)
bool_t const &getIsInitialized(void) const
void clear(void)

Public Members

vectorN_t q
vectorN_t v
vectorN_t a
vectorN_t command
vectorN_t u
vectorN_t uMotor
vectorN_t uInternal
vectorN_t uCustom
forceVector_t fExternal
class jiminy::EngineMultiRobot

Subclassed by jiminy::Engine

Public Functions

inline configHolder_t getDefaultContactOptions()
inline configHolder_t getDefaultJointOptions()
inline configHolder_t getDefaultWorldOptions()
inline configHolder_t getDefaultStepperOptions()
inline configHolder_t getDefaultTelemetryOptions()
inline configHolder_t getDefaultEngineOptions()
EngineMultiRobot(EngineMultiRobot const &engine) = delete
EngineMultiRobot &operator=(EngineMultiRobot const &other) = delete
EngineMultiRobot(void)
~EngineMultiRobot(void)
hresult_t addSystem(std::string const &systemName, std::shared_ptr<Robot> robot, std::shared_ptr<AbstractController> controller, callbackFunctor_t callbackFct)
hresult_t addSystem(std::string const &systemName, std::shared_ptr<Robot> robot, callbackFunctor_t callbackFct)
hresult_t removeSystem(std::string const &systemName)
hresult_t setController(std::string const &systemName, std::shared_ptr<AbstractController> controller)
hresult_t registerForceCoupling(std::string const &systemName1, std::string const &systemName2, std::string const &frameName1, std::string const &frameName2, forceCouplingFunctor_t forceFct)

Add a force linking both systems together.

This function registers a callback function forceFct that links both systems by a given force. This function must return the force that the second systems applies to the first system, in the global frame of the first frame (i.e. expressed at the origin of the first frame, in word coordinates).

Parameters
  • systemName1[in] Name of the first system (the one receiving the force)

  • systemName2[in] Name of the second system (the one applying the force)

  • frameName1[in] Frame on the first system where the force is applied.

  • frameName2[in] Frame on the second system where (the opposite of) the force is applied.

  • forceFct[in] Callback function returning the force that systemName2 applies on systemName1, in the global frame of frameName1.

hresult_t registerViscoElasticDirectionalForceCoupling(std::string const &systemName1, std::string const &systemName2, std::string const &frameName1, std::string const &frameName2, float64_t const &stiffness, float64_t const &damping)
hresult_t registerViscoElasticDirectionalForceCoupling(std::string const &systemName, std::string const &frameName1, std::string const &frameName2, float64_t const &stiffness, float64_t const &damping)
hresult_t registerViscoElasticForceCoupling(std::string const &systemName1, std::string const &systemName2, std::string const &frameName1, std::string const &frameName2, vectorN_t const &stiffness, vectorN_t const &damping)
hresult_t registerViscoElasticForceCoupling(std::string const &systemName, std::string const &frameName1, std::string const &frameName2, vectorN_t const &stiffness, vectorN_t const &damping)
hresult_t removeForcesCoupling(std::string const &systemName1, std::string const &systemName2)
hresult_t removeForcesCoupling(std::string const &systemName)
hresult_t removeForcesCoupling(void)
forceCouplingRegister_t const &getForcesCoupling(void) const
hresult_t removeAllForces(void)
void reset(bool_t const &resetRandomNumbers = false, bool_t const &removeAllForce = false)

Reset engine.

This function resets the engine, the robot and the controller. This method is made to be called in between simulations, to allow registering of new variables to log, and reset the random number generators.

Parameters
  • resetRandomNumbers[in] Whether or not to reset the random number generators.

  • removeAllForce[in] Whether or not to remove registered external forces.

hresult_t start(std::map<std::string, vectorN_t> const &qInit, std::map<std::string, vectorN_t> const &vInit, boost::optional<std::map<std::string, vectorN_t>> const &aInit = boost::none)

Reset the engine and compute initial state.

This function does NOT reset the engine, robot and controller. It is up to the user to do so, by calling reset method first.

Parameters
  • qInit[in] Initial configuration of every system.

  • vInit[in] Initial velocity of every system.

  • aInit[in] Initial acceleration of every system. Optional: Zero by default.

hresult_t step(float64_t stepSize = -1)

Integrate system from current state for a duration equal to stepSize.

This function performs a single ‘integration step’, in the sense that only the endpoint is added to the log. The integrator object is allowed to perform multiple steps inside of this interval. One may specify a negative timestep to use the default update value.

Parameters

stepSize[in] Duration for which to integrate ; set to negative value to use default update value.

void stop(void)

Stop the simulation.

It releases the lock on the robot and the telemetry, so that it is possible again to update the robot (for example to update the options, add or remove sensors…) and to register new variables or forces.

hresult_t simulate(float64_t const &tEnd, std::map<std::string, vectorN_t> const &qInit, std::map<std::string, vectorN_t> const &vInit, boost::optional<std::map<std::string, vectorN_t>> const &aInit = boost::none)

Run a simulation of duration tEnd, starting at xInit.

Parameters
  • tEnd[in] End time, i.e. amount of time to simulate.

  • qInit[in] Initial configuration of every system, i.e. at t=0.0.

  • vInit[in] Initial velocity of every system, i.e. at t=0.0.

  • aInit[in] Initial acceleration of every system, i.e. at t=0.0. Optional: Zero by default.

hresult_t registerForceImpulse(std::string const &systemName, std::string const &frameName, float64_t const &t, float64_t const &dt, pinocchio::Force const &F)

Apply an impulse force on a frame for a given duration at the desired time. The force must be given in the world frame.

hresult_t registerForceProfile(std::string const &systemName, std::string const &frameName, forceProfileFunctor_t const &forceFct, float64_t const &updatePeriod = 0.0)

Apply an external force profile on a frame. It can be either time-continuous or discrete. The force can be time and state dependent, and must be given in the world frame.

hresult_t removeForcesImpulse(std::string const &systemName)
hresult_t removeForcesProfile(std::string const &systemName)
hresult_t removeForcesImpulse(void)
hresult_t removeForcesProfile(void)
hresult_t getForcesImpulse(std::string const &systemName, forceImpulseRegister_t const *&forcesImpulsePtr) const
hresult_t getForcesProfile(std::string const &systemName, forceProfileRegister_t const *&forcesProfilePtr) const
configHolder_t getOptions(void) const
hresult_t setOptions(configHolder_t const &engineOptions)
bool_t getIsTelemetryConfigured(void) const
std::vector<std::string> getSystemsNames(void) const
hresult_t getSystemIdx(std::string const &systemName, int32_t &systemIdx) const
hresult_t getSystem(std::string const &systemName, systemHolder_t *&system)
hresult_t getSystemState(std::string const &systemName, systemState_t const *&systemState) const
stepperState_t const &getStepperState(void) const
bool_t const &getIsSimulationRunning(void) const
float64_t getMaxSimulationDuration(void) const
hresult_t computeSystemsDynamics(float64_t const &t, std::vector<vectorN_t> const &qSplit, std::vector<vectorN_t> const &vSplit, std::vector<vectorN_t> &aSplit)
hresult_t getLogDataRaw(std::shared_ptr<logData_t const> &logData)
hresult_t getLogData(std::vector<std::string> &header, matrixN_t &logMatrix)

Get the full logged content.

Parameters
  • header[out] Header, vector of field names.

  • logMatrix[out] Corresponding data in the log file.

hresult_t writeLog(std::string const &filename, std::string const &format = "binary")

Public Members

std::unique_ptr<engineOptions_t const> engineOptions_
std::vector<systemHolder_t> systems_

Public Static Functions

static void computeForwardKinematics(systemHolder_t &system, vectorN_t const &q, vectorN_t const &v, vectorN_t const &a)
static hresult_t parseLogBinaryRaw(std::string const &filename, logData_t &logData)
static hresult_t parseLogBinary(std::string const &filename, std::vector<std::string> &header, matrixN_t &logMatrix)
struct contactOptions_t

Public Functions

inline contactOptions_t(configHolder_t const &options)

Public Members

std::string const model
std::string const solver
float64_t const regularization
float64_t const stabilizationFreq
float64_t const stiffness
float64_t const damping
float64_t const transitionEps
float64_t const friction
float64_t const torsion
float64_t const transitionVelocity
struct engineOptions_t

Public Functions

inline engineOptions_t(configHolder_t const &options)

Public Members

telemetryOptions_t const telemetry
stepperOptions_t const stepper
worldOptions_t const world
jointOptions_t const joints
contactOptions_t const contacts
struct jointOptions_t

Public Functions

inline jointOptions_t(configHolder_t const &options)

Public Members

float64_t const boundStiffness
float64_t const boundDamping
struct stepperOptions_t

Public Functions

inline stepperOptions_t(configHolder_t const &options)

Public Members

bool_t const verbose
uint32_t const randomSeed
std::string const odeSolver
float64_t const tolAbs
float64_t const tolRel
float64_t const dtMax
float64_t const dtRestoreThresholdRel
uint32_t const successiveIterFailedMax
uint32_t const iterMax
float64_t const timeout
float64_t const sensorsUpdatePeriod
float64_t const controllerUpdatePeriod
bool_t const logInternalStepperSteps
struct telemetryOptions_t

Public Functions

inline telemetryOptions_t(configHolder_t const &options)

Public Members

bool_t const enableConfiguration
bool_t const enableVelocity
bool_t const enableAcceleration
bool_t const enableForceExternal
bool_t const enableCommand
bool_t const enableMotorEffort
bool_t const enableEnergy
float64_t const timeUnit
struct worldOptions_t

Public Functions

inline worldOptions_t(configHolder_t const &options)

Public Members

vectorN_t const gravity
heatMapFunctor_t const groundProfile
class jiminy::Engine : public jiminy::EngineMultiRobot

Public Functions

Engine(Engine const &engine) = delete
Engine &operator=(Engine const &other) = delete
Engine(void)
~Engine(void) = default
hresult_t initialize(std::shared_ptr<Robot> robot, std::shared_ptr<AbstractController> controller, callbackFunctor_t callbackFct)
hresult_t initialize(std::shared_ptr<Robot> robot, callbackFunctor_t callbackFct)
hresult_t setController(std::shared_ptr<AbstractController> controller)
hresult_t addSystem(std::string const &systemName, std::shared_ptr<Robot> robot, std::shared_ptr<AbstractController> controller)
hresult_t removeSystem(std::string const &systemName)
hresult_t start(vectorN_t const &qInit, vectorN_t const &vInit, boost::optional<vectorN_t> const &aInit = boost::none, bool_t const &isStateTheoretical = false)

Reset the engine and compute initial state.

This function does NOT reset the engine, robot and controller. It is up to the user to do so, by calling reset method first.

Parameters
  • qInit[in] Initial configuration.

  • vInit[in] Initial velocity.

  • aInit[in] Initial acceleration. Optional: Zero by default.

  • isStateTheoretical[in] Specify if the initial state is associated with the current or theoretical model

hresult_t simulate(float64_t const &tEnd, vectorN_t const &qInit, vectorN_t const &vInit, boost::optional<vectorN_t> const &aInit = boost::none, bool_t const &isStateTheoretical = false)

Run a simulation of duration tEnd, starting at xInit.

Parameters
  • tEnd[in] End time, i.e. amount of time to simulate.

  • qInit[in] Initial configuration, i.e. state at t=0.

  • vInit[in] Initial velocity, i.e. state at t=0.

  • aInit[in] Initial acceleration, i.e. state at t=0.

  • isStateTheoretical[in] Specify if the initial state is associated with the current or theoretical model

hresult_t registerForceImpulse(std::string const &frameName, float64_t const &t, float64_t const &dt, pinocchio::Force const &F)
hresult_t registerForceProfile(std::string const &frameName, forceProfileFunctor_t const &forceFct, float64_t const &updatePeriod = 0.0)
hresult_t removeForcesImpulse(void)
hresult_t removeForcesProfile(void)
forceImpulseRegister_t const &getForcesImpulse(void) const
forceProfileRegister_t const &getForcesProfile(void) const
hresult_t registerForceCoupling(std::string const &frameName1, std::string const &frameName2, forceProfileFunctor_t forceFct)
hresult_t registerViscoElasticForceCoupling(std::string const &frameName1, std::string const &frameName2, vectorN_t const &stiffness, vectorN_t const &damping)
hresult_t registerViscoElasticDirectionalForceCoupling(std::string const &frameName1, std::string const &frameName2, float64_t const &stiffness, float64_t const &damping)
hresult_t removeForcesCoupling(void)
hresult_t removeAllForces(void)
bool_t const &getIsInitialized(void) const
hresult_t getSystem(systemHolder_t *&system)
hresult_t getRobot(std::shared_ptr<Robot> &robot)
hresult_t getController(std::shared_ptr<AbstractController> &controller)
hresult_t getSystemState(systemState_t const *&systemState) const