lesunb / HMRSsim

Simulator for research in Heterogeneous Multi-Robots Environment. The intention is to provide extensible, lightweight, portable, low fidelity, visualizable simulations for testing task allocation approaches in a heterogeneous, multi-robot environment. The priority is to provide the researcher with the capability to easily implement new maps by importing 2D draws from draw.io.
GNU General Public License v3.0
12 stars 7 forks source link

Handling collision with robot-wall #10

Open gabrielsr opened 3 years ago

gabrielsr commented 3 years ago

It is already implemented a detection collision system but the collision is not handled. This means that as is a robot can pass through a wall or another robot.

We should implement a system that makes the robot bounce back when it collides with a wall.

Gguidini commented 3 years ago

There are two different approaches we can do right now:

First is to modify the collidable component to accept a callback function. This function will take 2 args: the ID of the entity (self) and the ID of the entity I'm colliding to.

A different option would be to have the Collidable component accept a string, which would be the event tag for a reactive system. Upon colliding, the entity would fire up that event (e.g. add the event to the EventStore) to be picked up by the matching system.

Of course, in the future we might have both, but to begin with something, what do you guys think? I prefer option 1 for now. It's simpler and faster to implement.

gabrielsr commented 3 years ago

I preferer events =) @Gguidini could you elaborate more about the 'event tag'? Wouldn't a generic event collision (entity A, entity B) suffice?

Gguidini commented 3 years ago

If we add custom event tags then we can have custom collision handling systems. Adding the tags would allow for each system to retrieve from the EventStore only the events directed at them. It would have the form (tag, entity A, entity B).

Not every object reacts the same way when colliding, so I think it makes sense to have different systems for that.

Gguidini commented 3 years ago

Robots now stop when they collide to a Wall (changes).

I will NOT be closing this issue though, because that is a very crude implementation. Particularly when colliding round shapes diagonally it needs much improvement.

gabrielsr commented 3 years ago

Not every object reacts the same way when colliding, so I think it makes sense to have different systems for that.

It looks like a collision handling logic for me, not collision detection logic. In that case I would make a single system handling collisions calling different sub-behaviors.