Machine Learning Applied to Autonomous Driving
Project description
BARK-ML - Machine Learning for Autonomous Driving
BARK-ML provides simple-to-use OpenAi-Gym environments for several scenarios, such as highway driving, merging and intersections. Additionally, BARK-ML integrates state-of-the-art machine learning libraries to learn driving behaviors for autonomous vehicles.
BARK-ML supported machine learning libraries:
Install BARK-ML using pip install bark-ml
.
Gym Environments
import gym
import numpy as np
import bark_ml.environments.gym
# environment
env = gym.make("merging-v0")
env.reset()
done = False
while done is False:
# random action
action = np.random.uniform(
low=np.array([-0.5, -0.1]), high=np.array([0.5, 0.1]), size=(2, ))
# step the world
observed_next_state, reward, done, info = env.step(action)
print(f"Observed state: {observed_next_state}, Action: {action}, Reward: {reward}, Done: {done}")
Available environments:
highway-v0
: Continuous highway environmenthighway-v1
: Discrete highway environmentmerging-v0
: Continuous merging environmentmerging-v1
: Discrete merging environmentintersection-v0
: Continuous intersection environmentintersection-v1
: Discrete intersection environment
TF-Agents
SAC-Agent learning a merging scenario:
import gym
from absl import app
from absl import flags
import os
os.environ['GLOG_minloglevel'] = '3'
# BARK imports
from bark.runtime.commons.parameters import ParameterServer
from bark.runtime.viewer.matplotlib_viewer import MPViewer
from bark.runtime.viewer.video_renderer import VideoRenderer
# BARK-ML imports
from bark_ml.environments.blueprints import ContinuousMergingBlueprint
from bark_ml.environments.single_agent_runtime import SingleAgentRuntime
from bark_ml.library_wrappers.lib_tf_agents.agents import BehaviorSACAgent
from bark_ml.library_wrappers.lib_tf_agents.runners import SACRunner
params = ParameterServer()
params["World"]["remove_agents_out_of_map"] = True
# create environment
bp = ContinuousMergingBlueprint(params,
number_of_senarios=2500,
random_seed=0)
env = SingleAgentRuntime(blueprint=bp,
render=False)
# SAC-agent
sac_agent = BehaviorSACAgent(environment=env, params=params)
env.ml_behavior = sac_agent
runner = SACRunner(params=params,
environment=env,
agent=sac_agent)
runner.Train()
runner.Visualize(5)
License
BARK-ML specific code is distributed under MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bark-ml-0.2.0.tar.gz
(3.4 MB
view hashes)
Built Distribution
Close
Hashes for bark_ml-0.2.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b51a9c1accfe9d778478f5af3c54068705221f66a018ab4e5b7cab26480ab81e |
|
MD5 | a724e0ace53a6c1e3258e5a9b15c142d |
|
BLAKE2b-256 | 4e0fca9f406241553356104792631addd776bc5e01683b31035fbf73c981a9f8 |