Skip to content

Commit

Permalink
Merge pull request #48 from bark-simulator/lanetype-filtered-graph
Browse files Browse the repository at this point in the history
Stable Version of support for other Lanetype
  • Loading branch information
klemense1 committed Jul 22, 2019
2 parents 5862c2d + a75808b commit 68c7f49
Show file tree
Hide file tree
Showing 30 changed files with 1,190 additions and 478 deletions.
4 changes: 2 additions & 2 deletions docs/source/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ We run two Debuggers in parallel. First, check if the shared object "bark.so" co
```
For debugging;
1. Add a breakpoint in the python file you want to debug, somewhere before an interesting code section, run the launch configuration "Python: Current File" (see before) and wait until the breakpoint is reached.
2. Run the "(gdb) Attach" launch configuration, select the python interpreter whose path contains "/.vscode/"
2. Run the "(gdb) Attach" launch configuration, select the python interpreter whose path contains "/.vscode/". You will be promted to enter your user password.
3. Set breakpoints in the C++ Files
4. Now, with the F5 vscode automatically jumps between the two debuggers between python and c++ code.
4. The python debugger is currently stopped at a break point. Switch back from the debugger "(gdb) Attach" to the other debugger "Python: Current File" and press F5 (Continue). Now, vscode automatically jumps between the two debuggers between python and c++ code.
4 changes: 0 additions & 4 deletions examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ py_test(
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/viewer:pygame_viewer",
"//modules/runtime/viewer:matplotlib_viewer",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime:runtime",],
)

Expand All @@ -24,7 +23,6 @@ py_test(
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/viewer:pygame_viewer",
"//modules/runtime/viewer:matplotlib_viewer",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime:runtime",],
)

Expand All @@ -38,7 +36,6 @@ py_test(
imports = ['../python/'],
deps = ["//modules/runtime/commons:parameters",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime:runtime",
"//modules/runtime/scenario/scenario_generation:scenario_generation"],
)
Expand All @@ -53,7 +50,6 @@ py_test(
deps = [":scenario_generation_dump",
"//modules/runtime/commons:parameters",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime/viewer:pygame_viewer",
"//modules/runtime/viewer:matplotlib_viewer",
"//modules/runtime:runtime",
Expand Down
3 changes: 1 addition & 2 deletions examples/od8_const_vel_one_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
map_interface.set_open_drive_map(xodr_parser.map)
map_interface.set_roadgraph(xodr_parser.roadgraph)
world.set_map(map_interface)

# Agent Definition
agent_2d_shape = CarLimousine()
init_state = np.array([0, -11, -8, 3.14*3.0/4.0, 10/3.6])
agent_params = param_server.addChild("agent1")
goal_polygon = Polygon2d([0, 0, 0],[Point2d(-1,-1),Point2d(-1,1),Point2d(1,1), Point2d(1,-1)])
goal_polygon = goal_polygon.translate(Point2d(-191.789,-50.1725))

agent = Agent(init_state,
behavior_model,
dynamic_model,
Expand All @@ -60,7 +60,6 @@
world.add_agent(agent)

# viewer

viewer = PygameViewer(params=param_server,
x_range=[-50, 50],
y_range=[-50, 50],
Expand Down
2 changes: 1 addition & 1 deletion examples/od8_const_vel_two_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
agent_2d_shape = CarLimousine()
init_state = np.array([0, -11, -8, 3.14*3.0/4.0, 50/3.6])
goal_polygon = Polygon2d([0, 0, 0],[Point2d(-1,-1),Point2d(-1,1),Point2d(1,1), Point2d(1,-1)])
goal_polygon = goal_polygon.translate(Point2d(-191.789,-50.1725))
goal_polygon = goal_polygon.translate(Point2d(-63,-61))
agent_params = param_server.addChild("agent1")
agent1 = Agent(init_state,
behavior_model,
Expand Down
11 changes: 1 addition & 10 deletions modules/runtime/commons/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ py_library(
srcs = ["xodr_parser.py"],
data = ['//python:bark.so'],
imports = ['../../../python'],
deps = [":roadgraph_generator"],
visibility = ["//visibility:public"],
)

py_library(
name = "roadgraph_generator",
srcs = ["roadgraph_generator.py"],
data = ['//python:bark.so'],
imports = ['../../../python'],
deps = [],
visibility = ["//visibility:public"],
)
)
89 changes: 0 additions & 89 deletions modules/runtime/commons/roadgraph_generator.py

This file was deleted.

34 changes: 13 additions & 21 deletions modules/runtime/commons/xodr_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from bark.world.opendrive import *
from bark.world.map import *
from bark.geometry import *
from modules.runtime.commons.roadgraph_generator import RoadgraphGenerator


class XodrParser(object):
Expand All @@ -19,11 +18,7 @@ def __init__(self, file_name):
self.map = OpenDriveMap()
self.convert_to_map(self.python_map)
self.roadgraph = Roadgraph()
self.generate_roadgraph()

def generate_roadgraph(self):
rg = RoadgraphGenerator(self.roadgraph)
rg.generate(self.map)
self.roadgraph.Generate(self.map)

def load_file(self, file_name):
return open(file_name, 'r')
Expand Down Expand Up @@ -90,7 +85,7 @@ def parse_lane(self, lanes, lane_section):
lane_dict[int(lane.get("id"))] = lane

for id, lane in lane_dict.items():
if str(lane.get("type")) not in ["driving"]: #LaneType.__members__.keys(): # skip if lane type currently not supported
if str(lane.get("type")) not in ["driving", "border", "sidewalk"]: #LaneType.__members__.keys(): # skip if lane type currently not supported
continue
new_lane = {}
new_lane["id"] = id
Expand Down Expand Up @@ -265,17 +260,17 @@ def create_cpp_plan_view(self, plan_view):

def create_cpp_road_link(self, link):
# TODO(hart): insert road_link
new_link = Link()
new_link = RoadLink()
try:
new_pre_info = LinkInfo()
new_pre_info = RoadLinkInfo()
new_pre_info.id = int(link["predecessor"]["element_id"])
new_pre_info.type = link["predecessor"]["element_type"]
new_link.predecessor = new_pre_info
except:
pass

try:
new_suc_info = LinkInfo()
new_suc_info = RoadLinkInfo()
new_suc_info.id = int(link["successor"]["element_id"])
new_suc_info.type = link["successor"]["element_type"]
new_link.successor = new_suc_info
Expand All @@ -294,20 +289,17 @@ def create_cpp_road(self, road):
return new_road

def create_lane_link(self, link):
new_link = Link()
new_link = LaneLink()

try:
new_suc = LinkInfo()
new_suc.id = int(link["successor"])
new_link.successor = new_suc
new_link.from_position = int(link["predecessor"])
except:
print("Roadlink has no successor.")
print("No LaneLink.predecessor")
try:
new_pre = LinkInfo()
new_pre.id = int(link["predecessor"])
new_link.predecessor = new_pre
new_link.to_position = int(link["successor"])
except:
print("Roadlink has no predeseccor.")
print("No LaneLink.successor")

return new_link

def create_cpp_lane(self, new_lane_section, new_road, lane, s_start,
Expand Down Expand Up @@ -395,8 +387,8 @@ def create_cpp_junction(self, junction):
# TODO(hart): contact point
for lane_link in connection["lane_links"]:
new_lane_link = LaneLink()
new_lane_link.from_id = int(lane_link["from"])
new_lane_link.to_id = int(lane_link["to"])
new_lane_link.from_position = int(lane_link["from"])
new_lane_link.to_position = int(lane_link["to"])
new_connection.add_lane_link(new_lane_link)
new_junction.add_connection(new_connection)
return new_junction
Expand Down
6 changes: 2 additions & 4 deletions modules/runtime/ml/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ py_test(
"//modules/runtime/commons:parameters",
"//modules/runtime/commons:commons",
"//modules/runtime/scenario/scenario_generation:scenario_generation",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator"],
"//modules/runtime/commons:xodr_parser"],
visibility = ["//visibility:public"],
)

Expand All @@ -25,8 +24,7 @@ py_test(
"//modules/runtime/commons:parameters",
"//modules/runtime/commons:commons",
"//modules/runtime/scenario/scenario_generation:scenario_generation",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator"],
"//modules/runtime/commons:xodr_parser"],
visibility = ["//visibility:public"],
)

1 change: 0 additions & 1 deletion modules/runtime/scenario/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from bark.world import *
from bark.world.map import *
from modules.runtime.commons.parameters import ParameterServer
from modules.runtime.commons.roadgraph_generator import RoadgraphGenerator
from modules.runtime.commons.xodr_parser import XodrParser

import copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from bark.geometry import *
from bark.geometry.standard_shapes import *
from modules.runtime.commons.parameters import ParameterServer
from modules.runtime.commons.roadgraph_generator import RoadgraphGenerator
from modules.runtime.commons.xodr_parser import XodrParser

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions modules/runtime/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ py_test(
imports = ['../../../python/'],
deps = ["//modules/runtime/commons:parameters",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime:runtime"],
)

Expand All @@ -25,7 +24,6 @@ py_test(
imports = ['../../../python/'],
deps = ["//modules/runtime/commons:parameters",
"//modules/runtime/commons:xodr_parser",
"//modules/runtime/commons:roadgraph_generator",
"//modules/runtime/scenario/scenario_generation:scenario_generation"],
)

Expand Down
15 changes: 15 additions & 0 deletions modules/runtime/tests/data/CulDeSac_ideal.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
digraph G {
0[label="road_id=1 lane_id=1 lane_pos=0"];
1[label="road_id=1 lane_id=2 lane_pos=1"];
2[label="road_id=1 lane_id=3 lane_pos=-1"];
3[label="road_id=3 lane_id=4 lane_pos=0"];
4[label="road_id=3 lane_id=5 lane_pos=-1"];
2->4 [label="0"color="red"];
4->1 [label="0"color="red"];
1->0 [label="1"color="blue"];
0->1 [label="2"color="blue"];
2->0 [label="1"color="blue"];
0->2 [label="2"color="blue"];
4->3 [label="1"color="blue"];
3->4 [label="2"color="blue"];
}

0 comments on commit 68c7f49

Please sign in to comment.