for loop over all the actors
self.k.kernel_api.vehicle.setPreviousSpeed(
vehID=actor_id,
speed=wanted_velocity - wanted_acceleration*simulation_step)
self.k.vehicle.moveToXY(
veh_id=actor_id,
edge_id=actor.edge,
lane=actor.lane,
posX=actor.pos_2d[0],
posY=actor.pos_2d[1],
angle=self.k.vehicle.get_angle(actor.actor_id),
keepRoute=1,
)
self.k.kernel_api.vehicle.setAcceleration(
vehID=actor.actor_id,
acceleration=actor.acceleration * 2,
duration=self.sim_step)
end for
self.k.simulation.simulation_step()
--------------------------------------
With this approach I can successfully set each actor position velocity and accelerations to my values. However it seems the success is really depending on the sequence of steps (for example setting moveToXY prior to setPreviousSpeed results in an unsuccessful final outcome - no error, just not getting what I want).
Therefore, I have the following questions:
0) Is what I am doing 1) feasible and 2) sound, given the above mentioned sequence of commands?
1) I tried to use setSpeed multiple times instead of setPreviousSpeed, but it doesn't work. Can you help me understand why?
2) It seems weird that I have to double my wanted acceleration (see acceleration=actor.acceleration * 2) to get the final wanted result. Why is that happening?
Thanks in advance for the help!