def __init__(self): app_config = AppConfig().config motor_l = app_config['navigation_config']['motor_L'] motor_r = app_config['navigation_config']['motor_R'] self.motor_L = Motor(motor_l) self.motor_R = Motor(motor_r) self.d_sleep = 0.4 log.info('Navigation System Initialized')
def process(self, arg_data): try: data_in = json.loads(arg_data) log.info(data_in) qr_command = data_in['action'] navigation = Navigation() function = getattr(navigation, qr_command) function() except Exception as ex: log.debug(f'Invalid QR Value: {data_in}')
def move_360(self): self.motor_R.backward() self.motor_L.forward() sleep(1) self.stop() log.info('[ROVER] Rotate 360')
def rotate_right(self): self.motor_R.backward() self.motor_L.forward() log.info('[ROVER] Rotating Right') sleep(self.d_sleep) self.stop()
def rotate_left(self): self.motor_L.backward() self.motor_R.forward() log.info('[ROVER] Rotating Left') sleep(self.d_sleep) self.stop()
def move_backward(self): self.motor_L.backward() self.motor_R.backward() log.info('[ROVER] Moving Backward') sleep(self.d_sleep) self.stop()
def move_forward(self): self.motor_L.forward() self.motor_R.forward() log.info('[ROVER] Moving forward') sleep(self.d_sleep) self.stop()
import cv2 from lib.common import AppConfig, log from lib.rover_events import process_event from lib.qr_reader import QrReader from pyzbar.pyzbar import decode from lib.rover_navigation import Navigation # from lib.voice import VoiceService import asyncio if __name__ == '__main__': log.info('Rover Initialization Started ....') app_config = AppConfig().config log.info('Rover Initialization Completed ....') navigation = Navigation() log.info('Voice Service Initialization Started ....') # voice = VoiceService() # asyncio.run(voice.say('Rover-AI voice service is activated')) log.info('Voice Service Initialization Completed ....') log.info('Started Rover Camera ....') vs = cv2.VideoCapture(app_config['rover_cam']['device_id']) log.info('Rover Camera started successfully') qr_reader = QrReader() while True: ret, frame = vs.read() frame = cv2.resize(frame, (400, 400)) img_grey = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) value = decode(img_grey) if not value: pass else: