Class Motor

java.lang.Object
  |
  +--Motor

public class Motor
extends java.lang.Object

Author:
Erhan Oztop, 2001-2002

Source code by Erhan Oztop (erhan@atr.co.jp)
Copyright August 2002 via
University of Southern California Ph.D. publication copyright

Field Summary
(package private)  PCode affordance
           
static int callback_Finger
           
static int callback_Input
           
static int callback_Offset
           
static int callback_Thumb
           
static int callback_Wrist
           
(package private) static boolean CLAMPOFF
           
(package private) static boolean CLAMPON
           
(package private)  double colW_VAR
           
(package private) static int DLEV
           
(package private)  double eta
           
(package private)  double eta01
           
(package private)  double eta02
           
(package private)  double eta03
           
(package private)  double eta12
           
(package private)  double eta13
           
(package private)  double eta23
           
(package private)  PCode finger_force
           
(package private)  int finger_FORCE_code_len
           
(package private) static double finger_FORCE_offset
           
(package private)  int finger_force_pick
           
(package private) static double finger_FORCE_scale
           
(package private)  double[] forcevalue
           
(package private) static double GVAR
           
(package private)  int hand_locMER_code_len
           
(package private) static double hand_locMER_offset
           
(package private) static double hand_locMER_scale
           
(package private)  int hand_locPAR_code_len
           
(package private) static double hand_locPAR_offset
           
(package private) static double hand_locPAR_scale
           
(package private)  int hand_locRAD_code_len
           
(package private) static double hand_locRAD_offset
           
(package private) static double hand_locRAD_scale
           
(package private)  PCode hand_off
           
(package private)  int hand_off_pick
           
(package private)  PCode hand_rot
           
(package private)  int hand_rot_pick
           
(package private)  int hand_rotBANK_code_len
           
(package private) static double hand_rotBANK_offset
           
(package private) static double hand_rotBANK_scale
           
(package private)  int hand_rotHEADING_code_len
           
(package private) static double hand_rotHEADING_offset
           
(package private) static double hand_rotHEADING_scale
           
(package private)  int hand_rotPITCH_code_len
           
(package private) static double hand_rotPITCH_offset
           
(package private) static double hand_rotPITCH_scale
           
(package private)  int index_FORCE_code_len
           
(package private) static double index_FORCE_offset
           
(package private) static double index_FORCE_scale
           
(package private)  int inix
           
(package private)  double[] input0
           
(package private)  double[] input0_p
           
(package private)  int input0_s
           
 double lastmer
           
 double lastpar
           
(package private)  double lasttilt_deg
           
(package private)  boolean looped
           
 double max_value_after_softmax
           
(package private) static int MAXREW3HIST
           
(package private)  int obj_axisMER_code_len
           
(package private) static double obj_axisMER_offset
           
(package private) static double obj_axisMER_scale
           
(package private)  int obj_axisPAR_code_len
           
(package private) static double obj_axisPAR_offset
           
(package private) static double obj_axisPAR_scale
           
(package private)  int obj_axisRAD_code_len
           
(package private) static double obj_axisRAD_offset
           
(package private) static double obj_axisRAD_scale
           
(package private)  PCode obj_loc
           
(package private)  int obj_locMER_code_len
           
(package private) static double obj_locMER_offset
           
(package private) static double obj_locMER_scale
           
(package private)  int obj_locPAR_code_len
           
(package private) static double obj_locPAR_offset
           
(package private) static double obj_locPAR_scale
           
(package private)  int obj_locRAD_code_len
           
(package private) static double obj_locRAD_offset
           
(package private) static double obj_locRAD_scale
           
(package private)  java.lang.String[] obj_name
           
(package private)  PCode obj_ori
           
(package private)  int obj_size_code_len
           
(package private)  int obj_type_code_len
           
(package private)  double[] offvalue
           
(package private)  double[] output0
           
(package private)  double[] output0_p
           
 int passc
           
(package private)  double PDFthreshold
           
(package private) static int plotKey
           
(package private) static int plotLabel
           
(package private) static int PLOTLEV
           
(package private)  int rew3_c
           
(package private)  double[] rew3_hist
           
(package private)  int rotix
           
(package private)  double[] rotvalue
           
(package private) static double softVAR
           
(package private)  int thumb_FORCE_code_len
           
(package private) static double thumb_FORCE_offset
           
(package private) static double thumb_FORCE_scale
           
(package private)  double unitBias
           
(package private)  double[][] W_01
           
(package private)  double[][] W_02
           
