-
Notifications
You must be signed in to change notification settings - Fork 1
/
out.txt
201 lines (195 loc) · 10.5 KB
/
out.txt
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
diff --git a/grade.js b/grade.js
index a6b4141..f75e94d 100644
--- a/grade.js
+++ b/grade.js
@@ -1,4 +1,4 @@
-//CI grader generates report at 17-11-2020-12-05-18
+//CI grader generates report at 18-11-2020-00-06-14
grade =
{
"chrisree": {
@@ -239,11 +239,11 @@ grade =
"test results": {
"Test 0": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_Jacobian/test_0.js:535\n for(var i = 0; i < m.length; i++){\n ^\n\nTypeError: Cannot read property 'length' of undefined\n at matrix_transpose (/chrisree/IK_Jacobian/test_0.js:535:26)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_Jacobian/test_0.js:1620:32)\n at Object.robot_inverse_kinematics [as robotInvers"
+ "Stderr": "[ERROR]: Incorrect IK Jacobian for test 0\n"
},
"Test 1": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_Jacobian/test_1.js:535\n for(var i = 0; i < m.length; i++){\n ^\n\nTypeError: Cannot read property 'length' of undefined\n at matrix_transpose (/chrisree/IK_Jacobian/test_1.js:535:26)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_Jacobian/test_1.js:1620:32)\n at Object.robot_inverse_kinematics [as robotInvers"
+ "Stderr": "[ERROR]: Incorrect IK Jacobian for test 1\n"
}
},
"comments": [
@@ -255,15 +255,15 @@ grade =
"test results": {
"Test 2": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JTranspose/test_2.js:541\n for(var i = 0; i < m.length; i++){\n ^\n\nTypeError: Cannot read property 'length' of undefined\n at matrix_transpose (/chrisree/IK_JTranspose/test_2.js:541:26)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JTranspose/test_2.js:1626:32)\n at Object.robot_inverse_kinematics [as robot"
+ "Stderr": "Error increased during iteration, implementation incorrect\n"
},
"Test 0": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JTranspose/test_0.js:541\n for(var i = 0; i < m.length; i++){\n ^\n\nTypeError: Cannot read property 'length' of undefined\n at matrix_transpose (/chrisree/IK_JTranspose/test_0.js:541:26)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JTranspose/test_0.js:1626:32)\n at Object.robot_inverse_kinematics [as robot"
+ "Stderr": "[ERROR]: IK_JTranspose test 0 failed\n"
},
"Test 1": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JTranspose/test_1.js:541\n for(var i = 0; i < m.length; i++){\n ^\n\nTypeError: Cannot read property 'length' of undefined\n at matrix_transpose (/chrisree/IK_JTranspose/test_1.js:541:26)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JTranspose/test_1.js:1626:32)\n at Object.robot_inverse_kinematics [as robot"
+ "Stderr": "[ERROR]: IK_JTranspose test 1 failed\n"
}
},
"comments": [
@@ -275,15 +275,15 @@ grade =
"test results": {
"Test 2": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JPseudoInverse/test_2.js:556\n var T = matrix_copy(matrix_tranpose(m));\n ^\n\nReferenceError: matrix_tranpose is not defined\n at matrix_pseudoinverse (/chrisree/IK_JPseudoInverse/test_2.js:556:13)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JPseudoInverse/test_2.js:1624:16)\n at Object.robot_inverse_kinematics [as rob"
+ "Stderr": "Error increased during iteration, implementation incorrect\n"
},
"Test 0": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JPseudoInverse/test_0.js:556\n var T = matrix_copy(matrix_tranpose(m));\n ^\n\nReferenceError: matrix_tranpose is not defined\n at matrix_pseudoinverse (/chrisree/IK_JPseudoInverse/test_0.js:556:13)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JPseudoInverse/test_0.js:1624:16)\n at Object.robot_inverse_kinematics [as rob"
+ "Stderr": "[ERROR]: IK_JPseudoInverse test 0 failed\n"
},
"Test 1": {
"Status": "Failed",
- "Stderr": "Error message too long, print partially: /chrisree/IK_JPseudoInverse/test_1.js:556\n var T = matrix_copy(matrix_tranpose(m));\n ^\n\nReferenceError: matrix_tranpose is not defined\n at matrix_pseudoinverse (/chrisree/IK_JPseudoInverse/test_1.js:556:13)\n at Object.iterate_inverse_kinematics [as iterateIK] (/chrisree/IK_JPseudoInverse/test_1.js:1624:16)\n at Object.robot_inverse_kinematics [as rob"
+ "Stderr": "[ERROR]: IK_JPseudoInverse test 1 failed\n"
}
},
"comments": [
diff --git a/kineval/kineval_inverse_kinematics.js b/kineval/kineval_inverse_kinematics.js
index 3136dfc..1946b09 100644
--- a/kineval/kineval_inverse_kinematics.js
+++ b/kineval/kineval_inverse_kinematics.js
@@ -51,7 +51,7 @@ kineval.iterateIK = function iterate_inverse_kinematics(endeffector_target_world
// robot.dq = [] // Joint configuration change term (don't include step length)
// ---------------------------------------------------------------------------
// Get all joints on endeffector path
- var joints = [];
+ var joints = [endeffector_joint];
var curJoint = robot.joints[endeffector_joint];
while (true) {
var parentLink = curJoint.parent;
@@ -61,22 +61,10 @@ kineval.iterateIK = function iterate_inverse_kinematics(endeffector_target_world
joints.unshift(robot.links[parentLink].parent);
curJoint = robot.joints[robot.links[parentLink].parent];
}
-
// calculates the jacobian
robot.jacobian = [[],[],[],[],[],[]];
joints.forEach(function(cur_joint) {
cur_joint = robot.joints[cur_joint];
- // Have to take the difference between the xyz and the rpy
- var xd = endeffector_target_world;
- var xn = matrix_multiply(cur_joint.xform, endeffector_position_local);
- var curOrientation = cur_joint.origin.rpy;
- robot.dx = [[0],[0],[0],[0],[0],[0]];
- for (var i = 0; i < 3; ++i) {
- robot.dx[i][0] = xd.position[i] - xn[i]
- }
- for (var i = 0; i < 3; ++i) {
- robot.dx[i + 3][0] = xd.orientation[i] - curOrientation[i];
- }
var tmpAxis = [[0],[0],[0],[1]];
for (var i = 0; i < 3; ++i) {
@@ -89,10 +77,9 @@ kineval.iterateIK = function iterate_inverse_kinematics(endeffector_target_world
var zero = [[0],[0],[0],[1]];
var oiw = matrix_multiply(matrix_copy(tiw), zero);
- tiw = matrix_copy(cur_joint.xform);
+ tiw = matrix_copy(robot.joints[endeffector_joint].xform);
var ptool = matrix_multiply(tiw, endeffector_position_local);
-
- // Jvi - linear
+
var kiwMinusOiw = [];
for (var i = 0; i < oiw.length; ++i) {
kiwMinusOiw.push(kiw[i][0] - oiw[i][0]);
@@ -101,15 +88,27 @@ kineval.iterateIK = function iterate_inverse_kinematics(endeffector_target_world
for (var i = 0; i < oiw.length; ++i) {
ptoolMinusOiw.push(ptool[i][0] - oiw[i][0]);
}
- var cross = vector_cross(kiwMinusOiw, ptoolMinusOiw)
+ var cross = vector_cross(kiwMinusOiw, ptoolMinusOiw);
for (var i = 0; i < 3; ++i) {
+ // Jvi - linear
robot.jacobian[i].push(cross[i]);
- }
- // Jwi - angular
- for (var i = 0; i < 3; ++i) {
+ // Jwi - Angular
robot.jacobian[i + 3].push(kiwMinusOiw[i]);
}
- });
+ });
+ var cur_joint = robot.joints[endeffector_joint];
+ // Have to take the difference between the xyz and the rpy
+ var xd = endeffector_target_world;
+ var xn = matrix_multiply(matrix_copy(cur_joint.xform), endeffector_position_local);
+ // am not sure if this is remotely right
+ var curOrientation = cur_joint.origin.rpy;
+ robot.dx = [[0],[0],[0],[0],[0],[0]];
+ for (var i = 0; i < 3; ++i) {
+ robot.dx[i][0] = xd.position[i] - xn[i]
+ }
+ for (var i = 0; i < 3; ++i) {
+ robot.dx[i + 3][0] = xd.orientation[i] - curOrientation[i];
+ }
var jacobian = matrix_copy(robot.jacobian);
var invJ;
@@ -118,13 +117,12 @@ kineval.iterateIK = function iterate_inverse_kinematics(endeffector_target_world
} else {
invJ = matrix_multiply(matrix_transpose(jacobian), matrix_copy(robot.dx));
}
- robot.dq = matrix_copy(matrix_multiply(invJ, robot.dx))
-
+ robot.dq = matrix_copy(invJ);
var gamma = kineval.params.ik_steplength;
var i = 0;
joints.forEach(function(cur_joint) {
cur_joint = robot.joints[cur_joint];
- cur_joint.control = cur_joint.angle + (gamma * robot.dq[i]);
+ cur_joint.angle = cur_joint.angle + (gamma * robot.dq[i]);
i = i + 1;
});
// Explanation of above 3 variables:
diff --git a/kineval/kineval_matrix.js b/kineval/kineval_matrix.js
index 79d7e26..08c233b 100644
--- a/kineval/kineval_matrix.js
+++ b/kineval/kineval_matrix.js
@@ -51,7 +51,7 @@ function matrix_multiply(m1, m2) {
// this might be wrong lol
function matrix_transpose(m) {
var ans = [];
- for(var i = 0; i < m.length; i++){
+ for(var i = 0; i < m[0].length; i++){
ans.push([]);
};
@@ -65,18 +65,17 @@ function matrix_transpose(m) {
}
function matrix_pseudoinverse(m) {
- // returns pseudoinverse of matrix m
- var tmpT = matrix_transpose(m);
- var T = [];
- for (var i = 0; i < tmpT.length; ++i) {
- if (tmpT[i].length != 0) {
- T.push(tmpT[i]);
- } else {
- break;
- }
+ if (m.length == m[0].length) {
+ return numeric.inv(m);
}
+ // returns pseudoinverse of matrix m
+ var T = matrix_transpose(m);
var copyM = matrix_copy(m);
- return matrix_multiply(numeric.inv(matrix_multiply(T, copyM)), T);
+ if (m.length > m[0].length) {
+ return matrix_multiply(numeric.inv(matrix_multiply(matrix_copy(T), copyM)), T);
+ } else {
+ return matrix_multiply(T, numeric.inv(matrix_multiply(copyM, matrix_copy(T))));
+ }
}
// function matrix_invert_affine(m) {