Add motion replay controller component to the INFINYTOOLKIT#41
Add motion replay controller component to the INFINYTOOLKIT#41rmolazem wants to merge 15 commits intoInfinyTech3D:mainfrom
Conversation
|
|
||
| template<class DataTypes> | ||
| class MotionReplayController | ||
| : public sofa::component::controller::MechanicalStateController<DataTypes> |
There was a problem hiding this comment.
I would recommend to inherit directly from sofa::component::controller::Controller or BaseController
MechanicalStateController is already a very complexe specialisation of a simple controller and add a lot of unuseful methods in this case
|
I guess the closing is a wrong manipulation? |
|
Since the PR was open, and I made some modifications, including changing the base class. I thought it might be cleaner to open a clean PR. Except if you want to follow the history of the changes. |
|
You can keep the same PR as in any case we only review the change in files which is the final diff between your branch and master: https://github.com/InfinyTech3D/InfinyToolkit/pull/41/changes |
|
I conclude that using the SOFA controller slightly increases the FPS. I compared Scenario 2 for Asan#2 at three stages:
--> The approximate FPS values are: Python controller: 66, 37, 22 SOFA controller: 70, 39, 25 |
| private: | ||
|
|
||
| sofa::core::objectmodel::DataFileName d_motionFile; /// CSV file containing the frames | ||
| sofa::core::objectmodel::Data<double> d_dt; /// Simulation time-step |
There was a problem hiding this comment.
I'm not sure this one is useful.
If not you can remove it.
| sofa::core::objectmodel::DataFileName d_motionFile; /// CSV file containing the frames | ||
| sofa::core::objectmodel::Data<double> d_dt; /// Simulation time-step | ||
|
|
||
| sofa::core::behavior::MechanicalState<sofa::defaulttype::Vec3dTypes>* mGridState{nullptr}; ///Controlled grid |
There was a problem hiding this comment.
it would be better to store a link that can be set in the scene file. For example:
and then access it in the init method to check if link is valid. You can keep a pointer and make it equal to the link target.
InfinyToolkit/src/InfinyToolkit/InteractionTools/ArticulatedToolManager.cpp
Lines 116 to 121 in 3f2395f
|
|
||
| void MotionReplayController::init() | ||
| { | ||
| mGridState = this->getContext()->get<sofa::core::behavior::MechanicalState<sofa::defaulttype::Vec3dTypes>>(); |
There was a problem hiding this comment.
this one can be dangerous if the components are not in the same node or if several mechanical objects are present in the same context. This way using link make it safer.
| #include <sofa/core/ObjectFactory.h> | ||
|
|
||
| #include <InfinyToolkit/MotionReplayController/MotionReplayController.h> | ||
| #include <InfinyToolkit/MotionReplayController/MotionReplayController.inl> |
There was a problem hiding this comment.
If the class is not templated anymore, you don't need to put all the methods inline.
The inline methods are only necessary for templated classes.
This controller inherits from MechanicalStateController, allowing easy access to the mechanical object’s states after loading all frames at initialization from a CSV file.
The class introduces two new functions:
loadMotion() – Loads all frames from the CSV and stores them in a vector.
handleEvent() – Updates the mechanical object’s positions (grids) according to the loaded frames at each animation step.
However, while compiling SOFA (which includes the infiny toolkit), there is a linking issue: It seems it
cannot inherit from MechanicalStateController and the plugin does not compile. I might have missed some steps to properly register this component inside the InfinyToolkit.
P.S. I have updated SOFA from the master branch.