0

I am running the stabilizing_highway example from flow/examples/rllib. I noticed that sometimes, during the state calculation in the merge environment:

    for i, rl_id in enumerate(self.rl_veh):
        this_speed = self.k.vehicle.get_speed(rl_id)

I am getting values of this_speed=-1001 every now and then. This is always the first observation when a new simulation is started (and I guess thats the reason for the warmup_steps parameter in the environment. But later during the simulation, this keeps happening too.

What could be the reasons for sumo giving back the error=-1001 value?

bmartin
  • 15
  • 3

1 Answers1

0

If you read the docstring of the get_speed function, you will see that it returns -1001 if the id of the vehicle is not found.

In the _apply_rl_actions method a test is done to see if the vehicle id exists:

        for i, rl_id in enumerate(self.rl_veh):
            # ignore rl vehicles outside the network
            if rl_id not in self.k.vehicle.get_rl_ids():
                continue
            self.k.vehicle.apply_acceleration(rl_id, rl_actions[i])

I guess this test is not performed in get_state because we need to output some value for the observation anyway since it is fixed size, whether it is the actual speed or a constant value -1001 meaning it's not an actual vehicle.

math.husky
  • 193
  • 1
  • 8
  • Thanks. This might not make any difference for the speed related observations (after clipping negative values to the observation space to [0..1], but the heading related observations will be e.g. lead_head / max_length = 1.0, whille without any vehicle this will be zero using zero padding. – bmartin Jul 23 '19 at 13:41
  • and (lead_speed - this_speed) / max_speed = 34.36666666666667 – bmartin Jul 23 '19 at 13:42