Slingshot robot game for two players

gigabrain.io

Install Instructions

GigaBrain Install

GigaBrain Thingiverse Thingiverse 3d printable parts for Robot Slingshot game for two players

GigaBrain Two player game is run with Java and sends PWM control signals to Raspberry PI pins. Currently tested versions Raspberry PI 3 B V1.2 model. Raspbian 4.9 Please test with your Raspberry device and send feedback to gigabrain@tuta.io

How to setup the two player game ?

                  3D Print yourself the parts. Follow the printing instructions 
                  You will also need:
                  - Raspberry Pi
                  - Two of 9g micro servos
                  - 3mm / 4mm / 5mm Neodyum magnet balls if you want extra weight for the cannon balls
                  - 3d Printer and PLA material
			 	  
Build a robot game with your Raspberry Pi and play with your Mobile phone, battling with two players using your favorite slingshot ammo to shoot off crates and count points. The game works with a Raspberry Pi and a Mobile phone, Pad or any touch screen.

Play instructions:

- Each player starts with 1p resource that they place in front of their own slingshot on top of the tower
- Each player on their turn draws the sling and releases it, trying to hit the opponents resources. Before the turn place a new resource on your playing field, according to the game image
- End of each throw count amount of resources that have fallen to ground on opponents field and add to your points
Points:

Corn, Barrel 1p
Leaf, Flour 2p
Gold crate 3p

Assembly: Print all parts, connect the spiral sling with a 9g micro servo, add additional screw to hold the servo better. Slide the servo inside the servo holder with the wire upwards. Adjust the servo when the servo is in middle position the sling cup is balanced horizontally.

Add 3mm / 4mm / 5mm Neodymium magnet balls if you want extra weight for the cannon balls.
                  

How to install manually ?

Manually install - Download newest version blocks-0.4.1-RELEASE.jar
Install the PiBlaster from https://github.com/sarfata/pi-blaster
Setup two Micro Servos: Control YELLOW/WHITE to Raspberry Pi Pins: Physical GPIO#11 (BCM17 / GPIO17) and Physical GPIO #12 (BCM18 / GPIO18)
And the servos + RED wire to +5 and - BLACK wire to Ground
No not attach any other GPIO pins, PiBlaster sets the following default pins to output mode 4,17,18,27,21,22,23,24,25


You can see different board references here 
You may use different boards as long as you can setup the pins according to PiBlaster configuration

PiBlaster by default has 9 output GPIO pins 4,17,18,27,21,22,23,24,25 and the default PWM output is 100Hz 
The 100 Hz is tested using one GPIO pin with an oscilloscope. When running multiple pins simultaneously the Hz value fluctuates.
If you are running with Pi Blaster make sure that you do not use any GPIO pins for input devices.
The reserved GPIO pins for output are 4,17,18,27,21,22,23,24,25
Note that you have to restart the Raspberry Pi Raspbian or restart the operating system or 
click on the interface "Bye" button to release the output GPIO pins for other use. 
Do not attach any input sensors or other devices to these output reserved GPIO pins
unless you have restarted the Raspberry Pi.
You can also release the PiBlaster pin by calling release for the pin number from command line:
echo "release 4" > /dev/pi-blaster
echo "release 17" > /dev/pi-blaster
echo "release 18" > /dev/pi-blaster
echo "release 27" > /dev/pi-blaster
echo "release 21" > /dev/pi-blaster
echo "release 22" > /dev/pi-blaster
echo "release 23" > /dev/pi-blaster
echo "release 24" > /dev/pi-blaster
echo "release 25" > /dev/pi-blaster

How to run the game with PiBlaster ?

The configuration parameters for PiBlaster pins:
CONTROLLING_ENABLE_PIBLASTER = Boolean (true or false) Turn on Raspberry Pi PiBlaster configuration
CONTROLLING_PIBLASTER_OUTPUT_TAGS = String separated with , List the hashtags that are mapped to pins in the same order as PINS
CONTROLLING_PIBLASTER_OUTPUT_PINS = String separated with , List the pin numbers that are mapped to output GPIO ports in the same order as TAGS
CONTROLLING_USERNAME = String User username
CONTROLLING_PASSWORD = String User BCrypted password 

Run command:
java -jar /home/pi/gigabrain/blocks/blocks-0.4.1-RELEASE.jar --CONTROLLING_ENABLE_PIBLASTER=true --CONTROLLING_PIBLASTER_OUTPUT_TAGS=p1,p2 --CONTROLLING_PIBLASTER_OUTPUT_PINS=17,18 --CONTROLLING_USERNAME=john --CONTROLLING_PASSWORD='{bcrypt}$2a$10$AkKVjmFjr.eTCxiUK5XGr.iD/lFSfs64gU7LhcNz2NbOVAKh0Zp6i' > /home/pi/gigabrain/blocks/logs/blocks.log 2>&1 &

