Git Product home page Git Product logo

carla_apollo_bridge's Introduction


Carla Apollo Bridge

Carla & Apollo Co-simulation
View Demo · Report Bug · Request Feature

visitor issues issues-closed issues-pr last-commit TODOs milestones repo-size lines language License: Apache 2.0 stars

About

This project aims to provide a data and control bridge for the communication between Carla and Apollo. It was tested with Carla 0.9.14 and the Apollo master branch (newer than v7.0.0)

image

Getting Started

Prerequisites

We will run Carla and Apollo in docker. Furthermore, NVIDIA Container Toolkit is needed. You can refer to the following link to install NVIDIA Container Toolkit:

Alternatively, simply perform the following steps:

  • docker

    sudo apt-get install docker.io
  • NVIDIA Container Toolkit

    curl https://get.docker.com | sh \
    && sudo systemctl --now enable docker
    distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
        && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
        && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
              sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
              sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
    sudo apt-get update
    sudo apt-get install -y nvidia-docker2
    sudo systemctl restart docker

Build And Run Apollo

  1. We patched Apollo in order to work with our bridge, for now please use the guardstrike/apollo_carla_bridge branch from our fork.

    # Using SSH
    git clone --branch guardstrike/apollo_carla_bridge [email protected]:guardstrikelab/apollo.git
    
    #Using HTTPS
    git clone --branch guardstrike/apollo_carla_bridge https://github.com/guardstrikelab/apollo.git

    We will be sending this patch upstream soon so that you can just clone the official Apollo next time.

  2. Build Apollo

    cd apollo
    echo "export APOLLO_ROOT_DIR=$(pwd)" >> ~/.bashrc  && source ~/.bashrc

    Then, run:

    bash docker/scripts/dev_start.sh

    to start Apollo development docker container.
    If you encounter any error, try

    sudo rm -rf /apollo/.cache
    bash docker/scripts/dev_start.sh

    Upon successful execution, you will see the following message

    [ OK ] Congratulations! You have successfully finished setting up Apollo Dev Environment.
    [ OK ] To login into the newly created apollo_dev_lei container, please run the following command:
    [ OK ]   bash docker/scripts/dev_into.sh
    [ OK ] Enjoy!

    Above If you occured error as "ERROR: Config value 'cuda' is not defined in any .rc file",you can try

    ./apollo.sh config -n

    Run this command to enter the container

    bash docker/scripts/dev_into.sh

    Make the GPU version:

    ./apollo.sh build_gpu

    After successful compilation, the following will be printed:

    ==============================================
    [ OK ] Done building apollo. Enjoy!
    ==============================================

    Run this command in the container to start Dreamview

    ./scripts/bootstrap.sh

    Finally, open the link in your browser

    http://localhost:8888/

Run Carla

  • Clone the carla_apollo_bridge project

    # Using SSH
    git clone [email protected]:guardstrikelab/carla_apollo_bridge.git
    
    #Using HTTPS
    git clone https://github.com/guardstrikelab/carla_apollo_bridge.git
  • To download and install Compose standalone, run:

     sudo curl -L "https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  • Change File Permission:

    sudo chmod +x /usr/local/bin/docker-compose 

Apply executable permissions to the standalone binary in the target path for the installation. Test and execute compose commands using docker-compose. Note: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path. For example:

 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  • Pull carla image and run

    cd carla_apollo_bridge/scripts
    ./docker_run_carla.sh

Run carla_apollo_bridge

  1. Run the following to enter the container. Note that carla_apollo_bridge/src is mapped to /apollo/cyber/carla_bridge within the container, this allows you to test any change you make to the bridge.

    cd carla_apollo_bridge/docker
    ./build_docker.sh
    ./run_docker.sh
    docker exec -ti carla_cyber_0.9.14 bash
  2. Compile

    Run the following command in the container

    ./apollo.sh build_cyber opt

    The following information is displayed after the compilation is successful:

    [INFO] Skipping revision recording
    ============================
    [ OK ] Build passed!
    [INFO] Took 61 seconds
  3. Start the bridge and spawn the ego vehicle

    Run the following command in the container.

    cd /apollo/cyber/carla_bridge
    python carla_cyber_bridge/bridge.py

    Start a new terminal and run:

    docker exec -ti carla_cyber_0.9.14 bash
    cd /apollo/cyber/carla_bridge
    python carla_spawn_objects/carla_spawn_objects.py

Result

If everything above goes well, you should see this in Apollo client:

image

and this in Carla:

image

Example: start a co-simulation

  1. Open apollo client: http://localhost:8888
  2. (Optional) Select "Task" in the sidebar and turn on "Camera Sensor" in "Others".
  3. (Optional) Select "Layer Menu" in the sidebar and turn on "Point Cloud" in "Perception".
  4. Select "Module Controller" in the sidebar and turn on "Routing" module.
  5. Select "Route Editing" in the sidebar.
  6. Click "Add Point of Interest" and left click at any point on the road to set the destination.
  7. Click "Send Routing Request".
  8. Select "Tasks" and click "Setup" to start co-simulation.

More

Deployment Network Introduction

Contribution

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contribution you make is greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache-2.0 License. See LICENSE for more information.

Acknowledgments

This work is based on the following open-source projects:

(back to top)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.