Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Modify position, vel and acceleration of each actor

Hi Stefano,

In my case I'm doing this (with SUMO 1.16):
- moveToXY() with 'keepRoute' set mostly to 0 (once I go off-road I get into trouble if I use any placement bits)
- setSpeed()
- I don't call setAcceleration() (not for a particular reason)

In sumo-gui this can give slightly shaking vehicles, but I've attributed that to asynchronicity. Perhaps it's the mismatching acceleration which would make that better.
I didn't ever use setPreviousSpeed(); perhaps this other order helps, although I'm not sure how you define 'get the final wanted result' and if this order would mess that up.

Cheers,
Ruud


On Wed, Sep 13, 2023 at 12:38 AM Stefano Bonasera via sumo-user <sumo-user@xxxxxxxxxxx> wrote:
Hello,

I am trying to modify 1) position 2) velocity and 3) acceleration of each actor within my simulation to prescribed values that I chose.
Sumo version: 1.16.0 - interfaced with flow
What I currently do is
----------------------------
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!

--
Kind regards,
Stefano.
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top