-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve whole-body and contacts simulator core execution speed #5
Comments
Proposed solution
We cannot replace the bindings by Simulink function calls combined with Simulink WBT blocks in a one-to-one mapping basis, mostly for the following reasons:
|
Implementation stepsSo the following steps are:
|
WIP: List all the called iDynTree bindings methodsList all the called iDynTree bindings methods, either directly called through the iDynTree object, either called through the
(*) Initialized in the library through the
... it is used for computing the floating base system state, dynamics, and kinematics. The model loading and initialization of the WBT shared KinDynComputations object (singleton) is actually done by any WBT block present in the system. In such case, (**) Can be avoided by using directly the frame name (string) as a block parameter if this parameter is set once at initialization (***) Not required for now as the computed default floating frame is the correct one (base/root link of the URDF model tree). |
|
Now Fixing compilation & run-time errors. Fixed so far:
|
Fixed other size mismatch errors by:
The Simulator now compiles and runs, with the following behavior:
|
Issue Analysis: Robot not moving through the whole simulationFor debugging the issue, we set the initial robot base pose to a significant height (e.g. 10m), in order to check a simple scenario, without link/ground impacts:
As the Matlab System block is now compiled with code generation, the usual MATLAB breakpoint workflow is not available, so we use the MATLAB display command to log critical computed variables. This way, we compare the dynamic quantities computed in The target quantities are the outputs of Side NoteThe expected bias forces are (first 3 components):
Which result in the base linear acceleration: There is probably an issue with the WBT Looking now closer at the problem... |
Issue Analysis: Robot not moving through the whole simulation
Just found the bug. Because of a double definition, the passed gravity vector was |
Implemented in #15, with the fixes described above. |
Issue: When hitting the round, the visualizer crashes due to singular matrix computationThe issue is actually caused by the fact that the robot right foot sinks in the ground (contact failure), creating very high reaction forces causing the simulation to diverge. Looking now for the root cause of the foot contact failure. Check:
|
|
Issue: WIP - Only one of the feet is staying "above the ground"After the robot sinks in the ground, only the vertices of the right foot stay on the ground, the other foot sinks far under the ground level.
This is probably related, again, with the contact mapping/index computations and velocities corrections. We'll check:
Wrong Forces ComputationWe checked the mapping of the contact points (vertices that were, and/or are in contact, respective built jacobians, etc) and it is working properly. The contacts are detected properly, as well as the impact detection (when a vertex was not in contact and now is), but the respective computed forces are always 0. Typically, after dropping iCub from 1m high, the first computed set of linear forces at the vertices impacting the ground should give:
but give all zeros (values < 10e-7) instead, this is why the feet sink into the ground after impact and although the first velocity correction is done properly at impact. After impact, the feet stay in contact, there is no new contact detected, and the simulation behavior depends solely on the ground reaction forces computation, output of the QR problem solver. The QR processing constraints include the equality constraints
So next check to do is the
|
C.C. @VenusPasandi |
Last issue fixed in f2184bd of the ongoing pull request. |
Execution speed analysis using the Simulink profiler:Actually, the last bottleneck slowing down the simulation was the visualizer, as we'll show in the following analysis. We illustrate below the blocks we will focus on in the execution profiler... The The Profile with the visualizer onWe obtained the following profile for a total simulated time of 1s: Final simulation state: The step time used for the visualizer ( As we can see in the profile report, it took ~48s for simulating 1s, so a rate of 1/48. The time shares for the blocks
The time share for the other Simulink functions (Function, Function1, Funciton2, ... Function7) is comparable to the QP function. The individual share of the QP is negligible w.r.t. the Profile with the visualizer off (commented)The simulation to real time rate is now 1/15, so the simulation is 3x faster. If we don't count the compile time, we get a ~1/7 rate. We can achieve the same performance with the visualizer if we treat it as an atomic unit and use a sample time of 40ms instead of 1ms, and treat it as an atomic unit the fake controller block as well, with a sample time of 1ms. This last detail is important as the sample time used by the We didn't observe significant improvement by treating the |
Related PR: robotology/idyntree#744 . |
Indeed, with a faster visualizer we could increase the display frequency and get a smoother motion in the visualizer. |
The MATLAB visualizer improvement will be dealt with in robotology/idyntree#744. The other improvements have been implemented in #15. Closing this issue. |
Currently in the worst case the simulation takes 15 sec for 1 sec (Real Time factor = 1/15 = 0.06). The identified bottleneck is the library
RobotDynamicsWithContacts
.Identified Reasons
The usage of bindings was initially motivated by the fact that it allows more effcient design of complex algorithms.
Fixed by #15.
The text was updated successfully, but these errors were encountered: