Dear All,
I am new to SUMO, OMNET++, and Veins, but somehow I have managed to run all of them for my project.
Now, I want to change the lane of all vehicles to lane#0 once they have received any WSM. However, I don't know the syntax and cannot understand how to use the function TraCIBuffer in TraCICommandInterface.
Could anyone kindly point out how it works for me or at least help sending me any links that I could learn more about it. I cannot find it or I may miss something. I will really appreciate it.
void TraCICommandInterface::Vehicle::changeRoute(std::string roadId, double travelTime) {
if (travelTime >= 0) {
uint8_t variableId = VAR_EDGE_TRAVELTIME;
uint8_t variableType = TYPE_COMPOUND;
int32_t count = 2;
uint8_t edgeIdT = TYPE_STRING;
std::string edgeId = roadId;
uint8_t newTimeT = TYPE_DOUBLE;
double newTime = travelTime;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << count << edgeIdT << edgeId << newTimeT << newTime);
ASSERT(buf.eof());
} else {
uint8_t variableId = VAR_EDGE_TRAVELTIME;
uint8_t variableType = TYPE_COMPOUND;
int32_t count = 1;
uint8_t edgeIdT = TYPE_STRING;
std::string edgeId = roadId;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << count << edgeIdT << edgeId);
ASSERT(buf.eof());
}
{
uint8_t variableId = CMD_REROUTE_TRAVELTIME;
uint8_t variableType = TYPE_COMPOUND;
int32_t count = 0;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << count);
ASSERT(buf.eof());
}
}
void TraCICommandInterface::Vehicle::changeLane(std::string roadId, double travelTime, std::string nodeId) {
std::string LaneId = getLaneId();
EV<<"Node "<< nodeId<< " is now on Lane Id = " << LaneId<<"\n";
//I can retrieve the lane id and host is at the moment but I am not sure how to send command to sumo to change the lane. Please kindly help.
}