def update(self, throttle, angle): throttle = min(1, max(-1, -throttle)) yaw = min(1, max(-1, methods.angle_to_yaw(angle))) if not config.car.reverse_steering: yaw = -yaw self.throttle_driver.update(throttle) self.steering_driver.update(yaw)
def update(self, throttle, angle): throttle = min(1, max(-1, -throttle)) yaw = min(1, max(-1, methods.angle_to_yaw(angle))) if not config.REVERSE_STEERING: yaw = -yaw self.throttle_driver.update(throttle) self.steering_driver.update(yaw)
def update(self, throttle, angle): throttle = min(1, max(-1, -throttle)) # valor de la aceleración yaw = min(1, max(-1, methods.angle_to_yaw(angle))) # angulo de guiñada if not config.car.reverse_steering: yaw = -yaw self.throttle_driver.update(throttle) self.steering_driver.update(yaw)
def send_status(self): v = self.application.vehicle img64 = None if v.frame_buffer is not None: image = v.frame_buffer if v.target is not None: found = v.target cv2.rectangle(image, (int(found[0]), int(found[1])), (int(found[2]), int(found[3])), (0, 255, 0), 1) cv2.putText(image, 'Target', (int(found[0]), int(found[1])), font, fontScale, fontColor, lineType) image = cv2.resize(image, None, fx=0.5, fy=0.5) retval, encoded = cv2.imencode('.jpg', image) img64 = base64.b64encode(encoded).decode('ascii') pilot_angle = 0 if v.pilot_angle is not None: pilot_angle = str(methods.angle_to_yaw(v.pilot_angle)) pilot_throttle = 0 if v.pilot_throttle is not None: pilot_throttle = str(methods.angle_to_yaw(v.pilot_throttle)) status = { "image": img64, "controls": { "angle": v.pilot_angle, "yaw": pilot_angle, "throttle": pilot_throttle }, "auto_pilot": { "auto_pilots": v.list_auto_pilot_names(), "index": v.auto_pilot_index }, "sensor_reading": v.sensor_reading, "fps": v.fps, "record": v.record, "throttle": v.auto_throttle, "is_recording": v.recorder and v.recorder.is_recording, "f_time": v.f_time } self.write_message(json.dumps(status))
def update(self, throttle, angle): throttle = min(1, max(-1, -throttle)) yaw = min(1, max(-1, methods.angle_to_yaw(angle))) if not config.car.reverse_steering: yaw = -yaw if config.car.reverse_throttle: throttle = -throttle # scaling throttle if throttle > 0: throttle = throttle / config.car.throttle_scaling self.throttle_driver.update(throttle) self.steering_driver.update(yaw)
def decide(self, img_arr): if config.camera.crop_top or config.camera.crop_bottom: h, w, _ = img_arr.shape t = config.camera.crop_top l = h - config.camera.crop_bottom img_arr = img_arr[t:l, :] img_arr = np.interp(img_arr, config.camera.output_range, config.model.input_range) img_arr = np.expand_dims(img_arr, axis=0) prediction = self.model.predict(img_arr) if len(prediction) == 2: yaw = methods.angle_to_yaw(prediction[0][0]) throttle = prediction[1][0] else: yaw = methods.angle_to_yaw(prediction[0][0]) throttle = 0 avf = config.model.yaw_average_factor yaw = avf * self.yaw + (1.0 - avf) * yaw self.yaw = yaw return methods.yaw_to_angle(yaw), throttle
def send_status(self): v = self.application.vehicle img64 = v.vision_sensor.capture_base64() status = { "image": img64, "controls": { "angle": v.pilot_angle, "yaw": str(methods.angle_to_yaw(v.pilot_angle)), "throttle": str(v.pilot_throttle) }, "pilot": { "pilots": v.list_pilot_names(), "index": v.selected_pilot_index() }, "record": v.record, "is_recording": v.recorder.is_recording, "f_time": v.f_time } self.write_message(json.dumps(status))
def test_angle_conversion(self): for yaw in np.arange(-1, 1, 0.1): test_yaw = yaw_to_angle(angle_to_yaw(yaw)) self.assertAlmostEqual(yaw, test_yaw, places=8)