Closed ReikoR closed 2 years ago
get_ball_cord
/get_basket_cord
/get_ballNbasket_cord
should be called only once per game state iteration as calling it will cause to wait for new camera frames and different frames contain different information.
It is called once per while loop, which is one game state iteration. The first get_ball_cord() is to make sure the ball is still in view and can go into the while loop to rotate around the ball.
I think what Reiko tries to say is that all the check methods use this method under the hood:
This method executes: https://github.com/ut-robotics/picr21-team-sauna-madis/blob/a80c9164e964e816dcf8a4658698719917ffa470/saun/image.py#L73
And as the name implies, it waits for a new frame. So if you use get_ball_cord() and get_ballNbasket_cord(), it uses 3 separate framers, so instead of 60 fps, you get 20. You should fetch the frame once, and then process the data of that frame, not get a fresh frame every time.
now uses one frame for both.
https://github.com/ut-robotics/picr21-team-sauna-madis/blob/1f4b77ebae64bb29882fd5f36271e09f96811f76/saun/main.py#L159-L163
It would probably be better to have enum for game state and call state handlers based on the enum value.
Other option is to have some variable for active state handler:
Also
get_ball_cord
is called multiple times during each iteration. This can't be good for performance.