(package private)  double[][] W_03
           
(package private)  double[][] W_13
           
(package private)  double[][] W_23
           
(package private)  double WTA_ERR
           
 
Constructor Summary
Motor()
           
 
Method Summary
 void addto(double[][] M, int im, int jm, double[][] C)
           
 void advancePass()
           
 void avgsoftmax(double[] v, int size, double[] r)
          Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5.
 void col_normalizeWeight(double[][] w, int col)
          Normalize over the columns.
static Point3d convert(int callbackID, double x, double y, double z)
          The convert family is used to scaling and translating the 0..1 firing of units to actual values.
static Point3d convertFinger(double a0, double a1, double a2)
           
static Point3d convertInput_Loc(double[] pv)
           
static Point3d convertInput(double[] pv)
           
static Point3d convertInput(double a0, double a1, double a2)
           
static Point3d convertOffset(double a0, double a1, double a2)
           
static Point3d convertThumb(double a0, double a1, double a2)
           
static Point3d convertWrist(double a0, double a1, double a2)
           
private  void createPopulations()
           
private  void createWeights()
          Creates the weight matrices.
 void decayWeight(double[] w, double rate)
          Decayin weight
 boolean doneRotGen()
           
private  void dprint(int level, java.lang.String s)
           
private  void dprint(java.lang.String s)
           
private  void dprintln(int level, java.lang.String s)
           
private  void dprintln(java.lang.String s)
           
 void dumpNet(java.lang.String suffix)
           
 void dumpNet(java.lang.String prefix, java.lang.String suffix)
           
 void dumpNet(java.lang.String prefix, java.lang.String suffix, java.lang.String us)
           
 double[][] fixedWeight(int rows, int cols, double v)
           
 double[] flatten(double[][] M)
           
 void forwardNoisyPass(int startlevel, double n1, double n2, double n3, MotorPlan m)
          startlevel 1: full forward pass 2: don't update hand offset 3: don't update hand offset and FINGERS 4: do nothing :)
 void forwardPass(int startlevel)
          startlevel 1: full forward pass 2: don't update hand offset 3: don't update hand offset and FINGERS 4: do nothing :)
 java.lang.String getGplotCommand(int callbackID)
           
 java.lang.String getTempPrefix(int callbackID)
           
 void hardcoresoftmax(double[] v, int size, double[] r)
          Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5.
 int[] inconvertInput_hack(Hand h, Point3d pp)
           
 double[] inconvertInput_Loc(Hand h, Point3d pp)
           
 double[] inconvertInput(Hand h, Point3d pp)
           
static Point3d inconvertOffset(MotorPlan mp)
           
static Point3d inconvertWrist(MotorPlan mp)
           
 void initBabble()
           
 void internalPass(int N, int K, int Kok)
           
 void loadNet(java.lang.String suffix)
           
 void loadNet(java.lang.String prefix, java.lang.String suffix)
           
static void main(java.lang.String[] argv)
           
static Point3d map2xy(int callbackID, Point3d p, double Z)
           
 void maxsoftmax(double[] v, int size, double[] r)
           
 void multiply(double[][] M, double[] v, int im, int jm, double[] r)
           
 void net3()
           
 double[] nextInput()
           
 MotorPlan nextMotorPlan(Hand h, Object3d obj)
           
 MotorPlan nextNoisyMotorPlan(Hand h, Object3d obj, double n1, double n2, double n3)
           
 Point3d nextRandomInput()
           
 void normalizeWeight(double[] w)
          Max component comes 1 the rest scaled accordinglym
 void normalizeWeight2(double[] w)
          Weight vector becomes unit length in ^2 norm
 void normalizeWeight2D(double[][] w)
           
 int pick_my_NoisyPDF(double[] pdf, int size, double chance)
           
 int pick_my_PDF(double[] pdf, int size)
           
 int pick_WTA(double[] pdf, int size)
           
 int pickNoisyPDF(double[] pdf, int size, double chance)
           
 void pickNoisyRotation(MotorPlan m, double chance)
           
 void pickOrdRotation(MotorPlan m)
          modify wrist rotation part of the motor plan in an ordered fashion, In each call next preferred value is returned.
 int pickPDF(double[] pdf, int size)
           
 void pickRotation(MotorPlan m)
           
 double[][] randomWeight(int rows, int cols, double scale)
           
 void realnormalizedsoftmax(double[] v, int size, double[] r)
          Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5.
 void reinforce(double R, int level)
          level 1: hand offset level 2: finger force level 3: hand rot level.
 void reinforceAll(double reward, MotorPlan mp)
           
 void reinforceOff(double reward)
           
 void reinforceRot_Off(double reward)
           
 void reinforceRot(double reward)
           
 void resetInputSeq()
           
 void resetRotGen()
           
 void safe_pickRotation(MotorPlan m)
           
 void setParameters()
           
 void showSomething()
           
 void sigsoftmax(double[] v, int size, double[] r)
           
 void softmax_colW(double[][] v, double[][] r, int col)
           
 void softmax(double[] v, int size, double[] r)
           
 void softmaxW(double[] v, int size, double[] r, double V)
           
 void squash(double[] v, int size, double[] r)
          we are using G(x)= 1/(1+exp(-2bX)) with b=0.5.
 void updateInputLayer_Loc(Hand h, Graspable obj)
           
 void updateInputLayer(Hand h, Graspable obj)
           
 void updateObjectAxis(Point3d p)
           
 void updateObjectLocation(Point3d p)
           
 void updateResourcePars()
           
 void updateWristLayer()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DLEV

