@@ -35,6 +35,81 @@ describe('URDFRobot', () => {
3535 expect ( robot . joints . JOINT2 . angle ) . toEqual ( 2 ) ;
3636 } ) ;
3737
38+ it ( 'should correctly parse joint efforts and velocities.' , ( ) => {
39+ const loader = new URDFLoader ( ) ;
40+ const robot = loader . parse ( `
41+ <robot name="TEST">
42+ <link name="LINK1"/>
43+ <link name="LINK2"/>
44+ <link name="LINK3"/>
45+ <joint name="JOINT1" type="continuous">
46+ <axis xyz="0 0 -1" />
47+ <parent link="LINK1"/>
48+ <child link="LINK2"/>
49+ <limit effort="150" lower="-3.14" upper="3.14" velocity="5.20" />
50+ </joint>
51+ <joint name="JOINT2" type="continuous">
52+ <axis xyz="0 0 -1" />
53+ <parent link="LINK2"/>
54+ <child link="LINK3"/>
55+ </joint>
56+ </robot>
57+ ` ) ;
58+
59+ expect ( robot . joints . JOINT1 . limit . effort ) . toEqual ( 150 ) ;
60+ expect ( robot . joints . JOINT1 . limit . lower ) . toEqual ( - 3.14 ) ;
61+ expect ( robot . joints . JOINT1 . limit . upper ) . toEqual ( 3.14 ) ;
62+ expect ( robot . joints . JOINT1 . limit . velocity ) . toEqual ( 5.20 ) ;
63+
64+ expect ( robot . joints . JOINT2 . limit . effort ) . toEqual ( 0 ) ;
65+ expect ( robot . joints . JOINT2 . limit . lower ) . toEqual ( 0 ) ;
66+ expect ( robot . joints . JOINT2 . limit . upper ) . toEqual ( 0 ) ;
67+ expect ( robot . joints . JOINT2 . limit . velocity ) . toEqual ( 0 ) ;
68+ } ) ;
69+
70+ it ( 'should correctly parse joint inertial data.' , ( ) => {
71+ const loader = new URDFLoader ( ) ;
72+ const robot = loader . parse ( `
73+ <robot name="TEST">
74+ <link name="LINK1">
75+ <inertial>
76+ <origin rpy="0 0 -1.5707963267948966" xyz="0.14635000035763 0 0"/>
77+ <mass value="2.5076"/>
78+ <inertia ixx="0.00443333156" ixy="0.0" ixz="0.0" iyy="0.00443333156" iyz="0.0" izz="0.0072" />
79+ </inertial>
80+ </link>
81+ <link name="LINK2"/>
82+ <link name="LINK3"/>
83+ <joint name="JOINT1" type="continuous">
84+ <axis xyz="0 0 -1" />
85+ <parent link="LINK1"/>
86+ <child link="LINK2"/>
87+ </joint>
88+ <joint name="JOINT2" type="continuous">
89+ <axis xyz="0 0 -1" />
90+ <parent link="LINK2"/>
91+ <child link="LINK3"/>
92+ </joint>
93+ </robot>
94+ ` ) ;
95+
96+ expect ( robot . links . LINK1 . inertial . origin . rpy ) . toEqual ( [ 0 , 0 , - 1.5707963267948966 ] ) ;
97+ expect ( robot . links . LINK1 . inertial . origin . xyz ) . toEqual ( [ 0.14635000035763 , 0 , 0 ] ) ;
98+ expect ( robot . links . LINK1 . inertial . mass ) . toEqual ( 2.5076 ) ;
99+ expect ( robot . links . LINK1 . inertial . inertia . ixx ) . toEqual ( 0.00443333156 ) ;
100+ expect ( robot . links . LINK1 . inertial . inertia . iyy ) . toEqual ( 0.00443333156 ) ;
101+ expect ( robot . links . LINK1 . inertial . inertia . izz ) . toEqual ( 0.0072 ) ;
102+ expect ( robot . links . LINK1 . inertial . inertia . ixy ) . toEqual ( 0 ) ;
103+ expect ( robot . links . LINK1 . inertial . inertia . ixz ) . toEqual ( 0 ) ;
104+ expect ( robot . links . LINK1 . inertial . inertia . iyz ) . toEqual ( 0 ) ;
105+
106+ // LINK2 has no <inertial> tag — should still have default values
107+ expect ( robot . links . LINK2 . inertial . mass ) . toEqual ( 0 ) ;
108+ expect ( robot . links . LINK2 . inertial . origin . xyz ) . toEqual ( [ 0 , 0 , 0 ] ) ;
109+ expect ( robot . links . LINK2 . inertial . origin . rpy ) . toEqual ( [ 0 , 0 , 0 ] ) ;
110+ expect ( robot . links . LINK2 . inertial . inertia . ixx ) . toEqual ( 0 ) ;
111+ } ) ;
112+
38113 it ( 'should parse material colors and name.' , ( ) => {
39114 const loader = new URDFLoader ( ) ;
40115 const res = loader . parse ( `
0 commit comments