def monta_simulacao(self):
        self.robo = None

        if self.tipo_mapa == 0:
            self.robo = Robo(30, -30, 0, 10)
        elif self.tipo_mapa == 1:
            self.robo = Robo(370, -30, -math.pi / 2, 10)
        elif self.tipo_mapa == 2:
            self.robo = Robo(30, -270, 0, 10)
        elif self.tipo_mapa == 3:
            self.robo = Robo(30, -270, 0, 10)
        elif self.tipo_mapa == 4:
            self.robo = Robo(30, -30, 0, 10)

        self.monta_obstaculos()
Esempio n. 2
0
class RoboTestes(unittest.TestCase):
    def setUp(self):
        self.megaman = Robo('Mega Man', bateria=50)
        print(f'setUp() sendo executado.')

    def test_carregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertEqual(self.megaman.dizer_nome(), 'BZZZ EU SOU MEGA MAN')
        self.assertEqual(self.megaman.bateria, 40)

    def tearDown(self):
        print('tearDown() sendo executado.')
Esempio n. 3
0
class RoboTests(unittest.TestCase):

    def setUp(self):
        self.megaman = Robo('Mega Man', bateria=50)
        print('Executando setUp()')

    def test_carregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertEqual(self.megaman.dizer_nome(), f'OI, EU SOU MEGA MAN')
        self.assertEqual(self.megaman.bateria, 49, 'A bateria deveria estar com 49%')

    def tearDown(self):
        print('Executando tearDown()')
Esempio n. 4
0
class RoboTestes(unittest.TestCase):
    def setUp(self):
        self.megaman = Robo('Mega Man', bateria=50)
        print('setUp() sendo executado!')

    def test_carregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertIn('BEEP, BOOP', self.megaman.dizer_nome())
        self.assertEqual(self.megaman.bateria, 49,
                         'A bateria deveria estar em 49%')

    def tearDown(self):
        print('tearDown() sendo executado!')
Esempio n. 5
0
    def __init__(self, subscriber, publisher_esquerda, publisher_direita):
        Robo.__init__(self, subscriber)

        self.pubL = rospy.Publisher(publisher_esquerda, Float64, queue_size = 100)
        self.pubR = rospy.Publisher(publisher_direita, Float64, queue_size = 100)

        self.vel = 0 #velocidade linear (inicializada como zero)
        self.omega = 0 #velocidade angular (inicializada como zero)

        self.orientacaoDesejada = Vetor(0, 0)
        self.posDesejada = Vetor(0, 0)

        self.orientacaoPrevista = Vetor(0, 0)
        self.posPrevista = Vetor(0, 0)

        self.omegaD = 0 # velocidade angular da roda direita
        self.omegaE = 0 # velocidade angular da roda esquerda
class RoboTestes(unittest.TestCase):
    def setUp(self):
        self.megaman = Robo("Mega Man", bateria=50)
        print("setUp() sendo executado")

    def test_carrregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertEqual(self.megaman.dizer_nome(),
                         "BEEP BOOP BEEP BOOP... EU SOU MEGA MAN")
        self.assertEqual(self.megaman.bateria, 49,
                         "A bateria deveria está em 49")

    def tearDown(self):
        print("tearDown() sendo executado...")
Esempio n. 7
0
class RoboTestes(unittest.TestCase):
    def setUp(self):
        self.megaman = Robo('Mega Man', bateria=50)
        print('setUP() sendo executado....')

    def test_carregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertEqual(self.megaman.dizer_nome(),
                         'BEEP BOOP BEEP BOOP. EU SOU MEGA MAN')
        self.assertEqual(self.megaman.bateria, 49,
                         'A bateria deveria estar em 49%')

    def tearDown(self):
        print('tearDown() sendo executado...')
Esempio n. 8
0
class RoboTestes(unittest.TestCase):
    def setUp(
            self
    ):  # setUp cria o objeto e deixa disponivel para os outros metodos
        self.megaman = Robo('Mega Man', bateria=50)
        print('setUp() sendo executado...')

    def test_carregar(self):
        self.megaman.carregar()
        self.assertEqual(self.megaman.bateria, 100)

    def test_dizer_nome(self):
        self.assertEqual(self.megaman.dizer_nome(),
                         'BEEP BOOP BEEP BOOP, EU SOU MEGA MAN')
        self.assertEqual(self.megaman.bateria, 49,
                         'A bateria deveria estar em 49%')

    def tearDown(self):
        print('tearDown() sendo executado...')