static int DLEV

input0

double[] input0

output0

double[] output0

input0_s

int input0_s

input0_p

double[] input0_p

output0_p

double[] output0_p

W_01

double[][] W_01

W_02

double[][] W_02

W_03

double[][] W_03

W_13

double[][] W_13

W_23

double[][] W_23

eta01

double eta01

eta02

double eta02

eta03

double eta03

eta12

double eta12

eta13

double eta13

eta23

double eta23

eta

double eta

obj_type_code_len

int obj_type_code_len

obj_size_code_len

int obj_size_code_len

obj_locPAR_code_len

int obj_locPAR_code_len

obj_locMER_code_len

int obj_locMER_code_len

obj_locRAD_code_len

int obj_locRAD_code_len

obj_axisMER_code_len

int obj_axisMER_code_len

obj_axisPAR_code_len

int obj_axisPAR_code_len

obj_axisRAD_code_len

int obj_axisRAD_code_len

obj_name

java.lang.String[] obj_name

hand_locPAR_code_len

int hand_locPAR_code_len

hand_locMER_code_len

int hand_locMER_code_len

hand_locRAD_code_len

int hand_locRAD_code_len

hand_rotBANK_code_len

int hand_rotBANK_code_len

hand_rotPITCH_code_len

int hand_rotPITCH_code_len

hand_rotHEADING_code_len

int hand_rotHEADING_code_len

finger_FORCE_code_len

int finger_FORCE_code_len

thumb_FORCE_code_len

int thumb_FORCE_code_len

index_FORCE_code_len

int index_FORCE_code_len

affordance

PCode affordance

obj_loc

PCode obj_loc

obj_ori

PCode obj_ori

hand_off

PCode hand_off

hand_rot

PCode hand_rot

finger_force

PCode finger_force

WTA_ERR

double WTA_ERR

PDFthreshold

double PDFthreshold

unitBias

double unitBias

PLOTLEV

static int PLOTLEV

obj_axisMER_scale

static double obj_axisMER_scale

obj_axisMER_offset

static double obj_axisMER_offset

obj_axisPAR_scale

static double obj_axisPAR_scale

obj_axisPAR_offset

static double obj_axisPAR_offset

obj_axisRAD_scale

static double obj_axisRAD_scale

obj_axisRAD_offset

static double obj_axisRAD_offset

obj_locMER_scale

static double obj_locMER_scale

obj_locMER_offset

static double obj_locMER_offset

obj_locPAR_scale

static double obj_locPAR_scale

obj_locPAR_offset

static double obj_locPAR_offset

obj_locRAD_scale

static double obj_locRAD_scale

obj_locRAD_offset

static double obj_locRAD_offset

hand_locPAR_scale

static double hand_locPAR_scale

hand_locPAR_offset

static double hand_locPAR_offset

hand_locMER_scale

static double hand_locMER_scale

hand_locMER_offset

static double hand_locMER_offset

hand_locRAD_scale

static double hand_locRAD_scale

hand_locRAD_offset

static double hand_locRAD_offset

hand_rotBANK_scale

static double hand_rotBANK_scale

hand_rotBANK_offset

static double hand_rotBANK_offset

hand_rotPITCH_scale

static double hand_rotPITCH_scale

hand_rotPITCH_offset

static double hand_rotPITCH_offset

hand_rotHEADING_scale

static double hand_rotHEADING_scale

hand_rotHEADING_offset

static double hand_rotHEADING_offset

index_FORCE_scale

