Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Handshake
- JSONObject handshake = new JSONObject(); //HandshakeMessage
- handshake.put("r", "Arduino"); //RobotName
- handshake.put("m", 2); //MessageType
- handshake.put("w", 10.0); //RobotWidth
- handshake.put("l", 20.0); //RobotLength
- handshake.put("to", new double[]{0.0, 0.0}); //TowerOffset
- handshake.put("ao", 0.0); //AxleOffset
- handshake.put("so", new double[]{0.0, 0.0, 0.0, 0.0}); //SensorOffset
- handshake.put("dl", 200); //MessageDeadline
- JSONObject irsensorheading = new JSONObject();
- irsensorheading.put("s1", 0); //IRsensorHeading
- irsensorheading.put("s2", 90); //IRsensorHeading
- irsensorheading.put("s3", 180); //IRsensorHeading
- irsensorheading.put("s4", 270); //IRsensorHeading
- handshake.put("irh", irsensorheading);
- inbox.putMessage(handshake);
- //Update
- JSONObject update = new JSONObject(); //UpdateMessage
- JSONObject position = new JSONObject();
- position.put("p1", 0); //RobotXpos
- position.put("p2", 0); //RobotYpos
- JSONObject irsensordata = new JSONObject();
- irsensordata.put("s1", 10); //IRsensorData
- irsensordata.put("s2", 15); //IRsensorData
- irsensordata.put("s3", 10); //IRsensorData
- irsensordata.put("s4", 15); //IRsensorData
- irsensorheading = new JSONObject();
- irsensorheading.put("s1", 0); //IRsensorHeading
- irsensorheading.put("s2", 90); //IRsensorHeading
- irsensorheading.put("s3", 180); //IRsensorHeading
- irsensorheading.put("s4", 270); //IRsensorHeading
- update.put("r", "1"); //RobotID
- update.put("m", 1); //MessageType
- update.put("pd", position); //PositionData
- update.put("o", 0.0); //Orientation
- update.put("irh", irsensorheading); //IRHeading
- update.put("ird", irsensordata); //IRData
- inbox.putMessage(update);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement