-
Notifications
You must be signed in to change notification settings - Fork 2
/
controller.html
62 lines (53 loc) · 2.11 KB
/
controller.html
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
<html>
<center>
<b>Robot Controller</b><br><br>
<p>Current Position
<br>X<input type="text" id="currentPosX" maxlength="1" style="text-align:right" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
<br>Y<input type="text" id="currentPosY" maxlength="1" style="text-align:right" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
</p>
<p>Waypoint
<br>X<input type="text" id="waypointX" maxlength="1" style="text-align:right" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
<br>Y<input type="text" id="waypointY" maxlength="1" style="text-align:right" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
</p>
<button onclick = "updateWaypoint()">Update Waypoint</button>
<br>
<button onclick = "setRun()">Run</button>
<p id = "myText">Waiting...</p>
</center>
<script>
function updateWaypoint()
{
var namex = "waypointX";
var namey = "waypointY";
var x_val = document.getElementById("waypointX").value;
var y_val = document.getElementById("waypointY").value;
var msgx = "set=" + 100 + "to" + x_val;
var msgy = "set=" + 101 + "to" + y_val;
httpPost("/controller_post", msgx);
httpPost("/controller_post", msgy);
document.getElementById("myText").innerHTML =
"Updated Waypoint";
}
function setRun()
{
var namex = "currentPosX";
var namey = "currentPosY";
var x_val = document.getElementById("currentPosX").value;
var y_val = document.getElementById("currentPosY").value;
var msgx = "set=" + 200 + "to" + x_val;
var msgy = "set=" + 201 + "to" + y_val;
httpPost("/controller_post", msgx);
httpPost("/controller_post", msgy);
document.getElementById("myText").innerHTML =
"Running";
}
function httpPost(path, param)
{
var req = new XMLHttpRequest();
req.open("POST", path, true);
req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
req.send(param);
}
</script>
</html>