You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use inheritance in our modules to enable specialised derived classes to have the same external API and internal structure as the base class. This is good for the end user, as they can simply call .compute_command on a controller object. Thanks to the employed parameter structure, derived objects can add new "properties" such as gains and configurations without actually needing new accessors or class properties.
This kind of polymorphism lends itself nicely to factory patterns, in which we use a pointer to the base class to encapsulate a derived object.
If we want a downstream user to have a generic ds or ctrl component that they can instantiate with a specific type dynamically, we should provide such a factory directly, including an enumeration of supported types. For example:
The dependency injection provided by the factory pattern would also make binding these modules in Python much more straightforward, since you could bind just the base class / a wrapper around the factory.
Since both the DynamicalSystems and Controller base classes are templated by the state type, it requires a bit of design thought on the best approach. In the example above I suggest a factory template by either CartesianState or JointState, but other kinds of polymorphic factories might also be possible.
In any case I think this will be a very valuable feature to make it easy for a user to switch out their running controller or ds based on run-time parameters.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
We use inheritance in our modules to enable specialised derived classes to have the same external API and internal structure as the base class. This is good for the end user, as they can simply call
.compute_command
on a controller object. Thanks to the employed parameter structure, derived objects can add new "properties" such as gains and configurations without actually needing new accessors or class properties.This kind of polymorphism lends itself nicely to factory patterns, in which we use a pointer to the base class to encapsulate a derived object.
If we want a downstream user to have a generic
ds
orctrl
component that they can instantiate with a specific type dynamically, we should provide such a factory directly, including an enumeration of supported types. For example:The dependency injection provided by the factory pattern would also make binding these modules in Python much more straightforward, since you could bind just the base class / a wrapper around the factory.
Since both the DynamicalSystems and Controller base classes are templated by the state type, it requires a bit of design thought on the best approach. In the example above I suggest a factory template by either
CartesianState
orJointState
, but other kinds of polymorphic factories might also be possible.In any case I think this will be a very valuable feature to make it easy for a user to switch out their running controller or ds based on run-time parameters.
Beta Was this translation helpful? Give feedback.
All reactions