Пример #1
0
    def __init__(self):
        self.services_to_run = {
            "encoders": [True, False],
            "motors": [True, False],
            "ir_sensors": [True, False],
            "tone": [True, False]
        }

        # Init services
        self.mirto = MirtoRobot(debug=False, services_on=self.services_to_run)
# Author: Noman Niazi
#Code may not be used by third part individuals or groups
from mirto_asip_manager.mirto_robot import MirtoRobot
from time import sleep
import time


services_to_run = {"encoders": [True, False], "motors": [True, False], "ir_sensors": [True, False],
                   "tone": [True, False]}


# Run services test
mirto = MirtoRobot(debug=True, services_on=services_to_run)

from time import sleep

def get_Motor_Distance_Values():

    motor_Distance = []

    enc = mirto.get_encoders_values()
    OneEncMM = 2 * 3.14 * (66.20 / 2) / 1632 / 10
    l_OneEncMM = (enc[0] * OneEncMM)
    r_OneEncMM = (enc[1] * OneEncMM * -1)

    motor_Distance.extend((l_OneEncMM, r_OneEncMM))

    return motor_Distance

while True:
    all_motor_Distance = get_Motor_Distance_Values()
Пример #3
0
from mirto_asip_manager.mirto_robot import MirtoRobot
from time import sleep

services_to_run = {
    "encoders": [True, False],
    "motors": [True, False],
    "ir_sensors": [True, False]
}
# Run services test
mirto = MirtoRobot(debug=False, services_on=services_to_run)
# mirto.set_motors(100,0)
# sleep(1)
# mirto.stop_motors()
# mirto.terminate()
#  get_encoders_values',
#  'get_ir_sensors_values',
#  'get_left_encoder_values',
#  'get_right_encoder_values',
#  'get_version_info',
#  'robot',
#  'set_motors',
#  'stop_motors',
#  'terminate',
#  'test_encoders',
#  'test_ir_sensors',
#  'test_motor']
# mirto.test_ir_sensors()

print()
rightIR = 0
leftIR = 0
Пример #4
0
from mirto_asip_manager.mirto_robot import MirtoRobot
from time import sleep

services_to_run = {
    "encoders": [True, False],
    "motors": [True, False],
    "ir_sensors": [True, False],
    "tone": [True, False]
}

# Run services test
mirto = MirtoRobot(debug=True, services_on=services_to_run)

from time import sleep

while True:
    enc = mirto.get_encoders_values()
    Distance = 2 * 3.14 * (66.20 / 2) / 1632 / 10
    print(enc[0] * Distance)
    print(enc[0] * Distance)
    sleep(0.1)
Пример #5
0
import imutils
import time
import cv2

import json
from mirto_asip_manager.mirto_robot import MirtoRobot
from time import sleep
from threading import Thread

# from pyzbar import pyzbar

services_to_run = {"encoders": [True, False], "motors": [True, False], "ir_sensors": [True, False],
                   "tone": [True, False]}

# Run services test
mirto = MirtoRobot(debug=False, services_on=services_to_run)


def whatColoris():
    cap = cv2.VideoCapture(0)
    ret, frame = cap.read()
    rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)

    # cv2.imshow('frame', rgb)

    out = cv2.imwrite('capture.jpg', frame)

    cap.release()
    cv2.destroyAllWindows()
    import requests
Пример #6
0
class DrivingRobot:
    def __init__(self):
        self.services_to_run = {
            "encoders": [True, False],
            "motors": [True, False],
            "ir_sensors": [True, False],
            "tone": [True, False]
        }

        # Init services
        self.mirto = MirtoRobot(debug=False, services_on=self.services_to_run)

    def get_mirto_ir_values(self):
        ordered_ir_values = []
        ir_values = mirto.get_ir_sensors_values()
        left_ir = ir_values[0]
        center_ir = ir_values[2]
        right_ir = ir_values[1]
        ordered_ir_values.extend((left_ir, center_ir, right_ir))
        return ordered_ir_values

    def get_ir_values_threshold(self):
        """

        :return:
        """
        ir_values = self.mirto.get_ir_sensors_values()
        sensors_vals = {
            "left": [ir_values[0], False],
            "center": [ir_values[2], False],
            "right": [ir_values[1], False]
        }
        threshold = 110
        for sensor in sensors_vals.keys():
            sensor_val = sensors_vals.get(sensor)
            sensors_vals.update(sensors_vals)
            if sensor_val[0] > threshold:
                sensor_val[1] = True
                sensors_vals[sensor] = sensor_val
            else:
                sensor_val[1] = False
                sensors_vals[sensor] = sensor_val
        # print(sensors_vals, "\n")
        return sensors_vals

    def run_main(self):

        try:

            while True:

                ir_values_after_check = self.get_ir_values_threshold()
                return ir_values_after_check
                if ir_values_after_check.get("left")[1]:
                    self.mirto.set_motors(20, 40)
                elif ir_values_after_check.get("right"[1]):
                    self.mirto.set_motors(40, 20)
                else:
                    self.mirto.set_motors(35, 35)
                sleep(0.1)
        except Exception as error:
            print(error)
Пример #7
0
# Author: Noman Niazi
#Code may not be used by third part individuals or groups
from mirto_asip_manager.mirto_robot import MirtoRobot
from time import sleep


services_to_run = {"encoders": [True, False], "motors": [True, False], "ir_sensors": [True, False],
                   "tone": [True, False]}


# Run services test
mirto = MirtoRobot(debug=True, services_on=services_to_run)

from time import sleep

def get_Motor_Distance_Values():

    motor_Distance = []

    enc = mirto.get_encoders_values()
    OneEncMM = 2 * 3.14 * (66.20 / 2) / 1632 / 10
    l_OneEncMM = (enc[0] * OneEncMM)
    r_OneEncMM = (enc[1] * OneEncMM * -1)

    motor_Distance.extend((l_OneEncMM, r_OneEncMM))

    return motor_Distance

# while True:
#     all_motor_Distance = get_Motor_Distance_Values()
#