Could anyone suggest how to use TraCIBuffer to change the lane in Veins?

16 views
Skip to first unread message

Chakky

unread,
Jun 20, 2018, 10:31:03 AM6/20/18
to OMNeT++ Users


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.
}

Christoph Sommer

unread,
Jun 21, 2018, 3:56:55 AM6/21/18
to andoklopez via OMNeT++ Users
Chakky wrote:
>
> I want to change the lane of all vehicles to lane#0

You will probably need to find out how to do this in SUMO first, then how to do this using SUMO's TraCI API, then how to extend Veins' TraCI API.

To get you started, here's the SUMO Wiki Page on what the TraCI API can currently do:

http://www.sumo.dlr.de/wiki/TraCI/Change_Vehicle_State#change_lane_.280x13.29

http://www.sumo.dlr.de/wiki/TraCI/Change_Vehicle_State#lane_change_mode_.280xb6.29

Best,

Christoph

--
Jun.-Prof. Dr.-Ing. Christoph Sommer
Cooperative Mobile Systems (CCS Labs)
Heinz Nixdorf Institute, Paderborn University, Germany
http://www.ccs-labs.org/~sommer/

Chakkaphong Tor Suthaputchakun

unread,
Jun 21, 2018, 4:07:43 AM6/21/18
to omn...@googlegroups.com
Dear  Christoph

Thank you so much for your reply. This is exactly what I am looking for. 
I will have a look. 

Many thanks.

Best,
Chakky



--
You received this message because you are subscribed to a topic in the Google Groups "OMNeT++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/omnetpp/CfFa2Zk9bu0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to omnetpp+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages