Python Turret Connector

Python Turret Connector

Features

Position

Shooting

Other

Guiding Principles

Safety

Use

Specification

Serial

Control Message (Pi → Arduino)

Error Message (Arduino → Pi)

Features

Position

Shooting

Other

Guiding Principles

Safety

The connector should be completely safe to use, as the Arduino code bears the responsibility of ensuring safe operation of the gun (servos do not go out of physical bounds, motors do not squish darts, minimize jerky motion, detect hardware malfunction or software halt, etc)

Use

Only one instance of the connector shall be allowed at one time. Each connector function queues a serial message, to be sent by a dedicated thread, and should execute without delay. If too many messages are queued, the process will error.

Gun Controller

The Gun Controller Arduino code runs a loop which updates state information and reads serial messages.

Specification

Serial

Control Message (Pi  Arduino)

Header

Operation Code

Argument

Footer

‘s’

(1 byte)

character

(1 byte)

number

(2 bytes)

‘e’

(1 byte)

Available operations

All 2-byte numerical arguments are valid and will be safely executed

Pan

p

uint16 pan location

Tilt

t

uint16 tilt location

Rev

r

uint8 speed

uint8 timeout (s)

Change velocity

v

int8 pan

int8 tilt

Fire

f

uint8 shot count

uint8 shooting frequency (dHz)

Heartbeat

h

uint16 timeout (ms)

Force stop

k

Status Message (Arduino → Pi)

Two types of messages are sent from the Arduino to the Pi. A w signifies that the Arduino is ready to receive instructions over serial. An x or i are sent in response to a critical error or invalid input message, respectively. Both of these prefixes are followed by a single line diagnostic message.

Access: turret.brianlevis.com picam.brianlevis.com