Skip to main content

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

Hi,

 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.
libsumo::Vehicle::getLanePosition(veh));
libsumo::Vehicle::getSpeed(veh));
libsumo::Vehicle::getAcceleration(veh)

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?

Thanks


Back to the top