Skip to content

Commit 6c6ba80

Browse files
committed
Merge pull request #138 from T045T/test_simplified_urdf
test the visual Urdf elements
2 parents a4e40d1 + 0a28e52 commit 6c6ba80

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

test/urdf.test.js

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,37 @@ var XPATH_FIRST_ORDERED_NODE_TYPE = 9;
77

88
var sample_urdf = function (){
99
return '<robot name="test_robot">' +
10-
' <link name="link1" />'+
11-
' <link name="link2" />'+
12-
' <link name="link3" />'+
13-
' <link name="link4" />'+
10+
' <link name="link1">'+ // test well-behaved versions of the basic shapes
11+
' <visual>'+
12+
' <geometry>'+
13+
' <sphere radius="1" />'+
14+
' </geometry>'+
15+
' </visual>'+
16+
' </link>'+
17+
' <link name="link2">'+
18+
' <visual>'+
19+
' <geometry>'+
20+
' <box size="0.5 0.5 0.5" />'+
21+
' </geometry>'+
22+
' </visual>'+
23+
' </link>'+
24+
' <link name="link3">'+
25+
' <visual>'+
26+
' <geometry>'+
27+
' <cylinder radius="0.2" length="2" />'+
28+
' </geometry>'+
29+
' </visual>'+
30+
' </link>'+
31+
' <link name="link4">'+ // and an extra one with a material
32+
' <visual>'+
33+
' <geometry>'+
34+
' <box size="1 1 1" />'+
35+
' </geometry>'+
36+
' <material name="red">'+
37+
' <color rgba="1 0 0 1" />'+
38+
' </material>'+
39+
' </visual>'+
40+
' </link>'+
1441
' <joint name="joint1" type="continuous">'+
1542
' <parent link="link1"/>'+
1643
' <child link="link2"/>'+
@@ -38,6 +65,26 @@ describe('URDF', function() {
3865
expect(urdfModel.name).to.equal('test_robot');
3966
});
4067

68+
it('should correctly construct visual elements', function() {
69+
var urdfModel = new ROSLIB.UrdfModel({
70+
string: sample_urdf()
71+
});
72+
73+
// Check all the visual elements
74+
expect(urdfModel.links['link1'].visual.geometry.radius).to.equal(1.0);
75+
expect(urdfModel.links['link2'].visual.geometry.dimension.x).to.equal(0.5);
76+
expect(urdfModel.links['link2'].visual.geometry.dimension.y).to.equal(0.5);
77+
expect(urdfModel.links['link2'].visual.geometry.dimension.z).to.equal(0.5);
78+
expect(urdfModel.links['link3'].visual.geometry.length).to.equal(2.0);
79+
expect(urdfModel.links['link3'].visual.geometry.radius).to.equal(0.2);
80+
81+
expect(urdfModel.links['link4'].visual.material.name).to.equal('red');
82+
expect(urdfModel.links['link4'].visual.material.color.r).to.equal(1.0);
83+
expect(urdfModel.links['link4'].visual.material.color.g).to.equal(0);
84+
expect(urdfModel.links['link4'].visual.material.color.b).to.equal(0);
85+
expect(urdfModel.links['link4'].visual.material.color.a).to.equal(1.0);
86+
});
87+
4188
it('is ignorant to the xml node', function(){
4289
var parser = new DOMParser();
4390
var xml = parser.parseFromString(sample_urdf(), 'text/xml');

0 commit comments

Comments
 (0)