-
Notifications
You must be signed in to change notification settings - Fork 504
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
Add a cache to ObjectStateMachine. #2079
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands, this isn't going to catch cases where the states are updated externally to the state machine, such as action updates. I don't know that caching is the best solution unless the ObjectStateSpec
singletons also map back to the parent ObjectStateMachine
in order modify the dirty flag themselves. Even then, most of the updates use set_state_of_obj
directly which doesn't hit either singleton class. For example:
def set_object_state( |
None of these will be caught and the update() function is called in the simulation loop, so you're really only catching that "step" has been called since last query I think.
habitat-lab/habitat/sims/habitat_simulator/object_state_machine.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments for reviewers.
if osm is not None: | ||
return osm.get_snapshot_dict(sim) | ||
else: | ||
return {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cache is no longer necessary.
new_state = not cur_state | ||
set_state_of_obj(obj, self.name, new_state) | ||
return new_state | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aclegg3 : This code is unused. Let me know if you have plans for it.
It's probably not the right abstraction because toggling may have different conditions depending on the current state, e.g. Clean -> Dirty
, Empty -> Full
, etc.
""" | ||
|
||
user_attr = obj.user_attributes | ||
obj_state_config = user_attr.get_subconfig("object_states") | ||
obj_state_config.set(state_name, state_val) | ||
user_attr.save_subconfig("object_states", obj_state_config) | ||
|
||
if object_state_machine is not None: | ||
object_state_machine.set_snapshot_dirty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aclegg3 : This is not ideal, but because set_state_of_obj()
is used everywhere to change states, it does the job.
Motivation and Context
This adds a cache to
ObjectStateMachine
so thatget_snapshot_dict()
doesn't re-compute the same snapshot over and over.On a reference single-learn HITL application, this improves the framerate from
11.3
to12.3
FPS.How Has This Been Tested
Tested locally + unit tests.
Types of changes
Checklist