static double index_FORCE_scale

index_FORCE_offset

static double index_FORCE_offset

finger_FORCE_scale

static double finger_FORCE_scale

finger_FORCE_offset

static double finger_FORCE_offset

thumb_FORCE_scale

static double thumb_FORCE_scale

thumb_FORCE_offset

static double thumb_FORCE_offset

callback_Wrist

public static final int callback_Wrist

callback_Offset

public static final int callback_Offset

callback_Finger

public static final int callback_Finger

callback_Thumb

public static final int callback_Thumb

callback_Input

public static final int callback_Input

plotLabel

static int plotLabel

plotKey

static int plotKey

CLAMPON

static final boolean CLAMPON

CLAMPOFF

static final boolean CLAMPOFF

passc

public int passc

hand_off_pick

int hand_off_pick

offvalue

double[] offvalue

hand_rot_pick

int hand_rot_pick

rotvalue

double[] rotvalue

finger_force_pick

int finger_force_pick

forcevalue

double[] forcevalue

GVAR

static double GVAR

softVAR

static double softVAR

MAXREW3HIST

static final int MAXREW3HIST

rew3_hist

double[] rew3_hist

rew3_c

int rew3_c

colW_VAR

double colW_VAR

max_value_after_softmax

public double max_value_after_softmax

inix

int inix

lasttilt_deg

double lasttilt_deg

lastpar

public double lastpar

lastmer

public double lastmer

rotix

int rotix

looped

boolean looped
Constructor Detail

Motor

public Motor()
Method Detail

convert

public static Point3d convert(int callbackID,
                              double x,
                              double y,
                              double z)
The convert family is used to scaling and translating the 0..1 firing of units to actual values.

convertInput

public static Point3d convertInput(double a0,
                                   double a1,
                                   double a2)

convertOffset

public static Point3d convertOffset(double a0,
                                    double a1,
                                    double a2)

inconvertOffset

public static Point3d inconvertOffset(MotorPlan mp)

convertThumb

public static Point3d convertThumb(double a0,
                                   double a1,
                                   double a2)

convertFinger

public static Point3d convertFinger(double a0,
                                    double a1,
                                    double a2)

convertWrist

public static Point3d convertWrist(double a0,
                                   double a1,
                                   double a2)

inconvertWrist

public static Point3d inconvertWrist(MotorPlan mp)

map2xy

public static Point3d map2xy(int callbackID,
                             Point3d p,
                             double Z)

getTempPrefix

public java.lang.String getTempPrefix(int callbackID)

getGplotCommand

public java.lang.String getGplotCommand(int callbackID)

setParameters

public void setParameters()

updateResourcePars

public void updateResourcePars()

createPopulations

private void createPopulations()

createWeights

private void createWeights()
Creates the weight matrices. Cannot be called before createPopulation().

randomWeight

public double[][] randomWeight(int rows,
                               int cols,
                               double scale)

fixedWeight

public double[][] fixedWeight(int rows,
                              int cols,
                              double v)

forwardPass

public void forwardPass(int startlevel)
startlevel 1: full forward pass 2: don't update hand offset 3: don't update hand offset and FINGERS 4: do nothing :)

forwardNoisyPass

public void forwardNoisyPass(int startlevel,
                             double n1,
                             double n2,
                             double n3,
                             MotorPlan m)
startlevel 1: full forward pass 2: don't update hand offset 3: don't update hand offset and FINGERS 4: do nothing :)

net3

public void net3()

advancePass

public void advancePass()

internalPass

public void internalPass(int N,
                         int K,
                         int Kok)

flatten

public double[] flatten(double[][] M)

showSomething

public void showSomething()

reinforceAll

public void reinforceAll(double reward,
                         MotorPlan mp)

reinforceRot

public void reinforceRot(double reward)

reinforceRot_Off

public void reinforceRot_Off(double reward)

reinforceOff

public void reinforceOff(double reward)

reinforce

public void reinforce(double R,
                      int level)
level 1: hand offset level 2: finger force level 3: hand rot level. For updating all the weights must be called three times with level 1,2,3

softmax_colW

public void softmax_colW(double[][] v,
                         double[][] r,
                         int col)

col_normalizeWeight

public void col_normalizeWeight(double[][] w,
                                int col)
Normalize over the columns. The column weight vector becomes unit length in ^2 norm

normalizeWeight2

public void normalizeWeight2(double[] w)
Weight vector becomes unit length in ^2 norm

decayWeight

public void decayWeight(double[] w,
                        double rate)
