Sunday, November 13, 2011

NRG to ISO

Assuming the NRG is just a single session ISO CD image, you can just remove the first few kb with dd from Terminal.app
Code:

dd if=image.nrg of=cdrom.iso bs=512 skip=600

Friday, November 11, 2011

Game states

final int STATE_XBEE_INIT = 0;
final int STATE_PLAYER_LIST = 1;
final int STATE_LEVEL_SELECT = 2;
final int STATE_PLAY = 3;
final int STATE_HIGHSCORE = 4;

Lag test

else if (mode == 2) {
println("We can test the lag now.");
players[0].xpansProx[0].broadcastProxConfig(1500);
mode++;
}
else {// done
initLevel(players, "levels/03-nomoremosquitos.xml");
for (int s=4; s<8; s++) { // Send an arbitrary step to the patches
println("Sending step "+s+" at time "+millis());
for (int i=0; i players[i].sendStep(s);
delay(500);
}
}
}

Shut off buzzing by hand, for player 1

// shut off glove buzzer
players[0].xpansVibe[0].broadcastVibe(0);
// shut off patch buzzer
Step shutoff = new Step(false, false, false, false, false);
players[0].xpansProx[0].broadcastStep(0, shutoff, shutoff, shutoff, shutoff);

for player 2, just do it for players[1]

Tuesday, November 8, 2011

PANs

Player 1 PANs:

1001: two proximity sensors, one base -- bidirectional.
Node Identifier: P1_PROX1
base ID: 0
end device IDs: 1, 2

1002: two proximity sensors, one base -- bidirectional.
Node Identifier: P1_PROX2
base ID: 0
end device IDs: 3, 4

1003: two vibes, one base
Node Identifier: P1_VIBE
base ID: 0
end device IDs: 5, 6

1004: two accelerometers, one base -- incoming only.
Node Identifier: P1_ACCEL
base ID: 0
end device IDs: 7, 8

Player 2 PANs:

2001: two proximity sensors, one base -- bidirectional.
Node Identifier: P2_PROX1
base ID: 0
end device IDs: 9, 10

2002: two proximity sensors, one base -- bidirectional.
Node Identifier: P2_PROX2
base ID: 0
end device IDs: 11, 12

2003: two vibes, one base
Node Identifier: P2_VIBE
base ID: 0
end device IDs: 13, 14

2004: two accelerometers, one base -- incoming only.
Node Identifier: P2_ACCEL
base ID: 0
end device IDs: 15, 16

One bottleneck is the baud rate between the base Xbee and the computer. This should be cranked up to 115200. The baud rate between the arduinos and the endpoint Xbees can remain at 9600.

Data packets for xbees

Message/Packet types:
1: from base to proximity patches telling them it’s the beginning of a turn. [5 BYTES]
2: from prox. patches to base providing sensor readings. [6 BYTES]
3: from base to gloves telling them what intensity to vibrate. [2 BYTES]
4: from accelerometer anklets to base providing sensor readings. [5 BYTES]
5: Config. from base to proximity patches. [3 BYTES]
6: Ack. of configuration messages, send from prox. patches to base in response to config. [4 BYTES]
7: Messages from gloves to base, for button presses on gloves, UI control. [3 BYTES]

More Info about Packets

2fake: data simulation packet outgoing of patch:
“sent” approximately every 50 ms, with a small percentage of dropped packets:
time (ms)
player #: 0 or 1
patch #: 0-3
touched: 0-1
prox: 0-1028

4fake: data simulation packet outgoing of accelerometer:
set every 50 ms, with a small percentage of dropped packets:
player#
patch#
accel: 1-255

2real: real packet outgoing of patch
sent by patch arduino software
every 50 ms
highest prox reading of interval

7real: real packet outgoing of patch: button press

4real: real packet outgoing of accelerometer
sent by anklet arduino software
every 50 ms
highest accel. reading of interval

Packet structure
Packet structures, by byte:

Type #1: Base to Prox
0: Packet type
1: Step number (high order bits)
2: Step number (low order bits)
3: patches active this turn (4 bits) and patches active next turn (4 bits) - patch is active or not: 1 or 0
4: patches active two turns from now (4 bits) and patches active 3 turns from now (4 bits)

Type #2: Prox to Base
0: Message Type
1: Patch Address (7 bits, expect 1-4, 9-12) | touched (1 bit)
2: Step number (high order bits)
3: Step number (low order bits)
4: Proximity reading (high order bits)
5: Proximity reading (low order bits)

Type #3: Base to Gloves
0: Message Type
1: Vibe intensity (higher -> more vibration)

Type #4: Accel to Base
0: Message type
1: Patch Address (expect 7-8, 15-16)
2: X axis reading
3: Y axis reading
4: Z axis reading

Type #5: Config, base to prox
0: Message Type
1: Length of step (high order bits) - tells the patches how long each “step” will be during this level
2: Length of step (low order bits)

Type #7: Glove to Base
0: Message Type
1: Patch address (expect 5-6, 13-14)
2: Which button was touched

Button touch data is an int encoded thus:
0: no touch, or ambiguous touch that we shouldn’t react to
1: left button ONLY was touched
2: right button ONLY was touched
3: center button ONLY was touched
4: all three buttons were touched