|
<!doctype html>
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Contrôle du robot</title>
|
|
<link href="style.css" rel="stylesheet">
|
|
</head>
|
|
<body
|
|
background = https://www.zooplus.fr/magazine/wp-content/uploads/2019/06/comprendre-le-langage-des-chats.jpg;
|
|
>
|
|
|
|
<h1>
|
|
Contrôle du robot sans fils
|
|
</h1>
|
|
<button>
|
|
<a href="https://cohabit.fr/"><img
|
|
src=https://cohabit.fr/images/logo.svg
|
|
width="150 "
|
|
height="150"/></a>
|
|
</button>
|
|
<p>
|
|
Cette page permet de contrôler le robot depuis un PC portable connecté au WiFi du robot. Elle est destinée aux personnes n'ayant pas de smartphone.
|
|
</p>
|
|
<h2>
|
|
Paramètres de contrôle
|
|
</h2>
|
|
<p>
|
|
Ici vous pourrez paramétrer les contrôles du robot, rentrer son adresse IP ainsi que lui indiquer la distance à parcourir ou l'angle de rotation désiré.
|
|
</p>
|
|
<form id="form">
|
|
<label for="ip">Adresse IP du robot</label>
|
|
<input type="text" id="ip" placeholder="192.168.0.0" oninput="storeInput()"><br>
|
|
<label for="valueRot">Rotation en degrés</label>
|
|
<input type="text" id="valueRot" placeholder="90" oninput="storeInput()"><br>
|
|
<label for="valueLength">Longueur en cm</label>
|
|
<input type="text" id="valueLength" placeholder="10" oninput="storeInput()">
|
|
</form>
|
|
<h2>
|
|
Contrôle
|
|
</h2>
|
|
<p>
|
|
Amusez vous ! Pour contrôler le robot, utilisez les flèches directionnelles pour le diriger et la barre espace pour le stopper.
|
|
</p>
|
|
</body>
|
|
<button class = "vertical" onclick="forward()"><img
|
|
src=https://www.impressions-languedoc.eu/931-thickbox_default/fleche-haut.jpg
|
|
width="150 "
|
|
height="150"
|
|
align=right />
|
|
</button>
|
|
<button class ="vertical" onclick="backward()"><img
|
|
src=https://www.impressions-languedoc.eu/931-thickbox_default/fleche-haut.jpg
|
|
style="transform:rotate(180deg);"
|
|
width="150 "
|
|
height="150"
|
|
align=right />
|
|
</button>
|
|
<button class ="horizontal" onclick="left()"><img
|
|
src=https://www.impressions-languedoc.eu/931-thickbox_default/fleche-haut.jpg
|
|
style="transform:rotate(270deg);"
|
|
width="150 "
|
|
height="150"
|
|
align=right />
|
|
</button>
|
|
<button onclick="pause()"><img
|
|
src=https://www.pngall.com/wp-content/uploads/5/Pause-Button-PNG-Clipart.png
|
|
width="150 "
|
|
height="150"
|
|
align=right />
|
|
</button>
|
|
|
|
<button class ="horizontal" onclick="right()"><img
|
|
src=https://www.impressions-languedoc.eu/931-thickbox_default/fleche-haut.jpg
|
|
style="transform:rotate(90deg);"
|
|
width="150 "
|
|
height="150"
|
|
align=right />
|
|
</button>
|
|
|
|
<script>
|
|
var ipInput = "";
|
|
var valueRot = "";
|
|
var valueLength ="";
|
|
var keyMap ={};
|
|
|
|
function forward() {
|
|
const url = keyMap[38];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
}
|
|
function backward() {
|
|
const url = keyMap[40];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
}
|
|
function right() {
|
|
const url = keyMap[39];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
}
|
|
function left() {
|
|
const url = keyMap[37];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
}
|
|
function pause() {
|
|
const url = keyMap[32];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
}
|
|
window.onload = function(){
|
|
storeInput();
|
|
}
|
|
|
|
document.addEventListener('keydown',(event) =>{
|
|
const key = event.keyCode;
|
|
const url = keyMap[key];
|
|
console.log(url);
|
|
sendCommand(url)
|
|
});
|
|
|
|
function sendCommand(url) {
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open('GET',url);
|
|
xhr.onload = () => {
|
|
const response = xhr.responseText;
|
|
console.log(response);
|
|
};
|
|
xhr.send();
|
|
}
|
|
|
|
function storeInput() {
|
|
ipInput = document.getElementById("ip").value;
|
|
valueRot = document.getElementById("valueRot").value;
|
|
valueLength = document.getElementById("valueLength").value;
|
|
keyMap={
|
|
38: 'http://'+ipInput+'/get?command=forward&value='+valueLength,
|
|
40: 'http://'+ipInput+'/get?command=backward&value='+valueLength,
|
|
37: 'http://'+ipInput+'/get?command=left&value='+valueRot,
|
|
39: 'http://'+ipInput+'/get?command=right&value='+valueRot,
|
|
32: 'http://'+ipInput+'/get?command=stop',
|
|
}
|
|
}
|
|
</script>
|
|
</html>
|