// Start is called before the first frame update void Start() { solarPanels = GetComponentsInChildren <SolarPanel>(); logWriters = new LogWriter[solarPanels.Length]; for (int i = 0; i < logWriters.Length; i++) { logWriters[i] = new LogWriter("panel_" + i + ".csv"); if (logWriters[i].Length() == 0) { logWriters[i].WriteLine("time,value"); } } socket = FindObjectOfType <NetworkHandler>().client; socket.On("connect", () => { string[] available_data = new string[solarPanels.Length]; for (int i = 0; i < solarPanels.Length; i++) { available_data[i] = "\"adjust_value_" + i + "\":\"float\", \"actual_angle_" + i + "\":\"float\", \"desired_position_" + i + "\":\"float\", \"actual_solar_angle_" + i + "\":\"float\""; } socket.Send("{\"available_data\": {" + string.Join(",", available_data) + "}}"); }); socket.On("message", () => { }); start_time = Time.time; sun = GameObject.FindGameObjectWithTag("sun"); }
//public bool showParticles = true; //public GameObject[] thrusterClockwise; //public GameObject[] thrusterCounterClockwise; // Start is called before the first frame update void Start() { desired_angle = 0; lightSensors = GetComponentsInChildren <LightSensor2>(); solarPanels = GetComponentsInChildren <SolarPanel2>(); rgbd = GetComponent <Rigidbody>(); //pidRotate = new PIDController(0.000001f, 0.025f, 0.0000f); pidRotate = new PIDController(5f, 1f, 0.01f); //pidRotate = new PIDController(1f, 0f, 0f); //pidRotate = new PIDController(1f, 0.001f, 0.001f); //pidRotate = new PIDController(0.001f, 0f, 0f); //AnimateThrusters(thrusterClockwise, false); //AnimateThrusters(thrusterCounterClockwise, false); socket = FindObjectOfType <NetworkHandler>().client; socket.On("connect", () => { //socket.FillSendBuffer<string>("u","\"float\""); socket.FillSendBuffer <string>("actual_angle", "\"float\""); socket.FillSendBuffer <string>("desired_angle", "\"float\""); socket.SendAvailableData(); }); }