-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from thibo73800/dev
Dev
- Loading branch information
Showing
46 changed files
with
2,734 additions
and
227 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Metacar: Continous control in traffic</title> | ||
<link rel="icon" href="/public/img/icon.png"> | ||
<link rel="stylesheet" href="/public/css/general.css"> | ||
<link href="https://fonts.googleapis.com/css?family=Tajawal" rel="stylesheet"> | ||
</head> | ||
<body> | ||
|
||
<header> | ||
<div class="header_container"> | ||
<h1><a href="/">Metacar</a></h1> | ||
<a href="https://github.com/thibo73800/metacar"><img src="/public/img/github-logo.png" /></a> | ||
</div> | ||
</header> | ||
|
||
<div class="canvas_container"> | ||
<!-- | ||
You just have to add a div with an ID as bellow and include the js to start | ||
using metacar. --> | ||
<div class="canvas" id="canvas"></div> | ||
</div> | ||
|
||
<div class="body_container"> | ||
<h3 id="trainingProgress"></h3> | ||
<h3 style="float: left" >Current state (Lidar points)</h3><br><br><br> | ||
<div id="realtime_viewer" style="float: left"></div> | ||
<p> | ||
The algorithm is based on the following papers: | ||
<ul style="margin:0;"> | ||
<li><b>Deep Deterministic Policy Gradients (DDPG): <a href="https://arxiv.org/abs/1509.02971">paper</a></b> </li> | ||
<li><b>Parameter Space Noise for Exploration</b>: <a href="https://blog.openai.com/better-exploration-with-parameter-noise/">paper</a> </li> | ||
</ul> | ||
<br> | ||
You can use the <b>arrow keys</b> to control the car by yourself.<br><br> | ||
|
||
The motion control is based on two continuous values for the throttle and steering angle of the car. | ||
|
||
<br><br>The left window gives you an overview of what the autonomous vehicle (in red) sees.<br><br> | ||
|
||
You can find the code of this demo <a href="https://github.com/thibo73800/metacar/tree/master/demo/webapp/public/js/ddpg/">here</a> and <a href="https://github.com/thibo73800/metacar/tree/master/demo/webapp/public/js/ddpg-traffic/">here</a>. | ||
</p> | ||
</div> | ||
|
||
<br> | ||
<div class="body_container" id="statContainer" style="position:relative"></div> | ||
|
||
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.7.1/pixi.min.js"></script> | ||
<script src="/dist/metacar.min.js"></script> | ||
|
||
<script type="text/javascript" src="/public/js/utils.js"></script> | ||
<script type="text/javascript" src="/public/js/viewer.js"></script> | ||
|
||
<script type="text/javascript" src="/public/js/ddpg/models.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/memory.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/prioritized_memory.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/noise.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/ddpg.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/ddpg_agent.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg-traffic/index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Metacar: Continous control</title> | ||
<link rel="icon" href="/public/img/icon.png"> | ||
<link rel="stylesheet" href="/public/css/general.css"> | ||
<link href="https://fonts.googleapis.com/css?family=Tajawal" rel="stylesheet"> | ||
</head> | ||
<body> | ||
|
||
<header> | ||
<div class="header_container"> | ||
<h1><a href="/">Metacar</a></h1> | ||
<a href="https://github.com/thibo73800/metacar"><img src="/public/img/github-logo.png" /></a> | ||
</div> | ||
</header> | ||
|
||
<div class="canvas_container"> | ||
<!-- | ||
You just have to add a div with an ID as bellow and include the js to start | ||
using metacar. --> | ||
<div class="canvas" id="canvas"></div> | ||
</div> | ||
|
||
<div class="body_container"> | ||
<h3 id="trainingProgress"></h3> | ||
<h3 style="float: left" >Current state (Lidar points)</h3><br><br><br> | ||
<div id="realtime_viewer" style="float: left"></div> | ||
<p> | ||
The algorithm is based on the following papers: | ||
<ul style="margin:0;"> | ||
<li><b>Deep Deterministic Policy Gradients (DDPG): <a href="https://arxiv.org/abs/1509.02971">paper</a></b> </li> | ||
<li><b>Parameter Space Noise for Exploration</b>: <a href="https://blog.openai.com/better-exploration-with-parameter-noise/">paper</a> </li> | ||
</ul> | ||
<br> | ||
You can use the <b>arrow keys</b> to control the car by yourself.<br><br> | ||
|
||
The motion control is based on two continuous values for the throttle and steering angle of the car. | ||
|
||
<br><br>The left window gives you an overview of what the autonomous vehicle (in red) sees.<br><br> | ||
|
||
You can find the code of this demo <a href="https://github.com/thibo73800/metacar/tree/master/demo/webapp/public/js/ddpg/">here</a>. | ||
</p> | ||
</div> | ||
|
||
<br> | ||
<div class="body_container" id="statContainer" style="position:relative"></div> | ||
|
||
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.7.1/pixi.min.js"></script> | ||
<script src="/dist/metacar.min.js"></script> | ||
|
||
<script type="text/javascript" src="/public/js/utils.js"></script> | ||
<script type="text/javascript" src="/public/js/viewer.js"></script> | ||
|
||
<script type="text/javascript" src="/public/js/ddpg/models.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/prioritized_memory.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/memory.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/noise.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/ddpg.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/ddpg_agent.js"></script> | ||
<script type="text/javascript" src="/public/js/ddpg/index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
let levelUrl = metacar.level.level3; | ||
|
||
var env = new metacar.env("canvas", levelUrl); | ||
|
||
env.setAgentMotion(metacar.motion.ControlMotion, {}); | ||
env.setAgentLidar({pts: 7, width: 3, height: 7, pos: -0.5}) | ||
|
||
// js/DDPG/ddpg.js | ||
var agent = new DDPGAgent(env, { | ||
stateSize: 50, | ||
resetEpisode: true, | ||
desiredActionStddev: 0.4, | ||
initialStddev: 0.4, | ||
actorFirstLayerSize: 128, | ||
actorSecondLayerSize: 64, | ||
criticFirstLayerSSize: 128, | ||
criticFirstLayerASize: 128, | ||
criticSecondLayerSize: 64, | ||
nbEpochs: 1000 | ||
}); | ||
|
||
initMetricsContainer("statContainer", ["Reward", "ActorLoss", "CriticLoss", "EpisodeDuration", "NoiseDistance"]); | ||
|
||
let it = 0; | ||
env.loop(() => { | ||
let state = env.getState(); | ||
displayState("realtime_viewer", state.lidar, 200, 200); | ||
let reward = env.getLastReward(); | ||
const qValue = agent.getQvalue(state.linear, [state.a, state.steering]); | ||
if (it % 10 == 0) | ||
displayScores("realtime_viewer", [qValue, state.a, state.steering], reward, ["Q(a, s)", "Acceleration", "Steering Angle"]); | ||
it += 1; | ||
}); | ||
|
||
env.load().then(() => { | ||
|
||
env.addEvent("train [Background]", () => { | ||
let train = confirm("The training process takes some time and might slow this tab. Do you want to continue? \n You can also load a pre-trained model."); | ||
if (train){ | ||
env.render(false); | ||
agent.train(false); | ||
} | ||
}); | ||
|
||
env.addEvent("Train [Show the training]", () => { | ||
env.steping(false); | ||
agent.train(true); | ||
}); | ||
|
||
env.addEvent("play", () => { | ||
agent.play(); | ||
}); | ||
|
||
env.addEvent("stop", () => { | ||
agent.stop(); | ||
}); | ||
|
||
env.addEvent("reset_env"); | ||
|
||
env.addEvent("save", () => { | ||
agent.save("model-ddpg-traffic"); | ||
}); | ||
|
||
env.addEvent("load", () => { | ||
agent.restore("ddpg-traffic", "model-ddpg-traffic-epoch-120"); | ||
}); | ||
}); | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.