Cody

Solution 1279712

Submitted on 2 Oct 2017 by yurenchu
  • Size: 49
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[0 0 0]; robot = forwardkinematics(robot); yc=robot.attitude; correct_attitude=[0 sum(robot.links) pi/2]; assert(isequal(yc,correct_attitude))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [0 0 0] attitude: [0 1.2500 1.5708]

2   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[pi/4 0 0]; robot = forwardkinematics(robot); yc=robot.attitude; correct_attitude=[-0.5*sqrt(2)*sum(robot.links) 0.5*sqrt(2)*sum(robot.links) 3*pi/4]; assert(isequal(yc,correct_attitude))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [0.7854 0 0] attitude: [-0.8839 0.8839 2.3562]

3   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[pi/4 pi 3*pi/4]; robot = forwardkinematics(robot); yc=robot.attitude correct_attitude=[-0.5*sqrt(2)*(robot.links(1)-robot.links(2)) 0.5*sqrt(2)*(robot.links(1)-robot.links(2))+robot.links(3) pi/2] assert(all(abs(yc-correct_attitude)<=eps))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [0.7854 3.1416 2.3562] attitude: [-0.0354 0.3354 1.5708] yc = -0.0354 0.3354 1.5708 correct_attitude = -0.0354 0.3354 1.5708

4   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[-pi/4 pi/4 0]; robot = forwardkinematics(robot); yc=robot.attitude; correct_attitude=[0.5*sqrt(2)*robot.links(1) 0.5*sqrt(2)*robot.links(1)+sum(robot.links(2:3)) pi/2]; assert(all(abs(yc-correct_attitude)<=eps))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [-0.7854 0.7854 0] attitude: [0.3536 1.1036 1.5708]

5   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[-2.1513 2.9568 2.8725]; robot = forwardkinematics(robot); yc=robot.attitude correct_attitude=[0.246878929631356 -0.220349832044192 5.248796326794897] assert(all(abs(yc-correct_attitude)<=1e-8))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [-2.1513 2.9568 2.8725] attitude: [0.2469 -0.2203 5.2488] yc = 0.2469 -0.2203 5.2488 correct_attitude = 0.2469 -0.2203 5.2488

6   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[-0.0919 1.8867 -2.2501]; robot = forwardkinematics(robot); yc=robot.attitude correct_attitude=[-0.260952279814086 0.667368060676958 1.115496326794896]; assert(all(abs(yc-correct_attitude)<=1e-8))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [-0.0919 1.8867 -2.2501] attitude: [-0.2610 0.6674 1.1155] yc = -0.2610 0.6674 1.1155

7   Pass
robot.links=[0.5 0.45 0.3]; robot.jointangles=[-0.4916 2.6121 1.8360]; robot = forwardkinematics(robot); yc=robot.attitude correct_attitude=[0.070611406176580 -0.000086942065283 5.527296326794897]; assert(all(abs(yc-correct_attitude)<=1e-8))

x = struct with fields: links: [0.5000 0.4500 0.3000] jointangles: [-0.4916 2.6121 1.8360] attitude: [0.0706 -8.6942e-05 5.5273] yc = 0.0706 -0.0001 5.5273