-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
123 lines (110 loc) · 3.08 KB
/
Copy pathindex.html
File metadata and controls
123 lines (110 loc) · 3.08 KB
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
<!DOCTYPE html>
<html>
<body>
<u> Assignment Part A: Task 1 Generator</u> <br />
<p id="gen1"></p>
<p id="gen2"></p>
<button onclick="border()">Border</button>
<button onclick="noBorder()">No Border</button>
<button onclick="barrel()">Generate Barrel</button>
<button onclick="container()">Generate Container</button>
</br>
<button onclick="copy()">Copy world file to clipboard</button>
<br />
Note: some browsers will not work and will need to manually copy and paste
<script>
function border() {
document.getElementById("borders").innerHTML = "border(pose [ 0.000 -2.500 0.000 90.000 ] size [0.100 5.000 0.500])\nborder(pose [ 0.000 2.500 0.000 90.000 ] size [0.100 5.000 0.500])\nborder( pose [ 2.500 0.000 0.000 0.000 ] size [0.100 5.000 0.500])\nborder( pose [ -2.500 0.000 0.000 0.000 ] size [0.100 5.000 0.500])";
document.getElementById("gen1").innerHTML = "Generated with borders"
}
function noBorder() {
document.getElementById("gen1").innerHTML = "Generated with no borders"
document.getElementById("borders").innerHTML = "";
}
function barrel() {
radius = (16+2*Math.floor(Math.random() * 18))/100;
diameter = radius*2;
output = "circle(\n"
output += "pose [0 0 0 0]\n"
output += "size ["+diameter+" "+diameter+" 0.500]\n"
output += ")\n"
document.getElementById("objects").innerHTML = output;
document.getElementById("gen2").innerHTML = "Barrel with radius: "+radius;
}
function container() {
width = (30+2*Math.floor(Math.random() * 36))/100;
length = (30+2*Math.floor(Math.random() * 36))/100;
output = "rectangle(\n"
output += "pose [0 0 0 45]\n"
output += "size ["+width+" "+length+" 0.500]\n"
output += ")\n"
document.getElementById("objects").innerHTML = output;
document.getElementById("gen2").innerHTML = "Container with width: "+width+ " length: "+length;
}
function copy() {
var range = document.createRange();
range.selectNode(document.getElementById("worldfile"));
window.getSelection().addRange(range);
document.execCommand("copy");
alert("text copied if highlighted")
}
</script>
<br />
<br />
<pre id="worldfile" >
# milliseconds per update step
interval_sim 50
resolution 0.001
window
(
size [ 400 400 ]
# camera options
center [ 0 0 ]
rotate [ 0 0 ]
scale 60
)
define border model
(
color "red"
)
define marker model
(
size [0.1 0.1 0.500]
color "red"
)
define rectangle model
(
color "random"
)
define circle model
(
bitmap "circle.png"
color "random"
)
define myLaser ranger
(
sensor( range [ 0.02 5.6 ] fov 180.0 samples 512 )
size [0.100 0.100 0.100]
color "black"
block(
points 4
point[0] [0 0]
point[1] [0.1 0]
point[2] [0.1 0.1]
point[3] [0 0.1]
z [0 0.1]
)
)
define myRobot position
(
size [0.460 0.460 0.250]
drive "diff"
myLaser(pose [ 0.280 0.000 -0.200 0.000 ])
)
# throw in a robot
myRobot( pose [ 0.000 -1.5 0.000 90.000 ] origin [ 0.000 0.000 0.000 90.000 ] name "bob" color "random")
<div id="borders"></div>
<div id="objects"></div>
</pre>
</body>
</html>