Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] sumo vehicle speed

Hi Mahima,


if you want to control the vehicle dynamics completely with your own logic, then please refer to vehicle.setSpeed and vehicle.moveToXY functions. You will have to call them in every time step you want the vehicle to follow your custom rules. On the opposite calling vehicle.slowDown with a positive duration > 0 will make the vehicle adapt its speed taking into account safety and dynamic constraints (gap, max. accel/decel). If you want to deactivate some constraints regarding speed, there is vehicle.setSpeedMode (see docs).


Best regards







Betreff: [sumo-user] sumo vehicle speed

Datum: 2023-01-23T16:36:07+0100

Von: "Mahima" <mahima13@xxxxxxxxx>

An: "Sumo project User discussions" <sumo-user@xxxxxxxxxxx>




 I want to move the vehicle to some edge.

I read speed, accel and position using these commands which give values of the last timestep.
And then I use the following commands in the current timestep so that I get the desired position and speed in the  next timestep.
libsumo::Vehicle::setPreviousSpeed(veh, speed, accel);
libsumo::Vehicle::moveTo(veh, cmd.lane_id(), lane_pos);
Then, I check the leader
double frontGapNeeded = libsumo::Vehicle::getSecureGap(veh, speed, libsumo::Vehicle::getSpeed(leader.first), libsumo::Vehicle::getDecel(leader.first));
double followSpeed=libsumo::Vehicle::getFollowSpeed(veh, speed, frontGapNeeded, libsumo::Vehicle::getSpeed(leader.first), libsumo::Vehicle::getDecel(leader.first), leader.first);
                double frontMax = frontGapNeeded + (-leader.second);
                 double new_speed = std::min(speed, followSpeed);            
                 double pos = std::min(lane_pos, frontMax);

Then, i set the vehicle speed as per the leader.
libsumo::Vehicle::slowDown(veh, followSpeed, 0);
But, I am not getting desired results. Is there any way to  get speed in the current timestep?



Back to the top