controller

class jiminy::AbstractController

Generic interface for any controller.

Any controller must inherit from this base class and implement its virtual methods.

The controller used to initialize a Jiminy Engine is downcasted as an instance of AbstractController and polymorphism is used to call the actual implementations.

Subclassed by jiminy::ControllerFunctor< F1, F2 >

Public Functions

inline virtual configHolder_t getDefaultControllerOptions()

Dictionary gathering the configuration options shared between controllers.

AbstractController(AbstractController const &controller) = delete
AbstractController &operator=(AbstractController const &controller) = delete
AbstractController(void)
virtual ~AbstractController(void) = default
virtual hresult_t initialize(std::weak_ptr<Robot const> robot)

Set the parameters of the controller.

Parameters

robot[in] Robot

Returns

Return code to determine whether the execution of the method was successful.

hresult_t registerVariable(std::vector<std::string> const &fieldnames, Eigen::Ref<vectorN_t, 0, Eigen::InnerStride<>> values)

Dynamically registered a Eigen Vector to the telemetry.

Internally, all it does is to store a reference to the variable, then it logs its value periodically. There is no update mechanism what so ever nor safety check. So the user has to take care of the life span of the variable, and to update it manually whenever it is necessary to do so.

Parameters
  • fieldnames[in] Name of each element of the variable. It will appear in the header of the log.

  • values[in] Eigen vector to add to the telemetry. It accepts non-contiguous temporary.

Returns

Return code to determine whether the execution of the method was successful.

hresult_t registerVariable(std::string const &fieldName, float64_t const &value)

Dynamically registered a float64 to the telemetry.

Internally, all it does is to store a reference to the variable, then it logs its value periodically. There is no update mechanism what so ever nor safety check. So the user has to take care of the life span of the variable, and to update it manually whenever it is necessary to do so.

Parameters
  • fieldnames[in] Name of the variable. It will appear in the header of the log.

  • values[in] Variable to add to the telemetry

Returns

Return code to determine whether the execution of the method was successful.

template<typename T>
hresult_t registerConstant(std::string const &fieldName, T const &value)

Register a constant float64 to the telemetry.

Register a constant to the telemetry.

Parameters
  • fieldnames[in] Name of the variable.

  • values[in] Variable to add to the telemetry

Returns

Return code to determine whether the execution of the method was successful.

void removeEntries(void)

Remove all variables dynamically registered to the telemetry.

Note that one must reset Jiminy Engine for this to take effect.

virtual hresult_t computeCommand(float64_t const &t, vectorN_t const &q, vectorN_t const &v, vectorN_t &command) = 0

Compute the command.

It assumes that the robot internal state (including sensors) is consistent with other input arguments. It fetches the sensor data automatically.

Parameters
  • t[in] Current time

  • q[in] Current configuration vector

  • v[in] Current velocity vector

  • command[out] Output effort vector

Returns

Return code to determine whether the execution of the method was successful.

virtual hresult_t internalDynamics(float64_t const &t, vectorN_t const &q, vectorN_t const &v, vectorN_t &uCustom) = 0

Emulate internal dynamics of the system at are not included in the physics engine.

Parameters
  • t[in] Current time

  • q[in] Current configuration vector

  • v[in] Current velocity vector

  • uCustom[in] Output effort vector

Returns

Return code to determine whether the execution of the method was successful.

configHolder_t getOptions(void) const

Get the configuration options of the controller.

Returns

Dictionary with the parameters of the controller

void setOptions(configHolder_t const &ctrlOptions)

Set the configuration options of the controller.

Note that one must reset Jiminy Engine for this to take effect.

Parameters

ctrlOptions[in] Dictionary with the parameters of the controller

Returns

Return code to determine whether the execution of the method was successful.

virtual hresult_t configureTelemetry(std::shared_ptr<TelemetryData> telemetryData, std::string const &objectPrefixName = "")

Configure the telemetry of the controller.

