obus/README.md

72 lines
3.8 KiB
Markdown
Raw Normal View History

2020-08-04 18:58:53 +00:00
# Ontmijnen van een Bom vereist Uitstekende Samenwerking
2020-08-24 13:16:09 +00:00
OBUS is a real-life version of the multiplayer game "Keep Talking And Nobody Explodes".
2020-08-04 18:58:53 +00:00
2020-08-24 13:16:09 +00:00
# Get started writing a module
1. [Install](https://www.arduino.cc/en/Guide/#install-the-arduino-desktop-ide) the Arduino IDE.
2. Clone this repository with Git in a permanent location on your drive.
3. Symlink the library: `ln -s /ABSOLUTE/PATH/TO/REPO/lib /PATH/TO/Arduino/libraries/obus`
2020-08-26 21:33:01 +00:00
(on most Linux distro's, this the Arduino folder is in `$HOME/Arduino`)
4. Follow [these steps](https://github.com/autowp/arduino-mcp2515/#software-usage) to install the CAN library
5. Execute `./src/new_module.sh` to create a new module
2020-08-24 13:16:09 +00:00
# Background
2020-08-04 18:58:53 +00:00
## Game
The game is played by at least two players. The goal is to defuse a bomb,
this is accomplished by defusing every module on that bomb before the bomb
timer runs out.
There are two roles:
2020-08-24 13:16:09 +00:00
- Expert: this person can read the manual about how to defuse the bomb, but cannot see nor interact with the bomb
2020-08-04 18:58:53 +00:00
- Defuser: this person can see and interact with the bomb, but cannot read the manual
2020-08-24 13:16:09 +00:00
These two roles can communicate with each other. To successfully defuse the bomb, they must
2020-08-04 18:58:53 +00:00
communicate efficiently and clearly. If a mistake is made, the team gets a strike.
If they get too many strikes, the bomb explodes, even if the timer hasn't run out yet.
## Implementation details
Now we want to implement this game in hardware. As in the computer version, we want this game to be modular:
it should be easy to 1) make new modules and 2) attach them to a bomb. To do this, we need to settle on
a protocol, both in hardware and in software.
The idea is to have one bomb controller that keeps track of the timer, the amount of strikes and of whether
2020-08-24 13:16:09 +00:00
the bomb has been successfully disarmed, and to have multiple modules that have one or more challenges on them
2020-08-04 18:58:53 +00:00
that need to be solved.
### Hardware
The bomb controller and modules have to be able to communicate with each other. Ideally, we would like a hardware bus where it is easy to add more modules. We would also like to minimise the amount of wires that are needed.
Multiple protocols were considered:
- I2C: very standard, most microcontrollers have this built in; unfortunately, limited in the amount of nodes that can connect to the same network (255), limited in distance between nodes (about 1 meter), and the bus needs 4 wires (GND, VCC and two data lines)
- SPI: needs even more wires, and requires a separate wire per module
- Serial: this is not a bus architecture, so a lot of wires will need to be used
But eventually, CAN was picked. CAN is widely used in vehicles and has several desired properties:
- We only need two wires (CAN uses a differential pair)
- Distance can be up to 500m
- There is built-in packet collision avoidance and per-node priorities
- CAN modules are very cheap
- There are existing Arduino libraries for the CAN module we'll be using
The payload of a CAN packet is 8 bytes long, this should be enough.
## Software
2020-08-24 13:16:09 +00:00
We needed to decide on a protocol to communicate between the bomb controller and the modules (and possibly also between modules?).
2020-08-04 18:58:53 +00:00
2020-08-24 13:16:09 +00:00
Some things we had to consider:
2020-08-04 18:58:53 +00:00
- payload is 8 bytes per packet
- packets can be delayed or not received on every node, so detection of this and retransmission might be needed: if the bomb interactor solves a module and the packet that communicates this with the bomb does not get delivered to the controller, the bomb will still go off, even if all modules have been solved
- we can't send an infinite amount of packets; the higher our bitrate is, the shorter our wires need to be
2020-08-10 17:34:45 +00:00
## Development setup
We use [this](https://github.com/autowp/arduino-mcp2515/) library for CAN communications. See [this](https://github.com/autowp/arduino-mcp2515/#software-usage) header for 3 simple steps on how to use it in the arduino IDE