Skip to content

codedragon/goBananas

Repository files navigation

Contents:

Main program:
goBananas:      Main program. Move around field, run into bananas for reward.

Training programs:
crossTraining:  Probably will never be used. Training that involves the crosshair only, no banana.
                Must just touch the joystick for a reward, crosshair then changes from white to red.
                Incomplete.
trainingBananas Training program for teaching monkeys to use a joystick. Progresses through multiple
                levels with small, incremental changes. Not using Pandaepl.

Secondary programs:
bananas         Provides the bananas for gobananas
config          Configuration file for gobananas
cross_config    Configuration file for crossTraining
giz_config      Configuration file for Giuseppe for gobananas
joystick        Interface with joystick/PyGame for TrainingBananas
LICENSE
load_models     Loads a PlaceModel object that contains information on models that we might use
moBananas       Functions for determining random placement of bananas, ensures they are not too
                close to one another or to another position specified by the user
myEggToBam      includes functions to convert either a single file or a directory of egg files
                into bam files for use with Panda3D.
Notes           Mostly notes to myself about problems I've run into or stuff to do
README
testing_config  Config for goBananas for playing around with
train_config    Config for trainingBananas

Tests:
test_crossTraining  fails
test_goBananas  Most ridiculous testing ever. The only way I could figure out how to do any testing
                with the PandaEPL package was to actually run the game and have someone interact with
                it to test stuff. Tests should all pass, but take a long time, have to pay attention
                to which test is running, and actually play the game for varying lengths of time. Ugh!

test_joystick   not a unittest. Plots how joystick movement is interpreted in Panda3D. Useful for
                testing and troubleshooting joystick hardware issues.

test_js_pandaepl  An unsuccessful attempt to try to get to the bottom of an intermittent problem we
                were having with joysticks when using pandaepl

* test_moBananas  Unittests for moBananas.
* test_trainingBananas  Unittests for trainingBananas. Running the bash script goes through all of the
                tests

* These tests are well-behaved and should be included in a pre-commit hook.

Directories:
data            Will be created by program(s)
models          Currently not in git, but required to run


Dependencies from external libraries:
1) recent version of Python 2.x
2) Panda3D
3) PandaEPL
for joystick:
4) Pygame
for getting/receiving data from National Instrument card:
5) PyDAQmx
6) pydaq - my repository for interfacing with PyDAQmx library


We use National Instruments card (NiDAQ): ni pci-6221

On the Windows machine used for actual experiments, we are running:
Python 2.7.3, installed by Panda3d, and located in the Panda3d folder
Panda3d 1.8.1 located in c:\Panda3D-1.8.1
PandaEPL 0.9 is also located in Panda3d folder in python/lib/site-packages/pandaepl
Pygame 1.9.1 (joystick support) also in python/lib/site-packages/
PyDAQmx PyDAQmx-1.2.5.2-py2.7 (National Instrument board support)
          also in python/lib/site-packages/

On my Mac (OS 10.7.5), I am running for testing purposes:
Python 2.7.2 system python -> use arch -i386 ppython
Panda3d 1.8.1 is installed in /Developer/Panda3d
PandEPL 0.9 is installed in /Library/Python/2.7/site-packages/pandaepl
 (see below for fix for deprecation warning in pandaEPL)



Start the game:
ppython goBananas.py --no-eeg --resolution=1280x1024 -sTest
use --no-fs for small window

crossTraining:
white cross on screen. touch joystick cross turns red, and get reward.
also available, but prefer not to use because normally crosshair would never be anywhere but center:
basic idea for starting: cross is off-center, move to center. (learn moving joystick moves crosshair)

trainingBananas:
crosshair in center, banana off center, move crosshair to banana (learn to associate destination with banana)

trainBananas is a version I made with PandaEPL, but joystick implementation is problematic.

Codes for goBananas plexon/blackrock:
200 ran into banana
201 given reward
1000 + trial number new trial
after trial numbers, x and y positions for each banana
300 repeated trial, next signal will be which trial number is the current repeat
400 next signal will be x and y position of weighted center


Config file training variable:

