-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't pickle bark.core.models.behavior.BehaviorModel objects #572
Comments
The tutorial code is similar to the test cases implemented in bark/models/tests/py_behavior_model_test.py You can have a look there and see if your implementation follows the test implementation. If errors persist, please add your code here and describe your build and execution pipeline. |
The problem occurs if the derived behavior model is returned from the controlled_behavior_model() in the CustomLaneCorridorConfig class. The implementation of DerivedBehaviorModel follows the ones in bark/models/tests/py_behavior_model_test.py. Ubuntu 18.04 Running the following code (which comes from the tutorial) leads to the pickle error import numpy as np
from bark.core.world.opendrive import *
from bark.core.world.goal_definition import *
from bark.core.models.behavior import BehaviorModel
from bark.core.models.behavior import BehaviorMobilRuleBased
from bark.runtime.runtime import Runtime
from bark.examples.paths import Data
from bark.runtime.commons.parameters import ParameterServer
from bark.runtime.viewer.matplotlib_viewer import MPViewer
from bark.runtime.scenario.scenario_generation.config_with_ease import \
LaneCorridorConfig, ConfigWithEase
params = ParameterServer()
class DerivedBehaviorModel(BehaviorModel):
def __init__(self, params=None):
super(DerivedBehaviorModel, self).__init__(params)
def Plan(self, step_time, observed_world):
super(DerivedBehaviorModel, self).ActionToBehavior(np.array([2., 1.], dtype=np.float32))
trajectory = np.array([[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.]], dtype=np.float32)
super(DerivedBehaviorModel, self).SetLastTrajectory(trajectory)
return trajectory
def Clone(self):
return self
class CustomLaneCorridorConfig(LaneCorridorConfig):
def __init__(self, params=None, **kwargs):
super(CustomLaneCorridorConfig, self).__init__(params, **kwargs)
def goal(self, world):
road_corr = world.map.GetRoadCorridor(self._road_ids, XodrDrivingDirection.forward)
lane_corr = self._road_corridor.lane_corridors[0]
return GoalDefinitionPolygon(lane_corr.polygon)
def controlled_behavior_model(self, world):
return DerivedBehaviorModel(self._params)
# configure both lanes
left_lane = CustomLaneCorridorConfig(params=params,
lane_corridor_id=0,
road_ids=[0, 1],
behavior_model=BehaviorMobilRuleBased(params),
s_min=0.,
s_max=50.)
# this lane has controlled_ids; ego vehicle is placed on this lane
right_lane = CustomLaneCorridorConfig(params=params,
lane_corridor_id=1,
road_ids=[0, 1],
controlled_ids=True,
behavior_model=BehaviorMobilRuleBased(params),
s_min=0.,
s_max=20.)
# finally, generate 3 scenarios on the merging map
scenarios = \
ConfigWithEase(
num_scenarios=3,
map_file_name=Data.xodr_data("DR_DEU_Merging_MT_v01_shifted"),
random_seed=0,
params=params,
lane_corridor_configs=[left_lane, right_lane])
viewer = MPViewer(params=params,
x_range=[-35, 35],
y_range=[-35, 35],
follow_agent_id=True)
env = Runtime(step_time=0.2,
viewer=viewer,
scenario_generator=scenarios,
render=True)
# run 3 scenarios
for _ in range(0, 3):
env.reset()
# step scenario 90 time-steps
for step in range(0, 90):
env.step() |
I'm trying to reproduce the developing behavior model tutorial in Ubuntu 18.04 and conda install.
In both the pip install and the source installation execution fails with the error
can't pickle bark.core.models.behavior.BehaviorModel objects
.I couldn't find any documentation or issue related to that topic. Do I miss something? How can I fix this?
Here is the full output
output.txt
The text was updated successfully, but these errors were encountered: