I think this topic is quite similar to Github issue #13647
<https://github.com/eclipse-sumo/sumo/issues/13647> in expecting specific 
control over internal computation of dynamics. The main question is: Should 
a use of moveToXY() invalidate computation of speed and acceleration and 
which values sumo should return when asked via TraCI?
 
At the moment, speed and acceleration are updated on moveToXY() and undergo 
a series of checks to avoid extreme values. The setSpeed command sets a new 
speed target for the vehicle in the following time steps (until disabling 
it with a negative value).
 
Best regards
Mirko
 
 
 
 
-----Original-Nachricht-----
Betreff: Re: [sumo-user] Modify position, vel and acceleration of each 
actor
Datum: 2023-09-14T10:59:51+0200
Von: "Ruud van Gaal via sumo-user" <[email protected]>
An: "Stefano Bonasera" <[email protected]>
 
 
 
Hi Stefano,
 
Indeed, no changing in vehicle state takes place until you simulate a step. 
You would say it's a linear system but I can imagine two methods:
 
1: v=v+a*dt, p=p+v*dt
2: p=v+v*dt, v=v+a*dt
 
This may account for a change in your expectations regarding position after 
a simulation step. What do you get for position when setting position to 
(0,0,0), adding velocity of (1,0,0) and an acceleration of (10,0,0) and 
taking a small step?
Note also that I also call Simulation::step(0) to step one-by-one. This 
makes it possible to set my own position/velocity (etc) at every step. If I 
don't and use Simulation::step(tNow), internally after 1 timestep, SUMO 
takes over and starts calculating its own speed etc again. So make sure you 
overrule your inputs at every step.
 
Cheers,
Ruud
 
 

On Wed, Sep 13, 2023 at 5:43 PM Stefano Bonasera <
[email protected] <mailto:[email protected]> > wrote:
  Hi Ruud,

  Thanks for the answer.
  I noticed that with your set of commands I cannot see an actual
  modification of actors position and velocity: this means that, if after
  your commands I getPosition() or getSpeed() for the "modified" actors, I
  will then get the same values that I had prior to your list of commands -
  this is why I need to simulate the step.
  Sorry, the 'get the final wanted result' in my case means that I can: 
  1) modify position velocity and acc of each actor that I want (say, actor
  1 was at (x, y, v, a) = (1, 1, 1, 1) but I want it at (x, y, v, a) = (2,
  3, 4, 5))
  2) when I try to getXXX(), I would then get the values that I wanted for
  each specific actor (following above, I get (x, y, v, a) = (2, 3, 4, 5)
  for that specific actor).

  Stefano

  On Wed, Sep 13, 2023 at 4:34 AM Ruud van Gaal <[email protected]
  <mailto:[email protected]> > wrote:
    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 <
    [email protected] <mailto:[email protected]> > 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
      [email protected] <mailto:[email protected]>
      To unsubscribe from this list, visit
      <https://www.eclipse.org/mailman/listinfo/sumo-user>

   
  --
  Kind regards,
  Stefano.
 

_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to