Skip to content

janelia-arduino/MouseJoystickController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MouseJoystickController

Library Information

Name
MouseJoystickController
Version
5.0.0
License
BSD
URL
https://github.com/janelia-arduino/MouseJoystickController
Author
Peter Polidoro
Email
[email protected]

Description

Modular device mouse joystick controller library.

API NAMES

{
  "id": "getApi",
  "result": {
    "ancestors": [
      "ModularServer",
      "ModularDeviceBase",
      "StepDirController",
      "StepperController",
      "StageController"
    ],
    "firmware": [
      {
        "name": "MouseJoystickController",
        "version": "5.0.1"
      }
    ],
    "verbosity": "NAMES",
    "functions": [
      "getSet",
      "clearSet",
      "getBlockCount",
      "addBlockToSet",
      "startAssay",
      "getAssayStatus",
      "moveJoystickToBasePosition",
      "moveJoystickToReachPosition",
      "activateLickport",
      "getTrialTimingData"
    ],
    "parameters": [
      "repeat_trial_count",
      "pull_torque",
      "lickport_reward_duration",
      "zero_torque_reward_delay",
      "reach_position",
      "lickport_activation_duration",
      "lickport_activation_count"
    ],
    "properties": [
      "homeCurrent",
      "idleCurrent",
      "basePosition",
      "pullThreshold",
      "pushThreshold",
      "joystickReadyToneFrequency",
      "joystickReadyToneDuration",
      "rewardToneFrequency",
      "rewardToneDuration",
      "toneVolume",
      "lickportRewardDelay",
      "trialTimeoutDuration",
      "repeatAbortedTrial",
      "repeatSetCount",
      "startTrialDuration",
      "waitUntilTrialTimingDataRead"
    ],
    "callbacks": [
      "startTrial",
      "abortTrial",
      "abortAssay",
      "restartAssay"
    ]
  }
}

API GENERAL

./api/

Assay

An assay consists of a series of trials, performed one after the other, until the assay is either completed successfully or is aborted.

The assay begins by calibrating each axis position by homing each axis to its home switch.

The joystick then moves to the base position and waits until a trial is started.

For each trial, the user sets the value for the joystick pull torque, the lickport reward duration, and the multiple axis joystick reach position.

When a trial is started, the joystick moves to the reach position and waits for the mouse to pull the joystick. The trial may be aborted by the user or it may be aborted automatically if the mouse pushes too far on the joystick or if the mouse waits longer than the trial timeout duration before pulling.

Trial

Three values are used for each trial, the pull_torque, the lickport_reward_duration, and the reach_position.

Block

A block is a group of identical trials, repeated repeat_trial_count times.

{
  "repeat_trial_count": 2,
  "pull_torque": 50,
  "lickport_reward_duration": 100,
  "zero_torque_reward_delay": 3,
  "reach_position": [
    20,
    200
  ]
}

Set

A set is a group of blocks, run one after another. The set is repeated repeatSetCount times.

[
  {
    "repeat_trial_count": 2,
    "pull_torque": 50,
    "lickport_reward_duration": 100,
    "zero_torque_reward_delay": 3,
    "reach_position": [
      20,
      200
    ]
  },
  {
    "repeat_trial_count": 3,
    "pull_torque": 75,
    "lickport_reward_duration": 120,
    "zero_torque_reward_delay": 3,
    "reach_position": [
      30,
      300
    ]
  }
]

Assay Status

{
  "state": "ASSAY_NOT_STARTED",
  "unread_trial_timing_data": false,
  "finished_trial_count": 0,
  "successful_trial_count": 0,
  "trial_aborted": false,
  "assay_aborted": false,
  "pull_threshold": -50,
  "set_in_assay": 0,
  "repeat_set_count": 2,
  "block_in_set": 0,
  "block_count": 1,
  "trial_in_block": 0,
  "block": {
    "repeat_trial_count": 2,
    "pull_torque": 50,
    "lickport_reward_duration": 100,
    "zero_torque_reward_delay": 3,
    "reach_position": [
      20,
      200
    ]
  }
}

Trial Timing Data

{
  "trial_start": 0,
  "mouse_ready": 0,
  "joystick_ready": 0,
  "pull": 0,
  "push": 0,
  "timeout": 0,
  "trial_abort": 0
}

Ancestors

https://github.com/janelia-arduino/ModularServer

https://github.com/janelia-arduino/ModularDeviceBase

https://github.com/janelia-arduino/StepDirController

https://github.com/janelia-arduino/StepperController

https://github.com/janelia-arduino/StageController

Clients

https://github.com/janelia-arduino/EncoderInterfaceSimple

https://github.com/janelia-arduino/PowerSwitchController

https://github.com/janelia-arduino/AudioController

Devices

https://github.com/janelia-modular-devices/modular_device_base

https://github.com/janelia-modular-devices/stepper_controller

https://github.com/janelia-modular-devices/encoder_interface_simple

https://github.com/janelia-modular-devices/power_switch_controller

https://github.com/janelia-modular-devices/audio_controller

More Detailed Modular Device Information

https://github.com/janelia-modular-devices/modular-devices

Installation Instructions

https://github.com/janelia-arduino/arduino-libraries

Development

Download this repository

https://github.com/janelia-arduino/MouseJoystickController.git

git clone https://github.com/janelia-arduino/MouseJoystickController.git

PlatformIO

Install PlatformIO Core

https://docs.platformio.org/en/latest/core/installation/index.html

python3 -m venv .venv
source .venv/bin/activate
pip install platformio
pio --version

99-platformio-udev.rules

Linux users have to install udev rules for PlatformIO supported boards/devices.

Download udev rules file to /etc/udev/rules.d

curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules

Restart udev management tool

sudo service udev restart

Add user to groups

sudo usermod -a -G dialout $USER
sudo usermod -a -G plugdev $USER

Remove modemmanager

sudo apt-get purge --auto-remove modemmanager

Compile the firmware

Gnu/Linux

make firmware

Other

pio run -e teensy35

Upload the firmware

Gnu/Linux

make upload

Other

pio run -e teensy35 -t upload

Serial Terminal Monitor

Gnu/Linux

make monitor

Other

pio device monitor --echo --eol=LF

About

Modular device mouse joystick controller library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published