Robotcode  1.0
Experimental C++ code of the Motor Control Group
Author:
Joern Diedrichsen, Tobias Wiestler, Alexandra Reichenbach, Nick Roach, and Julius Klein
Date:
20/11/2011. Copyright 2009-2011 Institute of Cognitve Neuoscience. All rights reserved.

System requirements

  • Windows XP
  • Microsoft Visual C++ 6.0
  • Sensoray 626 IO card
  • Ideally two monitors (and a dual-head graphics card) for Experimenter and Subject display.

Introduction

This is the documentation for the experimental code for the motor control group at UCL. The code is written for fast developement of experiments under C++ and with time-sensitive control of robots or other external devices. Time sensitivity is achieved through a hardware interrupt from the Sensoray s626 card.

Class Structure

overview.jpg

Abstract classes

The file Experiment.cpp entails the definition of three abstract classes that define much of the default behavior of the experiment. For example that the program reacts to keyboard input from the user, reads target files that specify how a Block looks like, the running of a single trial, the recording of data, and the saving of data to disk.

  • Experiment: Contains the main functionality of interacting with the user, setting subject name, and running blocks
  • Block: Is a list of trials, usually read in from a target file.
  • Trial: The abstract class for a single trial. Your class MyTrial will contain the main behavior for your experiment

All you have to do is to define the behavior of your experiment by defining the classes MyExperiment, MyBlock, MyTrial, and DataRecord. All other things happen pretty automatically. Do NOT try to change these files - you should not have to (or talk to me if you have suggestions for improving). This html-documentation contains the doc for a typical robot experiment - Linepush5. This experiment implements reaching movements under channel movements, or force field movements to a point target, or to a redundant line target.

Device Classes

The device level contains classes for all kinds of different things that you would want to control. There are four classes that will be used by nearly all experiments.

  • S626sManager: A wrapper class that serves as API for communication with the s626 card. Allocates channels to other devices
  • Timer: Relies on one (or two) counters on the s626 card. Provides highly accurate timing information (better than windows at least!)
  • Screen: Class that deals with the screen presented to the participant. Uses OpenGL as a drawing commands. Scale and origin can be set flexibly
  • TextDisplay: Text display presented to the experimenter. This takes commands and from the keyboard and can display current status information

Depending on the experiment, you can then use the classes for optimal devices:

  • ManipulandumDR: Control for the 2-joint robots in QS17, B05.
  • ManipulandumMR: Control for the MRI-compatible robots
  • ManipulandumRed2D: Control for the Threedom robot in QS33, lab 1. Use with the simple handle end-device.
  • ManipulandumRed3D: Control for the Threedom robot in QS33, lab 1. Use with the wrist device.
  • StimulatorBox: fMRI-comaptible finger box with vibratory elements
  • TRCounter: TR Counter for MRI Experiments over serial port or s626 IO card
  • ...

Utility Classes

  • Vector2D: 2D-vector class
  • Matrix2D: 2x2 matrix class
  • DataManager: Class that holds N data records (per trial) and does memory allocation
  • KalmanFilter: Kalman filter for estimation of position and velocity on different channels

Directory structure

It is important that you respect the following directory structure Root-directory is typically c:/robot

source Contains all the common .cpp files. DO NOT MODIFY ANY OF THESE FILES! If you need to make changes, please make a copy to your local project directory. If you think you found a bug, or want to add a new feature, please contact Joern Diedrichsen (j.diedrichsen@ucl.ac.uk) to submit your changes. It is strongly recommended that instead of modifying the existing classes, you inherit the class functionality and make the changes in the derived class. This way you will stay up-to-date with the newest features and the debugged code.
include Contains all the common .h (header) files. DO NOT MODIFY ANY OF THESE FILES! See source for details
documentation Contains this documentation and the Doxygen config file
calib Contains calibration and configuration files for Manipulanda, s626card, etc. The parameters are read during the .init() function of each device. If you need to modify, please make a copy and reference that file.
project Folder for individual projects: Make your own subfolder with your unique project name. Your project folder will contain the following files and folders:
  • <MyProject>.cpp: Contains the source file for your experiment
  • <MyProject>.h: Contains the header file for your experiment
  • data: This is where *.mov and *.dat files are written
  • target: This is where the target files are kept

Making a new Project

It's easiest if you start from an exisiting project that is pretty close to what you want to do. Instead of copying the project, however, you should take the following steps

  • New->New Project
  • Choose win32 application (not console application)
  • give your project a name and create an empty project
  • copy the example project files (.cpp + .h) and rename them to <MyProject>.cpp
  • include all the .cpp listed in the Figure under source folder in the project
  • Go to c++ project settings in the example project and copy the settings to yours
  • Go to link project settings in the example project and copy the settings to yours
  • Compile and start modifying!