Cannot simulate_step

hi. i cannot simulate_step. what’s wrong with it?I want to know if there is a problem with my installation or my code. In addition, I was able to run through the minimal_example code.
there is my code.

folder_scenarios = os.path.abspath(’/home/thicv/codes/commonroad/commonroad-scenarios/scenarios/scenarios_cr_competition/competition_scenarios_new/interactive/’)
name_scenario = “DEU_Frankfurt-4_3_I-1”
interactive_scenario_path = os.path.join(folder_scenarios, name_scenario)

conf = load_sumo_configuration(interactive_scenario_path)
scenario_file = os.path.join(interactive_scenario_path, f"{name_scenario}.cr.xml")
scenario, planning_problem_set = CommonRoadFileReader(scenario_file).open()
planning_problem = list(planning_problem_set.planning_problem_dict.values())[0]

scenario_wrapper = ScenarioWrapper()
scenario_wrapper.sumo_cfg_file = os.path.join(interactive_scenario_path, f"{conf.scenario_name}.sumo.cfg")
scenario_wrapper.initial_scenario = scenario

num_of_steps = conf.simulation_steps

sumo_sim = SumoSimulation()

# initialize simulation
sumo_sim.initialize(conf, scenario_wrapper, None)
sumo_sim.simulate_step()

And here is the error info when i debug in vscode.

No planned trajectory found at time step 0 for ego vehicle 40673! Use ego_vehicle.set_planned_trajectory() to set the trajectory.
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/ego_vehicle.py”, line 115, in get_planned_state
f"No planned trajectory found at time step {self.current_time_step} for ego vehicle {self.id}! "
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/sumo_simulation.py”, line 781, in _send_ego_vehicles
planned_state = ego_vehicle.get_planned_state(delta_step)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/sumo_simulation.py”, line 378, in simulate_step
self._send_ego_vehicles(self.ego_vehicles, i)
File “/home/thicv/codes/commonroad/commonroad_planner/main_interactive_CRplanner.py”, line 121, in
sumo_sim.simulate_step()
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/runpy.py”, line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/runpy.py”, line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/runpy.py”, line 193, in _run_module_as_main (Current frame)
main”, mod_spec)

And there is the error info when i use ternimal.

Traceback (most recent call last):
File “main_interactive_CRplanner.py”, line 121, in
sumo_sim.simulate_step()
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/sumo_simulation.py”, line 378, in simulate_step
self._send_ego_vehicles(self.ego_vehicles, i)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/sumo_simulation.py”, line 781, in _send_ego_vehicles
planned_state = ego_vehicle.get_planned_state(delta_step)
File “/home/thicv/miniconda3/envs/cr37/lib/python3.7/site-packages/sumocr/interface/ego_vehicle.py”, line 115, in get_planned_state
f"No planned trajectory found at time step {self.current_time_step} for ego vehicle {self.id}! "
AssertionError: No planned trajectory found at time step 0 for ego vehicle 40673! Use ego_vehicle.set_planned_trajectory() to set the trajectory.
Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown
Quitting (on error).

Hi, in your code, it looks like you don’t provide the trajectory for the ego vehicle. The error message sounds like this as well:

No planned trajectory found at time step 0 for ego vehicle 40673! Use ego_vehicle.set_planned_trajectory() to set the trajectory."

The state planned for the next time step needs to be sent before every simulation step to the simulator.

Did you already have a look at the suggested tutorial? It explains how to run the scenarios using the code from https://gitlab.lrz.de/tum-cps/commonroad-interactive-scenarios

:slight_smile: thanks for your reply.
i am still confused. As you can see, that’s the beginning of my code. I try to get the first frame information so I use simulate_step() just after the initialize().

i don’t have any ego trajectory just because I don’t get any information of obstacles. It seems I can run through the code with previous version of sumocr but not the version now.

Even before the first call of sumo_sim.simulate_step() you need to send the ego vehicle’s trajectory.

The problem was indeed that in the last sumocr version the obstacles were not collected properly during the initialization, thanks for pointing that out. This was just fixed in the latest version so please update sumocr.

:slight_smile: thank you very much! really helps a lot!