Esempio n. 9
0
 def setUp(self):
     self.megaman = Robo('Mega Man', bateria=50)
     print(f'setUp() sendo executado.')
Esempio n. 10
0
import numpy as np

from ambiente import Ambiente
from robo import Robo
from largura import BuscaLargura
from noMovimento import NoMovimento
from dijkstra import Djikstra
from aEstrela import AEstrela

place = Ambiente('Robo-ambiente.txt')
robo = Robo(place)
#place.print()
robo.print()
place.setPesos([1, 5, 10, 15])
place.printPeso()

runLargura = BuscaLargura(place)
runLargura.run(robo)

runDjikstra = Djikstra(place)
runDjikstra.run(robo)

runAEstrela = AEstrela(place)
runAEstrela.run(robo)

runLargura.getMenorCaminho()
runDjikstra.getMenorCaminho()
runAEstrela.getMenorCaminho()
Esempio n. 11
0
 def resetar(self) -> None:
     self._robo = Robo()
Esempio n. 12
0
# set your serial device here:
serialPort = '/dev/ttyACM0'

ser = serial.Serial(serialPort, 115200, timeout=1)
ser.flush()

servos = [
    Dynamixel(0, ser),
    Dynamixel(1, ser),
    Dynamixel(2, ser),
    Dynamixel(3, ser),
    Dynamixel(4, ser)
]
kinematics = InverseKinematics()
robo = Robo(servos, kinematics)

moves = RoboMoves(robo, kinematics)
fileHandler = FileHandler()
actionHandler = ActionHandler(robo, fileHandler)
cli = RoboCLI(actionHandler, robo)


def moveWithCV(showMovie=False):
    ip = ImageProcessor()
    vid = VideoStream(src=0).start()
    time.sleep(2.0)
    while True:
        frame = vid.read()
        if frame is None:
            break
 def __init__(self, tipo, idade):
     Robo.__init__(self, tipo)
     Pessoa.__init__(self, tipo, idade)
Esempio n. 14
0
 def setUp(
         self
 ):  # setUp cria o objeto e deixa disponivel para os outros metodos
     self.megaman = Robo('Mega Man', bateria=50)
     print('setUp() sendo executado...')
Esempio n. 15
0
import sys, json
from robo import Robo
from time import sleep

# JSON string passed in from Node.
lines = sys.stdin.readlines()

# Convert JSON string to dictionary object.
data = json.loads(lines[0])

# Create new robot and pass in dictionary as arguments.
r = Robo()

while True:
    r.drive(**data)
    sleep(0.1)
    sys.stdout.flush()
Esempio n. 16
0
from flask import Flask, request, render_template, Response
import json
import datetime
import sys
import signal
from robo import Robo
from camera import Camera

app = Flask(__name__)

robo = Robo()

@app.route("/")
def index():
    return "Hello Robo!"

@app.route('/robo')
def robot():
    now = datetime.datetime.now()
    date = now.strftime('%H-%M-%S')
    template_data = {
        'title' : 'ROBO',
        'date': date
    }
    return render_template('robo.html', **template_data)

@app.route('/robo/state')
def state():
    return json.dumps(robo.state)

