Hello, looking at your code I don't see any glaring mistakes (but to be honest I'm alway using the python client anyway). You may find it helpful to check out the code in src/trac_testclient/TraCITestClient.cpp and src/utils/traci/TraCIAPI.cpp regards, Jakob
2014-07-22 18:21 GMT+02:00 Timothy Lehner <[email protected]>: > Hello All, > > I am trying to forcibly move a car from some location to another one, > specified by an edge_id > > I am trying to do this using SUMO TraCI Byte[] messages, but am having > difficulty encoding the message, I am not trying to decode any messages as > I don't think I should be getting any response, although I may be mistaken. > > If you can see where I've gone wrong, that would be extremely useful. > > Kind regards, > Tim Lehner > > My approach is below: > =============================== > > > public static byte[] encodeTeleportRequest(final String vehicleId, String > newEdgeId) { > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > DataOutputStream dos = new DataOutputStream(baos); > > try{ > dos.writeInt(41 + newEdgeId.length()); // Message Length inc. > Header > > dos.writeByte(37+ newEdgeId.length()); // Length of Command, > with Identifier (note just 4 less then total) > dos.writeByte((byte)0xc4); // Command 0xc4: Change > Vehicle State > dos.writeByte((byte)0x5c); // move to (0x5c) compound > (lane ID, position along lane) > // Moves the vehicle to a > new position > > dos.writeInt(vehicleId.length()); // Prep next few lines > dos.write(vehicleId.getBytes("UTF-8")); // Identify Vehicle > > dos.writeByte((byte)0x0F); // compound object 0x0F > dos.writeInt(2); // compound object has 2 > values > > dos.writeByte((byte)0x0C); // String object, 0x0C > dos.writeInt((newEdgeId.size() + 2)); > dos.write((newEdgeId + "_0").getBytes("UTF-8")); // Lane id = > edge_id + "_#" where # is lane number > > dos.writeByte((byte)0x0B); // Double object, 0x0B > dos.writeInt(8); > dos.writeDouble(0.0); // start of the lane. > > > > } catch (IOException e) { > throw new RuntimeException(e); > } > return baos.toByteArray(); > } > > =============================== > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > sumo-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/sumo-user > ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ sumo-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sumo-user