This method connects the controller-specific telemetry sender to a given telemetry data (which is unique for a given robot), so that it is later possible to register the variables that one want to monitor. Finally, the telemetry recoder logs every registered variables at each timestep in a memory buffer.

Remark

This method is not intended to be called manually. The Engine is taking care of it before flushing the telemetry data at the end of each simulation steps.

Parameters

telemetryData[in] Shared pointer to the robot-wide telemetry data object

Returns

Return code to determine whether the execution of the method was successful.

virtual void updateTelemetry(void)

Update the internal buffers of the telemetry associated with variables monitored by the controller.

As the main entry point for a user to log extra variables, the engine also passes the current state of the robot to enable logging of custom state-related variables.

Remark

This method is not intended to be called manually. The Engine is taking care of it before flushing the telemetry data at the end of each simulation steps.

Parameters
  • t[in] Current time.

  • q[in] Current position.

  • v[in] Current velocity.

virtual hresult_t reset(bool_t const &resetDynamicTelemetry = false)

Reset the internal state of the controller.

Note that it resets the configuration of the telemetry.

Remark

This method is not intended to be called manually. The Engine is taking care of it when its own reset method is called.

Parameters

resetDynamicTelemetry[in] Whether or not variables dynamically registered to the telemetry must be removed. Optional: False by default

bool_t const &getIsInitialized(void) const

Get isInitialized_.

It is a flag used to determine if the controller has been initialized.

Remark

Note that a controller can be considered initialized even if its telemetry is not properly configured. If not, it is the only to do before being ready to use.

bool_t const &getIsTelemetryConfigured(void) const

Get isTelemetryConfigured_.

It is a flag used to determine if the telemetry of the controller has been initialized.

Public Members

std::unique_ptr<controllerOptions_t const> baseControllerOptions_

Structure with the parameters of the controller.

std::weak_ptr<Robot const> robot_

Robot for which to compute the command and internal dynamics must be computed.

sensorsDataMap_t sensorsData_
struct controllerOptions_t

Structure with the configuration options shared between controllers.

Public Functions

inline controllerOptions_t(configHolder_t const &options)

Public Members

bool_t const telemetryEnable

Flag used to enable the telemetry of the controller.

template<typename F1, typename F2>
class jiminy::ControllerFunctor : public jiminy::AbstractController

Public Functions

ControllerFunctor(ControllerFunctor const &controller) = delete

Forbid the copy of the class.

ControllerFunctor &operator=(ControllerFunctor const &controller) = delete
ControllerFunctor(F1 &commandFct, F2 &internalDynamicsFct)

Constructor.

Remark

A valid ‘callable’ is a function pointer, functor or lambda with signature: void(float64_t const & t, vectorN_t const & q, vectorN_t const & v, sensorsDataMap_t const & sensorsData, vectorN_t & command) where I is range(n), with n the number of different type of sensor.

Parameters
  • commandFct[in] ‘Callable’ computing the command

  • internalDynamicsFct[in] ‘Callable’ computing the internal dynamics

ControllerFunctor(F1 &&commandFct, F2 &&internalDynamicsFct)
~ControllerFunctor(void) = default
virtual hresult_t computeCommand(float64_t const &t, vectorN_t const &q, vectorN_t const &v, vectorN_t &command) override

Compute the command.

It assumes that the robot internal state (including sensors) is consistent with other input arguments. It fetches the sensor data automatically.

Parameters
  • t[in] Current time

  • q[in] Current configuration vector

  • v[in] Current velocity vector

  • command[out] Output effort vector

Returns

Return code to determine whether the execution of the method was successful.

virtual hresult_t internalDynamics(float64_t const &t, vectorN_t const &q, vectorN_t const &v, vectorN_t &uCustom) override

Emulate internal dynamics of the system at are not included in the physics engine.

Parameters
  • t[in] Current time

  • q[in] Current configuration vector

  • v[in] Current velocity vector

  • command[in] Output effort vector

Returns

Return code to determine whether the execution of the method was successful.