Exemplo n.º 1
0
# http://docs.micropython.org/en/latest/library/pyb.html
import uasyncio as asyncio
import math

import ulogging as logging
from motors import Motor
from sensors import Camera, Sensor

logger = logging.Logger(__name__)


class Robot:
    """A class that represents the robot and offers shortcuts functions
    to runs two motors.

    Args:
        rmotor (Motor): The right-side motor
        lmotor (Motor): The left-side motor
    """

    WHEEL_DIAMETER = 80  # in millimeters
    ROT_DIAMETER = 270  # distance (mm) between two wheels

    def __init__(self):
        self.lmotor = Motor(4, 0x09, 1)
        self.rmotor = Motor(4, 0x09, 2)
        self.camera = Camera()
        self.sensor = Sensor()

    @property
    def moving(self):
Exemplo n.º 2
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import sys
import ulogging
from utokenize import *
import utokenize
from . import types as ast


log = ulogging.Logger(__name__)


TOK_TYPE = 0
TOK_STRING = 1

BP_UNTIL_COMMA = 6
BP_LVALUE = 160 - 1


class GenComp(ast.expr):
    _fields = ('elt', 'generators')


def literal_eval(s):
    if s.endswith('"') or s.endswith("'"):
Exemplo n.º 3
0
"""
This program is the entry point of the Open MV Cam.
This is the one you need to launch in OpenMV IDE.
"""

import pyb
import uasyncio as asyncio

import robot
import ulogging as logging

# Creates the root logger (all loggers are herited from it by default)
logger = logging.Logger("root")
usb_vcp = pyb.USB_VCP()

if usb_vcp.debug_mode_enabled():
    # Logs will be displayed in the console output
    logger.add_handler(logging.StreamHandler())
    logger.set_level("DEBUG")
else:
    logger.add_handler(logging.FileHandler("robot.log"))

try:
    asyncio.run(robot.main())  # Runs the main script
except Exception as error:
    if str(error) == "IDE interrupt":
        logger.critical("The script was stopped by Open MV IDE")
    else:
        raise error