How to run the game with PCA9685 board ?

Connect the PCA9685 board to Raspberry Pi with these instructions. Note that you are required to have an additional power source for the servos. With the configuration you can change the PCA9685 pin numbers, in the run command below there is pin 0 for player 1 and pin 1 for player 2.

Adafruit Raspberry Pi PCA9685 instructions

Enable the I2C to connect with the PCA9685 board

Enable I2C on Raspberry Pi
The configuration parameters for PCA9685 pins:
CONTROLLING_ENABLE_PCA9685 = Boolean (true or false) Turn on Raspberry Pi PCA9685 I2C port configuration
CONTROLLING_PCA9685_OUTPUT_TAGS = String separated with , List the hashtags that are mapped to pins in the same order as PINS
CONTROLLING_PCA9685_OUTPUT_PINS = String separated with , List the pin numbers that are mapped to PCA9685 pins (0-15) in the same order as TAGS. The default I2C bus is 1 and address is 40.
CONTROLLING_USERNAME = String User username
CONTROLLING_PASSWORD = String User BCrypted password 

Run command:
java -jar /home/pi/gigabrain/blocks/blocks-0.4.1-RELEASE.jar --CONTROLLING_ENABLE_PCA9685=true --CONTROLLING_PCA9685_OUTPUT_TAGS=p1,p2 --CONTROLLING_PCA9685_OUTPUT_PINS=0,1 --CONTROLLING_USERNAME=john --CONTROLLING_PASSWORD='{bcrypt}$2a$10$AkKVjmFjr.eTCxiUK5XGr.iD/lFSfs64gU7LhcNz2NbOVAKh0Zp6i' > /home/pi/gigabrain/blocks/logs/blocks.log 2>&1 &

How to Generate a BCrypt password hash ?

Create a BCrypted password manually
	in Command line see reference BCrypt Hash from command line
	in browser JavaScript Browserling Javascript BCrypt tool
	Notice that Browserling uses a local JavaScript BCrypt script
	BCrypt JavaScript library
and add a {bcrypt} in front of the property eg. --CONTROLLING_USERNAME=john --CONTROLLING_PASSWORD='{bcrypt}$2a$04$dl...' In the above run command example username is john and password is "hello"

How the application security is implemented ?

The security is implemented using standard Spring Security libraries to ensure the security and stability of the application.

How to install with a script ?


wget http://gigabrain.io/blocks/GigaBrainBlocksInstallStandalone.sh -O ~/GigaBrainBlocksInstallStandalone.sh
chmod +x ~/GigaBrainBlocksInstallStandalone.sh
~/GigaBrainBlocksInstallStandalone.sh

Open issues

Resolved issues

Version: blocks-0.4.1-RELEASE Added timeout reset call after the movement in 3s, added controller shutdown after 5 minutes. Added Pin and other resource reset and releases after the shutdown. Changed the port number to 5800.

The wiringPi needs rights to GPIO access, the install script uses sudo rights to start the Spring boot application. WiringPi/Pi4J without sudo in Spring Boot Resolved by using PiBlaster to send control signals to GPIO pins

Before downloading you can read the installation script here

Install script

The script creates folder gigabrain in your home folder and downloads the GigaBrain Standalone version and creates a script for running the service. The log files are created in logs folder. You can launch the Standalone version with script start.sh Connect your Raspberry Pi and a Mobile phone to a Wifi network and open the Raspberry Pi IP address with the Mobile phone browser. The service runs in a port 5800, open up a web browser to your Raspberry Pi IP address: http://RPI_IPADDRESS:5800 or Open a browser in Raspberry Pi and go to localhost:5800

How to use GigaBrain ?

Make sure that you have Raspbian 4.9 installed on your SD card Install the newest Raspbian official installation

Share the Wifi hotspot with iPhone or iPad, Android phone or tablet, PC with a touch screen and after that connect your Raspberry Pi to the same Wifi with your mobile phone

You can also connect your touch screen and Raspberry Pi with the same Wifi hotspot device, as long as the devices see each others IP addresses.

One option also is to create a Wifi hotspot with your Raspberry Pi and connect your mobile device to that Wifi. This is an advanced option

Find the IP address of your Raspberry Pi with Command line command: host raspberrypi

Install GigaBrain to your Raspberry Pi and setup the device. If you are running with Pi Blaster make sure that you do not use any GPIO pins for input devices. The reserved GPIO pins for output are 4,17,18,27,21,22,23,24,25

Open up the browser from your mobile phone and type the address for example: http://192.0.1.23:5800 Make sure that the port number :5800 is added after the IP address of your Raspberry Pi

Log in with the same username and password that you installed GigaBrain with and start your show!

Stop the application with the interface "Bye" button or restart your Raspberry Pi Operating system before using any input pins for other devices.