Extract obstacles from an image
Hi everyone,
I wanted to follow up on the idea to pick a color in an uploaded image and transform all those pixels into obstacles.
Design:
-
Add new button to simulator panel that shows the image and ask for a wall color using a color picker (this probably requires the upcoming change with the hamburger menu to allow more buttons) The button can also hide in the menu.
-
Convert wall pixels into an obstacle representation, the "obstacle map".
-
Find a free place in the map for the robot to place into. A hidden feature could be to hard-code one color to define the typical robot start position, but that's a detail.
-
Loading a new map will clean up the obstacle representation and one needs to use the color picker dialog again.
Implementation plan:
- I would first refactor the collision detection and sensor logic out of scene.js into a separate module, if that is ok with you. I'm thinking along these lines:
Define a class ObstacleMap with three methods:
- intersectsPoint(point) -> bool
- intersectsBall(ball) -> bool
- raycast(ray) -> closest intersection Point + distance I think with these methods, all the of logic in scene.js can be implemented.
Conceptually, this class represents everything that the robot can collide with.
-
Next, I would extract the wall image using a fixed color when loading an image and add it to the obstacle map. The raycast method will simply march through the intersecting pixels.
-
Finally, I would add the button to select the wall color and integrate the wall extraction into the simulator.
If that sounds ok to you, I would start implementing this feature now.
@bjost2s what about this ticket. I still think this would be a nice feature?