Lidar's, Lines, and Lives
- Caleb Dueck
- Jan 16, 2024
- 2 min read
Development Summary
As mentioned in a previous post we need to know where the player is in the room. Over the holidays I have refined the Lidar code to better process where the player is.
The code defines two zones, the room and a safe zone. The room defines a large rectangle where the program will consider lidar points, anything outside of this zone will be ignored.
The code has been refined to better determine the location of the player. It now considers the average of all points within the room zone and determines the average of this cluster. It returns this coordinate as the location of the player. For graphic representation it also returns a line of best fit on the data points that extends 1 std deviation from the centre point.
This will determine where the player is in the room. Allowing us to confirm they are not too close to the launcher and that they remain in the gameplay area. If they exit the safe zone a life lost signal will be sent to the main game computer.
Currently we plan to only consider the player out of the safe zone if the average of all lidar points are outside the safe zone, however we could also use the line of best fit and ensure that the average point +/- 1 std deviation is contained in the safe zone.
Testing
This was tested with one player walking around the game zone and it worked as expected.
To determine how it would react to a ball flying into the lidars field of view, objects were thrown around the room, these only appeared as one or two lidar points and since the human consists of dozens of points it did not impact the average centre point.
However, should this become an issue a clustering algorithm can be used that ignores outliers.
Also to scale for more than a single player a k-means clustering algorithm can be used. Where k = the number of players. That way each player can be tracked and the game can adapt accordingly.
Comments