I created a method changeTarget
in the TraCICommandInterface.cc file where I used the chageTarget
TraCI command to change the destination. I want to know whether it is a correct implementation or not and also if the nodeId
mentioned in the method is the same as the nodeId
of TraCICommandInterface.h. So can I use the nodeId
or do I need to use the getexternalId()
method to get the vehicle id?
void TraCICommandInterface::Vehicle::changeTarget(std::string roadId) {
uint8_t variableId = CMD_CHANGETARGET;
uint8_t variableType = TYPE_COMPOUND;
uint8_t edgeIdT = TYPE_STRING;
std::string edgeId = roadId;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << edgeId<<edgeIdT);
ASSERT(buf.eof());
}
No, it is not correct. The type should always go in front of the value and you don't need a compound here. So something like the following:
uint8_t variableId = CMD_CHANGETARGET;
uint8_t edgeIdT = TYPE_STRING;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << edgeIdT << roadId);