Decayin weight

normalizeWeight

public void normalizeWeight(double[] w)
Max component comes 1 the rest scaled accordinglym

normalizeWeight2D

public void normalizeWeight2D(double[][] w)

pickNoisyPDF

public int pickNoisyPDF(double[] pdf,
                        int size,
                        double chance)

pickPDF

public int pickPDF(double[] pdf,
                   int size)

pick_WTA

public int pick_WTA(double[] pdf,
                    int size)

pick_my_PDF

public int pick_my_PDF(double[] pdf,
                       int size)

pick_my_NoisyPDF

public int pick_my_NoisyPDF(double[] pdf,
                            int size,
                            double chance)

softmax

public void softmax(double[] v,
                    int size,
                    double[] r)

maxsoftmax

public void maxsoftmax(double[] v,
                       int size,
                       double[] r)

avgsoftmax

public void avgsoftmax(double[] v,
                       int size,
                       double[] r)
Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5. v[] and r[] can be the same

hardcoresoftmax

public void hardcoresoftmax(double[] v,
                            int size,
                            double[] r)
Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5. v[] and r[] can be the same

realnormalizedsoftmax

public void realnormalizedsoftmax(double[] v,
                                  int size,
                                  double[] r)
Softmax with G(x)= 1/(1+exp(-2bX)) with b=0.5. v[] and r[] can be the same

sigsoftmax

public void sigsoftmax(double[] v,
                       int size,
                       double[] r)

softmaxW

public void softmaxW(double[] v,
                     int size,
                     double[] r,
                     double V)

squash

public void squash(double[] v,
                   int size,
                   double[] r)
we are using G(x)= 1/(1+exp(-2bX)) with b=0.5. v[] and r[] can be the same

multiply

public void multiply(double[][] M,
                     double[] v,
                     int im,
                     int jm,
                     double[] r)

addto

public void addto(double[][] M,
                  int im,
                  int jm,
                  double[][] C)

initBabble

public void initBabble()

resetInputSeq

public void resetInputSeq()

nextInput

public double[] nextInput()

nextRandomInput

public Point3d nextRandomInput()

convertInput_Loc

public static Point3d convertInput_Loc(double[] pv)

convertInput

public static Point3d convertInput(double[] pv)

updateObjectAxis

public void updateObjectAxis(Point3d p)

updateObjectLocation

public void updateObjectLocation(Point3d p)

inconvertInput_Loc

public double[] inconvertInput_Loc(Hand h,
                                   Point3d pp)

inconvertInput

public double[] inconvertInput(Hand h,
                               Point3d pp)

inconvertInput_hack

public int[] inconvertInput_hack(Hand h,
                                 Point3d pp)

updateInputLayer_Loc

public void updateInputLayer_Loc(Hand h,
                                 Graspable obj)

updateInputLayer

public void updateInputLayer(Hand h,
                             Graspable obj)

nextMotorPlan

public MotorPlan nextMotorPlan(Hand h,
                               Object3d obj)

nextNoisyMotorPlan

public MotorPlan nextNoisyMotorPlan(Hand h,
                                    Object3d obj,
                                    double n1,
                                    double n2,
                                    double n3)

doneRotGen

public boolean doneRotGen()

resetRotGen

public void resetRotGen()

pickOrdRotation

public void pickOrdRotation(MotorPlan m)
modify wrist rotation part of the motor plan in an ordered fashion, In each call next preferred value is returned. Note that this is kind of fake. It reads the preferred value from the network but the network is not notified. If you wanna learn using this you need to fake good

pickRotation

public void pickRotation(MotorPlan m)

pickNoisyRotation

public void pickNoisyRotation(MotorPlan m,
                              double chance)

safe_pickRotation

public void safe_pickRotation(MotorPlan m)

updateWristLayer

public void updateWristLayer()

main

public static void main(java.lang.String[] argv)

dprint

private void dprint(java.lang.String s)

dprint

private void dprint(int level,
                    java.lang.String s)

dprintln

private void dprintln(java.lang.String s)

dprintln

private void dprintln(int level,
                      java.lang.String s)

dumpNet

public void dumpNet(java.lang.String prefix,
                    java.lang.String suffix,
                    java.lang.String us)

dumpNet

public void dumpNet(java.lang.String suffix)

dumpNet

public void dumpNet(java.lang.String prefix,
                    java.lang.String suffix)

loadNet

public void loadNet(java.lang.String prefix,
                    java.lang.String suffix)

loadNet

public void loadNet(java.lang.String suffix)