'''
 def setUp(self):
     self.megaman = Robo("Mega Man", bateria=50)
     print("setUp() sendo executado")
class NucleoSimulacao:
    """
        Janela principal de simulacao
    """
    def __init__(self):
        self.robo = None
        self.obstaculos = []

        self.ligado = False
        self.intervalo_de_simulacao = 30

        self.tipo_mapa = 0
        self.altura_labirinto = 430  # pixels
        self.largura_labirinto = 400  # pixels
        self.largura_mapa = 300

        self.mostra_sensores = False
        self.mostra_celulas = False

        self.monta_simulacao()

    def liga_desliga(self):
        if not self.ligado:
            self.ligado = True
        else:
            self.ligado = False

    def troca_mapa(self):
        NUM_MAPS = 5

        self.tipo_mapa = (self.tipo_mapa + 1) % NUM_MAPS

        self.monta_simulacao()

    def troca_modo(self):
        if self.robo.ideal:
            self.robo.ideal = False
        else:
            self.robo.ideal = True

    def troca_exibicao_sensores(self):
        self.mostra_sensores = not self.mostra_sensores

    def troca_exibicao_grid(self):
        self.mostra_celulas = not self.mostra_celulas

    def monta_simulacao(self):
        self.robo = None

        if self.tipo_mapa == 0:
            self.robo = Robo(30, -30, 0, 10)
        elif self.tipo_mapa == 1:
            self.robo = Robo(370, -30, -math.pi / 2, 10)
        elif self.tipo_mapa == 2:
            self.robo = Robo(30, -270, 0, 10)
        elif self.tipo_mapa == 3:
            self.robo = Robo(30, -270, 0, 10)
        elif self.tipo_mapa == 4:
            self.robo = Robo(30, -30, 0, 10)

        self.monta_obstaculos()

    def monta_obstaculos(self):
        """
            Adiciona as paredes do labirinto
        """
        self.obstaculos = []

        # Moldura
        self.obstaculos.append([0, 0, 5, -self.altura_labirinto])
        self.obstaculos.append([
            self.largura_labirinto - 5, 0, self.largura_labirinto,
            -self.altura_labirinto
        ])
        self.obstaculos.append([0, 0, self.largura_labirinto, -5])
        self.obstaculos.append([
            0, -(self.altura_labirinto - 5), self.largura_labirinto,
            -self.altura_labirinto
        ])

        if self.tipo_mapa == 0:
            # Barreiras - Conjunto 1
            self.obstaculos.append([0, -60, self.largura_labirinto - 60, -65])
            self.obstaculos.append([60, -120, self.largura_labirinto, -125])
            self.obstaculos.append(
                [0, -180, self.largura_labirinto - 60, -185])
            self.obstaculos.append([60, -240, self.largura_labirinto, -245])
            self.obstaculos.append(
                [0, -300, self.largura_labirinto - 60, -305])
            self.obstaculos.append([60, -360, self.largura_labirinto, -365])

        if self.tipo_mapa == 1:
            # Barreiras - Conjunto 2
            self.obstaculos.append([
                self.largura_labirinto - 65, 0, self.largura_labirinto - 60,
                -65
            ])
            self.obstaculos.append(
                [60, -self.altura_labirinto + 65, 65, -self.altura_labirinto])
            self.obstaculos.append([0, -60, self.largura_labirinto - 60, -65])
            self.obstaculos.append([60, -120, self.largura_labirinto, -125])
            self.obstaculos.append([
                self.largura_labirinto / 2 + 30, -180, self.largura_labirinto,
                -185
            ])
            self.obstaculos.append(
                [0, -180, self.largura_labirinto / 2 - 30, -185])
            self.obstaculos.append([
                self.largura_labirinto / 2 + 30, -240, self.largura_labirinto,
                -245
            ])
            self.obstaculos.append(
                [0, -240, self.largura_labirinto / 2 - 30, -245])
            self.obstaculos.append(
                [0, -300, self.largura_labirinto - 60, -305])
            self.obstaculos.append([60, -360, self.largura_labirinto, -365])

        if self.tipo_mapa == 2:
            # Barreiras - Conjunto 3
            self.obstaculos.append([
                self.largura_labirinto - 65, 0, self.largura_labirinto - 60,
                -65
            ])
            self.obstaculos.append(
                [60, -self.altura_labirinto + 65, 65, -self.altura_labirinto])
            self.obstaculos.append([0, -60, self.largura_labirinto - 60, -65])
            self.obstaculos.append([60, -120, self.largura_labirinto, -125])
            self.obstaculos.append(
                [60, -180, self.largura_labirinto - 60, -185])
            self.obstaculos.append(
                [60, -240, self.largura_labirinto - 60, -245])
            self.obstaculos.append(
                [0, -300, self.largura_labirinto - 60, -305])
            self.obstaculos.append([60, -360, self.largura_labirinto, -365])

        if self.tipo_mapa == 3:
            # Barreiras - Conjunto 4
            self.obstaculos.append([
                self.largura_labirinto - 65, 0, self.largura_labirinto - 60,
                -65
            ])
            self.obstaculos.append(
                [60, -self.altura_labirinto + 65, 65, -self.altura_labirinto])
            self.obstaculos.append([
                self.largura_labirinto / 2, -180,
                self.largura_labirinto / 2 + 5, -240
            ])
            self.obstaculos.append([0, -60, self.largura_labirinto - 60, -65])
            self.obstaculos.append([60, -120, self.largura_labirinto, -125])
            self.obstaculos.append(
                [60, -180, self.largura_labirinto - 60, -185])
            self.obstaculos.append(
                [60, -240, self.largura_labirinto - 60, -245])
            self.obstaculos.append(
                [0, -300, self.largura_labirinto - 60, -305])
            self.obstaculos.append([60, -360, self.largura_labirinto, -365])

        if self.tipo_mapa == 4:
            # Barreiras - Conjunto 5
            self.obstaculos.append([0, -60, self.largura_labirinto - 60, -65])
            self.obstaculos.append([60, -360, self.largura_labirinto, -365])

    def executa(self):
        if not self.ligado:
            return ()
        self.robo.dinamica_robo(self.obstaculos)
Esempio n. 19
0
# license removed for brevity
from bola import Bola
from robo import Robo
from aliado import Aliado
from bola import Bola
from campo import Campo

import numpy
import rospy

from geometry_msgs.msg import Pose

if __name__ == '__main__':
    rospy.init_node('goleiro', anonymous=True)

    try:
        campo = Campo()
        bola = Bola("/ball/pose")
        goleiro = Aliado("/player1/pose",
                         "/player1__VSS_player__chassi_left_wheel/joint_vel",
                         "/player1__VSS_player__chassi_right_wheel/joint_vel")
        artilheiro = Robo("/player2/pose")

        # rate = rospy.Rate(10)
        while not rospy.is_shutdown():
            goleiro.move_goleiro(campo, bola)
            # rate.sleep()

    except rospy.ROSInterruptException:
        pass
Esempio n. 20
0
from robo import Robo
from time import sleep
r = Robo()
r.stop()
sleep(0.1)
Esempio n. 21
0
# coding=utf-8
from robo import Robo

# Faz a leitura do arquivo
with open('regras.txt') as f:
    helper = f.readlines()

# Faz a instancia do robô
p = Robo(helper)

while p.hasQuestions():
    r = "zero"
    perg = p.question()

    while not r.isdigit():
        if r is not "zero":
            print "Você deve responder com um numero!"

        # Recupera a resposta do usuario
        r = raw_input("%s? (0 ou 1): " % perg['pergunta'])

    # Responde a questao
    p.answer(perg, r)

print p.getWinner()
Esempio n. 22
0
 def setUp(self):
     self.megaman = Robo('Mega Man', bateria=50)
     print('Executando setUp()')
Esempio n. 23
0
from guizero import App, Box, PushButton
from robo import Robo

r = Robo()


def test():
    app = App(title='Robo', height=300, width=400, layout='grid')

    box = Box(app, layout='grid', grid=[0, 0])
    PushButton(box, r.leftMotorForward, text='Left Motor Forward', grid=[0, 0])
    PushButton(box,
               r.rightMotorForward,
               text='Right Motor Forward',
               grid=[1, 0])

    box = Box(app, layout='grid', grid=[0, 1])
    PushButton(box, r.forwardLeft, text='Forward Left', grid=[0, 0])
    PushButton(box, r.forward, text='Forward', grid=[1, 0])
    PushButton(box, r.forwardRight, text='Forward Right', grid=[2, 0])
    PushButton(box, r.pivotLeft, text='Pivot Left', grid=[0, 1])
    PushButton(box, r.stop, text='Stop', grid=[1, 1])
    PushButton(box, r.pivotRight, text='Pivot Right', grid=[2, 1])
    PushButton(box, r.backwardLeft, text='Backward Left', grid=[0, 2])
    PushButton(box, r.backward, text='Backward', grid=[1, 2])
    PushButton(box, r.backwardRight, text='Backward Right', grid=[2, 2])

    box = Box(app, layout='grid', grid=[0, 2])
    PushButton(box,
               r.leftMotorBackward,
               text='Left Motor Backward',
Esempio n. 24
0
from robocli import RoboCLI
from actionHandler import ActionHandler

import serial

# set your serial device here:
serialPort = '/dev/ttyACM0'

# ser = serial.Serial(serialPort, 115200, timeout=1)
# ser.flush()

ser = None

servos = [Dynamixel(0, ser), Dynamixel(1, ser), Dynamixel(2, ser), Dynamixel(3, ser), Dynamixel(4, ser)]
kinematics = InverseKinematics()
robo = Robo(servos, kinematics)

moves = RoboMoves(robo, kinematics)
fileHandler = FileHandler()
actionHandler = ActionHandler(robo, fileHandler)


app = Flask(__name__, template_folder='static', static_url_path='/static')

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/setPosition")
def setPosition():
    actionHandler.setPosition()