RESTful API for controlling a table tennis ball thrower robot.
The robot consists of two motors: a feeder and a shooter. Each one is controlled by a separate python script that runs on a Raspberry Pi.
The shooter is a DC motor responsible for throwing the ball. The speed of the shooter determines the amount of spin generated in the ball.
The feeder consists of a stepper motor to which the feeder plate is attached. Its speed dictates how fast the ball reaches the shooter, thus determining the interval between each throw.
- Make sure you have npm installed.
- Download the project dependencies using
npm install
These instructions will get you a copy of the project up and running on your Raspberry Pi.
Just run npm run build
After the process, the files will be moved from the source (src
) folder to the distribution (dist
) folder and you should have a production-ready version of this project.
To start the HTTP server on port 3000, run npm start
If you would like to start the server automatically once the Raspberry Pi boots, add the following line at the beggining of the /etc/rc.local
file:
su pi -c 'node /home/pi/ball-thrower-server/dist/app.js < /dev/null &'
Note: replace /home/pi/ball-thrower-server
by another absolute path in case the ball-thrower-server
folder is located somewhere else.
To check if the server is up and running, send a GET request to /status
The server will respond with a 200 (OK) status in case it is running.
- To start the feeder motor, send a GET request to /feeder/start
- To change the speed of the feeder motor, send a GET request to /feeder/change-speed/SPEED where SPEED is one of the following:
l
(low speed)m
(medium speed)h
(high speed)
- To stop the feeder motor, send a GET request to /feeder/stop
- To start the shooter motor, send a GET request to /shooter/start
- To change the speed of the shooter motor, send a GET request to /shooter/change-speed/SPEED where SPEED is one of the following:
l
(low speed)m
(medium speed)h
(high speed)
- To stop the shooter motor, send a GET request to /shooter/stop
On this other repository you can find the source code for an app that interacts with the aforementioned API.
Feel free to contribute with corrections, optimizations, etc. There are no strict guidelines on how one should contribute.
This project is licensed under the MIT License - see the LICENSE file for details.