-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathStretchReceptor.cpp
71 lines (62 loc) · 2.1 KB
/
StretchReceptor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// StretchReceptor.cpp
// one
//
// Created by Eduardo on 9/26/15.
// Copyright © 2015 Eduardo Izquierdo. All rights reserved.
//
#include "StretchReceptor.h"
StretchReceptor::StretchReceptor(int nSegs, int nSR, double srvncgain, double srheadgain)
{
SetStretchReceptorParams(nSegs, nSR, srvncgain, srheadgain);
}
void StretchReceptor::SetStretchReceptorParams(int nSegs, int nSR, double srvncgain, double srheadgain)
{
NSEGS = nSegs; // Number of segments
NSR = nSR; // Number of stretch receptors
NSEGSSR = 6; // Number of segments that go into a stretch receptor
SRvncgain = srvncgain; // Stretch receptor gain
SRheadgain = srheadgain; // Stretch receptor gain
NSEGSHEADSTART = 7; // 7-12
NSEGSHEAD = 14; // Number of segments for the sublateral head motorneurons
NSEGSVNCSTART = 7; // Segment where VNC starts
normSegLenD.SetBounds(1, NSEGS);
normSegLenV.SetBounds(1, NSEGS);
D_sr.SetBounds(1, NSR);
VA_sr.SetBounds(1, NSR);
VP_sr.SetBounds(1, NSR);
}
void StretchReceptor::Update()
{
double d, v;
// Head
d = 0.0;
v = 0.0;
for (int j = NSEGSHEADSTART; j < NSEGSHEADSTART + NSEGSHEAD; j++)
{
d += normSegLenD(j);
v += normSegLenV(j);
}
HD_sr = SRheadgain*(d/NSEGSHEAD);
HV_sr = SRheadgain*(v/NSEGSHEAD);
// First four VC Neural Units (with three muscles each)
for (int i = 1; i <= 6; i++){
d = 0.0;
v = 0.0;
for (int j = 1; j <= NSEGSSR; j++)
{
d += normSegLenD(j+((i-1)*NSEGSSR)+NSEGSVNCSTART-1);
v += normSegLenV(j+((i-1)*NSEGSSR)+NSEGSVNCSTART-1);
}
D_sr(i) = SRvncgain*(d/NSEGSSR);
VA_sr(i) = SRvncgain*(v/NSEGSSR);
d = 0.0;
v = 0.0;
for (int j = 1; j <= NSEGSSR; j++)
{
d += normSegLenD(j+((i-1)*NSEGSSR)+NSEGSVNCSTART-1+2);
v += normSegLenV(j+((i-1)*NSEGSSR)+NSEGSVNCSTART-1+2);
}
VP_sr(i) = SRvncgain*(v/NSEGSSR);
}
}