1.x = Left-Right Training.  No background.  Crosshairs in center of screen, and banana appears on left or right of crosshairs.  Subject has to push joystick to right or left to align the crosshairs with the banana.  Once the crosshairs hit the banana, the position is locked in place until all the reward is dispensed.  Then the tasks restarts with the banana in a new random location.
* 1.1 = Left only. [Perhaps need to add a variable to control max distance, and vary within that.  That's what increaseDistance and decreaseDistance should do.]
* 1.2 = Right only. [Perhaps need to add a variable to control max distance, and vary within that.  That's what increaseDistance and decreaseDistance should do.]
* 1.3 = Both, randomized location and distance.

2.x = Continuation of the left-right training in 1.x.  When the crosshairs align wih the target, some reward is dispensed, but the positions don't lock in and the crosshairs are allowed to leave the target, at which point reward stops being dispensed, until the crosshairs and target are aligned again.  The goal is to get the animal to leave the crosshairs 
* 2.1 = The window within which the crosshair has to fall is fairly large

3.x = Introducing forward movement. 
* 3.1 = Start out with banana centered, just go forward to get reward.
* 3.2 = Left-right to banana, with crosshairs on it, then go forward to get rewarded again. Forward movement is blocked until crosshair turns blue.  When crosshairs hit banana, further turning is blocked. Only forward movement is allowed.
* 3.3 = Require him to stop on his own on the banana.  As soon as he moves forward a bit, left and right turning is blocked, only more forward movement is allowed.    He is rewarded up to 6 beeps at a time for turning until the crosshairs are blue, and then he can only get more reward by actually going up to the banana.

4.x = Introducing the environment. 
* 4.0 = Starts off the same place as 3.3. Except the background is present and there is a massive, and very dense fog over it.  Press F to remove the fog and eluminate the environment/backround little by little.
* 4.1 = Remove the block for turning after he moves forward.
* 4.2 = Allow forward movement even when he's not with a blue cross.
* 4.25 = Remove FOV rays blocking turning.
* 4.3 = At beginning of new trial, face same direction as end of previous one. FOV rays blocking turning still on.
* 4.35 = Remove FOV rays blocking turning from 4.3.

5.x = More bananas come in.
* 5.1 = Same as 4.25, except now there are multiple bananas that he has to go around and pick up.  Position resets to the center and faces the original 0-header position after gathering each batch of bananas.
* 5.2 = A given number of bananas appear on the field and you have to go gather them all, then a new set appears.  Position doesn't reset, neither does header direction.

PandaEPL Bugs and Warnings:

esc-d debug doesn't work?

Bug in joystick implementation:
Add the word float in line 85, Joystick.py:
change:
self.threshold = Options.getInstance().get().js_zero_threshold
to:
self.threshold = float(Options.getInstance().get().js_zero_threshold)
otherwise the threshold option will not work.

comment out loading joystick calibration in common.py, is buggy, and does nothing.
(comment out all 3 lines, no sense loading if not calibrating)

In the following files, line numbers, delete the .asList() part. For example in
ModelBase.py, line 60
change:
for nodePath in self.retrNodePath().findAllMatches("**/" + str(tag) + "/**").asList():
to:
for nodePath in self.retrNodePath().findAllMatches("**/" + str(tag) + "/**"):
Vr.py, line 206
VrObject.py, line 86

Panda3d updated getTightBounds so it returns None instead of
(Point3(0, 0), Point3(0, 0)) when the node is empty.

http://www.panda3d.org/forums/viewtopic.php?t=16865&p=97925

So, edit Text.py, to add an if statement, starting line 159
now will read:

bounds    = self.retrNodePath().getTightBounds()
if bounds is None:
    bounds = (Point3(0, 0), Point3(0, 0))
self.firstLineHeight = bounds[1][2]-bounds[0][2]

From Jonathan:

Vr.py within the function simulateWalkingMotion() - if you are using simulateCarMotion(), the bug may still exist, but the fix should be similar.

The changes come near the end of the function, which, if I'm looking at the correct version of the code, should begin around line 770. New code is below, with the changes highlighted. All I'm doing is checking if the direction of turning has changed as a result of the friction, which shouldn't be allowed to happen and could cause you to move back and forth. The same change could (should?) also be applied to the speed.

# If speed is negligible, clamp it to zero.
            if not self.inputEvents.has_key('turnLeft') and \
               not self.inputEvents.has_key('turnRight') and \
                abs(newTurningSpeed) < 0.1:
                newTurningSpeed = 0
                avatar.setTurningSpeed(0) # may not be necessary
                avatar.setTurningAccel(0)


            # Simulate some friction.
            if newLinearSpeed > 0:
                newLinearSpeed = newLinearSpeed \
                                 - dt*config['linearAcceleration']*config['friction']
            elif newLinearSpeed < 0:
                newLinearSpeed = newLinearSpeed \
                                 + dt*config['linearAcceleration']*config['friction']

            if self.inputEvents.has_key('turnLeft') or self.inputEvents.has_key('turnRight'):
                turningFriction = config['friction']
            else:
                turningFriction = config['friction']*3
            if newTurningSpeed > 0:
                newTurningSpeed = newTurningSpeed \
                                  - dt*config['turningAcceleration']*turningFriction
                if newTurningSpeed < 0:
                    newTurningSpeed = 0
            elif newTurningSpeed < 0:
                newTurningSpeed = newTurningSpeed \
                                  + dt*config['turningAcceleration']*turningFriction
                if newTurningSpeed > 0:
                    newTurningSpeed = 0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published