GithubHelp home page GithubHelp logo

dacuotecuo / libopendrive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pageldev/libopendrive

0.0 0.0 0.0 1014 KB

Small, lightweight C++ library for handling OpenDRIVE files

License: Apache License 2.0

Shell 0.13% JavaScript 11.77% C++ 84.97% C 0.76% HTML 1.51% CMake 0.86%

libopendrive's Introduction

libOpenDRIVE

libOpenDRIVE is a lightweight, dependency-free, fast C++ library providing OpenDRIVE file parsing and 3D model generation.

It's small and can be easily integrated in other projects. It can be compiled to a WebAssembly library and includes JavaScript bindings. A core function is the parsing of OpenDRIVE files and the generation of 3D models. The library targets OpenDRIVE version 1.4.

Example

Here's an example of how code using libOpenDRIVE looks. For a more complete example refer to test.cpp.

// load map
odr::OpenDriveMap odr_map("data.xodr");

// iterate roads
for (odr::Road road : odr_map.get_roads())
    std::cout << "road: " << road.id << " length: " << road.length << std::endl;

// get xyz point for road coordinates
odr::Road odr_road = odr_map.id_to_road.at("508");
odr::Vec3D pt_xyz = odr_road.get_xyz(2.1 /*s*/, 1.0 /*t*/, 0.0 /*h*/);

// access road network attributes
std::string lane_type = odr_road.get_lanesection(0.0).id_to_lane.at(-1).type;

// use routing graph
odr::RoutingGraph routing_graph = odr_map.get_routing_graph();
odr::LaneKey from("516" /*road id*/, 0.0 /*lane section s0*/, 1 /*lane id*/);
odr::LaneKey to("501", 0.0, -1);
std::vector<odr::LaneKey> path = routing_graph.shortest_path(from, to);

Viewer

To use the included viewer first build the WebAssembly library and then run a webserver in the Viewer/ directory (e.g. python3 -m http.server). Or you can test the viewer online.

Also check out the viewer at odrviewer.io which uses this library.

Build

To build the library simply run:

mkdir build && cd build
cmake ..
make

This also builds an executable to test the library:

./build/test-xodr Viewer/data.xodr

WebAssembly

Install emsdk and run the following commands to build the WebAssembly library:

mkdir build && cd build
emcmake cmake ..
emmake make

This will create the files ModuleOpenDrive.js/.wasm. To run the viewer copy them to the Viewer/ directory.

cp ModuleOpenDrive.* ../Viewer

Javascript Example

Refer to the code in main.js for an example.

odr_map = new Module.OpenDriveMap("./data.xodr", odr_map_config);

libopendrive's People

Contributors

pageldev avatar flok avatar mkahra14 avatar victorjarlow avatar cxruan1999 avatar eganj avatar ovo4096 avatar

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.