private void UpdateSensor() { motor_a_sensor.UpdateSensorValues(); motor_b_sensor.UpdateSensorValues(); this.writer.Set("motor_angle_a", (int)motor_a_sensor.GetDegree()); this.writer.Set("motor_angle_b", (int)motor_b_sensor.GetDegree()); colorSensor.UpdateSensorValues(); ultrasonicSensor.UpdateSensorValues(); this.writer.Set("sensor_ultrasonic", (int)(this.ultrasonicSensor.GetDistanceValue() * 10)); this.writer.Set("sensor_reflect", (int)(this.colorSensor.GetLightValue() * 100f)); ColorRGB color_sensor_rgb; this.colorSensor.GetRgb(out color_sensor_rgb); this.writer.Set("sensor_rgb_r", color_sensor_rgb.r); this.writer.Set("sensor_rgb_g", color_sensor_rgb.g); this.writer.Set("sensor_rgb_b", color_sensor_rgb.b); this.writer.Set("sensor_color", (int)this.colorSensor.GetColorId()); }
private void UpdateSensor() { if (this.motor_a_sensor != null) { motor_a_sensor.UpdateSensorValues(); this.writer.Set("motor_angle_a", (int)motor_a_sensor.GetDegree()); } if (this.motor_b_sensor != null) { motor_b_sensor.UpdateSensorValues(); this.writer.Set("motor_angle_b", (int)motor_b_sensor.GetDegree()); } if (this.motor_arm_sensor != null) { motor_arm_sensor.UpdateSensorValues(); this.writer.Set("motor_angle_c", (int)motor_arm_sensor.GetDegree()); } if (this.colorSensor != null) { colorSensor.UpdateSensorValues(); this.writer.Set("sensor_reflect", (int)(this.colorSensor.GetLightValue() * 100f)); ColorRGB color_sensor_rgb; this.colorSensor.GetRgb(out color_sensor_rgb); this.writer.Set("sensor_rgb_r", color_sensor_rgb.r); this.writer.Set("sensor_rgb_g", color_sensor_rgb.g); this.writer.Set("sensor_rgb_b", color_sensor_rgb.b); this.writer.Set("sensor_color", (int)this.colorSensor.GetColorId()); } if (this.ultrasonicSensor != null) { ultrasonicSensor.UpdateSensorValues(); this.writer.Set("sensor_ultrasonic", (int)(this.ultrasonicSensor.GetDistanceValue() * 10)); } if (touchSensor0 != null) { touchSensor0.UpdateSensorValues(); if (this.touchSensor0.IsPressed()) { //Debug.Log("Touched0:"); this.writer.Set("touch_sensor0", 4095); } else { this.writer.Set("touch_sensor0", 0); } } if (touchSensor1 != null) { touchSensor1.UpdateSensorValues(); if (this.touchSensor1.IsPressed()) { //Debug.Log("Touched1:"); this.writer.Set("touch_sensor1", 4095); } else { this.writer.Set("touch_sensor1", 0); } } if (gyroSensor != null) { gyroSensor.UpdateSensorValues(); this.writer.Set("gyro_degree", (int)gyroSensor.GetDegree()); this.writer.Set("gyro_degree_rate", (int)gyroSensor.GetDegreeRate()); } }