public void QueueMessage(SimMessage m) { lock (this) { messages.Add(m); } }
private void SendFELoaded() { SimMessage m = new SimMessage(); m.json = new JSONObject(JSONObject.Type.OBJECT); m.messageId = "SceneSelectionReady"; m.json.AddField("loaded", "1"); QueueMessage(m); }
private void SendProtocolVersion() { SimMessage m = new SimMessage(); m.json = new JSONObject(JSONObject.Type.OBJECT); m.messageId = "ProtocolVersion"; m.json.AddField("version", "1"); QueueMessage(m); }
void OnLoaded() { SimMessage m = new SimMessage(); m.json = new JSONObject(JSONObject.Type.OBJECT); m.messageId = "SceneLoaded"; m.json.AddField("none", "none"); car.SavePosRot(); QueueMessage(m); }
private void SendSceneNames() { SimMessage m = new SimMessage(); m.messageId = "SceneNames"; JSONObject scenes = new JSONObject(JSONObject.Type.ARRAY); scenes.Add("generated_road"); scenes.Add("warehouse"); scenes.Add("sparkfun_avc"); m.json = new JSONObject(JSONObject.Type.OBJECT); m.json.AddField("scene_names", scenes); QueueMessage(m); }
public void QueueMessage(SimMessage m) { lock (this) { if (bVerbose) { Debug.Log("Queueing message: " + m.messageId); } if (messages != null) { messages.Add(m); } else { Debug.LogWarning("message queue not inited yet."); } } }
private void Update() { if (collectData) { collectData = false; SimMessage m = new SimMessage(); m.json = new JSONObject(JSONObject.Type.OBJECT); m.messageId = "Telemetry"; m.json.AddField("steering_angle", car.GetSteering()); m.json.AddField("throttle", car.GetThrottle()); m.json.AddField("speed", car.GetVelocity().magnitude); m.json.AddField("image", System.Convert.ToBase64String(CameraHelper.CaptureFrame(camSensor))); m.json.AddField("hit", car.GetLastCollision()); car.ClearLastCollision(); Transform tm = car.GetTransform(); m.json.AddField("pos_x", tm.position.x); m.json.AddField("pos_y", tm.position.y); m.json.AddField("pos_z", tm.position.z); m.json.AddField("time", Time.timeSinceLevelLoad); if (pm != null) { float cte = 0.0f; if (pm.path.GetCrossTrackErr(tm.position, ref cte)) { m.json.AddField("cte", cte); } else { pm.path.ResetActiveSpan(); m.json.AddField("cte", 0.0f); } } QueueMessage(m); } }