Fix time management in robots and marbles notebook 4 #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The notebook 4 starts by the following:
This suggests (to me at least :) ) that the first part of this notebook will follow the last part of the notebook 3.
Nevertheless, the results of the simulation look different.
In fact, after a look at the code across these 2 sections (last section of notebook 3 and first section of notebook 4) it seems that time is managed slightly differently (justifying the different simulation results).
I'm not entirely sure how the backend of cadCAD operates, but I suspect that
steps
are shifted by one 1 w.r.t tos['timestep']
(i.e. the first step of the simulation is done at time 0). In fact, AFAICT, in notebook 3, the robots do not start operating at the system's starting time (thedef get_current_timestep(cur_substep, s)
function seems to avoid that and re-alignsteps
andtimesteps
), while this is not the case anymore in the first section of the notebook 4, wheredef get_current_timestep(cur_substep, s)
is not used anymore in therobot_arm_1
androbot_arm_2
policies and wheres['timestep']
is used directly instead. This means that in the notebook 4, both policies will returnrobot_arm(params, step, sH, s)
ifs['timestep'] = 0
because0%robots_periods[_robotId - 1]
will trivially return 0 in both cases. Hence, both robots will move marbles at the same time for timestept = 0
(which again, seems to be enforced not to happen like that in the last section of the notebook 3).I am not sure if this slight change in the model is intentional or not, but as far as I understand the first introductory part of the notebook 4 (quoted above) this does not appear to be desired.
This PR fixes this and re-introduces the
get_current_timestep
function in the first section of the notebook 4.Another way to fix this, would be to rephrase the model specification.
Please let me know if I missed something,
Thanks!