Skip to main content

Machine Learning Applied to Autonomous Driving

Project description

BARK-ML

BARK-ML - Machine Learning for Autonomous Driving

CI Build CI-DIADEM Build

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

BARK-ML Highway

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 environment
  • highway-v1: Discrete highway environment
  • merging-v0: Continuous merging environment
  • merging-v1: Discrete merging environment
  • intersection-v0: Continuous intersection environment
  • intersection-v1: Discrete intersection environment

TF-Agents

SAC-Agent learning a merging scenario:

import gym
import os
os.environ['GLOG_minloglevel'] = '3' 

# BARK imports
from bark.runtime.commons.parameters import ParameterServer
from bark.runtime.viewer.matplotlib_viewer import MPViewer

# 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


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.2.tar.gz (3.4 MB view hashes)

Uploaded Source

Built Distributions

bark_ml-0.2.2-py3-none-any.whl (4.0 MB view hashes)

Uploaded Python 3

bark_ml-0.2.2-cp37-cp37m-macosx_10_15_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page