I use to do basketball training workouts regularly and I always track the sections statistics (number of shots, scores, misses, training time, etc). Track these numbers is kind of boring and hard to accomplish.
The smart balls can be used to this but they have some drawbacks:
- If you want to train with multiple balls you'll need to buy several (expensive) smart balls.
- The accuracy isn't so good.
- The durability of the ball.
The idea of this project is to use the Avnet SmartEdge device to prototype a solution to track all training facts.
Step 1: Avnet SmartEdge setupFirst of all it's necessary to setup the Avnet SmartEdge device. I followed the instructions described in the Hands-On with the SmartEdge Agile document:
- Open the box.
- Charge the device.
- Sign up to the Brainium portal.
- Install the Brainium gateway.
- Add the SmartEdge device to the Brainium portal.
All these steps are easy and they are fully described in the hands-on document.
Step 2: Brainium project creationIn the Brainium portal I created the project "Scoreboard" clicking in List of Projects item at the left menu and then in the Add Project button at the bottom right edge of the page.
In the Brainium portal I selected the "Scoreboard" project clicking in List of Projects item at the left menu and then clicking in the Scoreboard project. After that I clicked in the Create Widget button at the bottom right edge of the page and added the following widgets to the project:
- Visible lightness.
- Temperature.
- Atmospheric pressure.
- Air humidity.
- Acceleration (absolute value).
- Proximity distance.
This is my original basketball board that I regularly use to do basketball training workouts.
First I removed the plastic cover under the hoop and then I removed temporarily the hoop and the net.
Then I prepared a support to the SmartEdge device using some parts I have available and fixed it in the hoop.
Finally I fixed again the hoop and the net in the basketball board.
In the Brainium portal I selected the "Scoreboard" project clicking in List of Projects item at the left menu and then clicking in the Scoreboard projec. After that I clicked in the StartTracking button at the top left edge of the page and then in the Record Session button at the top left edge too. At this moment Brainium portal is tracking the SmartEdge device and recording all required sensors values.
Now... it's show time!
When the training session finished I just clicked in the End Session button to finish the recording. The sessions can be repeated as many times as you like and all the results can be accessed clicking in the RECORDED SESSIONS tab.
Step 6: Basketball workout data processingFirst of all I had to get the workout data from the Brainium portal and to make things more interesting I decided to use the REST api to download the record sessions.
I developed some Bash scripts to help with this task.
The first script is the show-recordings.sh (attached at the end of the project) which uses the recordings/api/find endpoint to search for all available recordings on the Scoreboard project in the Brainium portal and show their date/time/id information.
The second script is the get-recording.sh (attached at the end of the project) which uses the recordings/${recordingId} endpoint to get the recording URL of a specific recording Id and the wget command to download the recording file.
Finally I was able to process the workout session data stored at the recording file. All the information from the sensors of the SmartEdge device are in the recording_session.csv file in the CSV format, like the following example.
devicePublicId,dataSource,timestamp,scalar,vector
TO136-020210000100112A,HUMIDITY,1560712053812,51,
TO136-020210000100112A,ACCELERATION_NORM,1560712053219,9.831536293029785,
TO136-020210000100112A,PRESSURE,1560712053809,94928,
TO136-020210000100112A,PROXIMITY,1560712053221,200,
TO136-020210000100112A,HUMIDITY_TEMPERATURE,1560712053812,23.492218017578125,
TO136-020210000100112A,VISIBLE_SPECTRUM_LIGHTNESS,1560712053931,201,
...
Using Bash again I developed the scoreboard.sh script (attached at the end of the project) which reads the recording_session.csv file and process the sensors information in the following way:
- HUMIDITY, PRESSURE, TEMPERATURE and LIGHTNESS = Calculate the average of the values of each sensor.
- ACCELERATION = Count the number of shots based on the hoop movements.
- PROXIMITY = Count the number of the scores based on the ball presence.
The results were really good... but not perfect :-(
Actually, in the above recording session, it was made 40 shots and 32 of them were scored correctly (8 were missed). In other words, the SmartEdge device was able to recognize correctly 100% of the shots (40) but it just was able to detect 81% of the 32 scored shots (26).
Step 7: Final considerations- The SmartEdge device and the Brainium portal are very simple to setup/use and it was proved to be an excellent solution for really quick prototype development.
- The SmartEdge device comes with a lot of sensors available.
- The Brainium portal has a lot of great features and the API access is easy to use and very useful.
- The proximity sensor was not able to identify correctly the presence of the ball probably due to the interference caused by the sun light.
Based in this project results I successfully developed the Smart basketball scoreboard project which proposed a definitive solution for this task.
It's really worth to take a look.
Have fun...
Comments