Skip to content
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

Component wrappers limited to changing spaces #477

Open
rusu24edward opened this issue Dec 7, 2023 · 0 comments
Open

Component wrappers limited to changing spaces #477

rusu24edward opened this issue Dec 7, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@rusu24edward
Copy link
Collaborator

rusu24edward commented Dec 7, 2023

I designed the component wrapper to transform points from one space to another and back. So the interface has check_space, wrap_space, wrap_point, and unwrap_point. However, not all wrappers do this. Here's an example:

class DriftMoveActor(ActorWrapper):
    def __init__(self, component, **kwargs):
        assert isinstance(component, CrossMoveActor), "DriftMove only works with CrossMove."

    def check_space(self, *args):
        """
        DriftMoveActor does not change the agent's space, so we just return True.
        """
        return True

    def wrap_space(self, space):
        """
        DriftMoveActor does not change the agent's space, so we just return the space.
        """
        return space
    
    def wrap_point(self, space, point, **kwargs):
        # converting "stay" to a movement is the point wrap! BUT: can we unwrap it? And if not ,then
        # should we use the wrap/unwrap approach?
        return point
    
    def unwrap_point(self, space, point):
        return super().unwrap_point(space, point)()

    def process_action(self, agent, action_dict, **kwargs):
        if isinstance(agent, OrientationAgent): # Extra assertion, resolveable with #423
            if action_dict[self.wrapped_component.key] == 0: # Stay was issued
                ...

This wrapper leverages the logic the cross move actor without transforming the data in a bijection (0 is transformed to the agent's orientation, but we can't go back). The four api functions are unnecessary for this use case.

Related to #306
Comes out of #470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant