Esempio n. 1
0
	// Update is called once per frame
	void FixedUpdate () {


		ekf_generator ekf = (ekf_generator) target.GetComponent(typeof(ekf_generator));


		if (ekf.isRunning ()) 
		{
			float new_x = target.transform.position.x;
			float new_y = target.transform.position.y;

			transform.position = new Vector3 (new_x, new_y, -1);
		}
		else 
		{
			if (Input.GetKey (KeyCode.RightArrow)) {
				transform.Translate (new Vector3 (0.2f * (zoom / 5), 0, 0));
			}
			if (Input.GetKey (KeyCode.LeftArrow)) {
				transform.Translate (new Vector3 (-0.2f * (zoom / 5), 0, 0));
			}
			if (Input.GetKey (KeyCode.DownArrow)) {
				transform.Translate (new Vector3 (0, -0.2f * (zoom / 5), 0));
			}
			if (Input.GetKey (KeyCode.UpArrow)) {
				transform.Translate (new Vector3 (0, 0.2f * (zoom / 5), 0));
			}
		}
			

	}
    void Estimate(SocketIOEvent obj)
    {
        JSONObject jsonObject = obj.data;

        if (kalman_filter.isRunning())
        {
            float estimate_x = float.Parse(jsonObject.GetField("estimate_x").ToString());
            float estimate_y = float.Parse(jsonObject.GetField("estimate_y").ToString());

            float rmse_x  = float.Parse(jsonObject.GetField("rmse_x").ToString());
            float rmse_y  = float.Parse(jsonObject.GetField("rmse_y").ToString());
            float rmse_vx = float.Parse(jsonObject.GetField("rmse_vx").ToString());
            float rmse_vy = float.Parse(jsonObject.GetField("rmse_vy").ToString());

            kalman_filter.Estimate(estimate_x, estimate_y);
            kalman_filter.SetRmse(rmse_x, rmse_y, rmse_vx, rmse_vy);
        }

        EmitTelemetry(obj);
    }