Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Vicente Castellano Gómez
/
robotAmbientales
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51c3f537
authored
May 07, 2024
by
Vicente Castellano Gómez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
- Funca, falta la media vueltaa hay que arreglarla
parent
5a8b03b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
camino.py
main.py
robot.py
camino.py
View file @
51c3f537
...
@@ -290,5 +290,3 @@ def encontrarCamino(stringMapa, posicionInicial, posicionFinal):
...
@@ -290,5 +290,3 @@ def encontrarCamino(stringMapa, posicionInicial, posicionFinal):
# print(d)
# print(d)
# print()
# print()
return
dirs
,
solOptima
return
dirs
,
solOptima
main.py
View file @
51c3f537
#!/usr/bin/env pybricks-micropython
#!/usr/bin/env pybricks-micropython
from
robot
import
Robot
from
robot
import
Robot
import
camino
from
camino
import
MovGiro
as
mov
from
umqtt.robust
import
MQTTClient
import
conexion
as
cn
robot
=
Robot
()
robot
=
Robot
()
#robot.calibraSensorColor()
#robot.calibraSensorColor()
robot
.
realizaPedido
()
robot
.
realizaPedido
()
#mov,cas = camino.encontrarCamino(mapa,(0,0),(3,0))
#robot.recorreRuta(mov,cas)
#robot.recorreRuta(mov,cas)
#robot.recogePaquete()
#robot.recogePaquete()
...
@@ -18,6 +14,7 @@ robot.realizaPedido()
...
@@ -18,6 +14,7 @@ robot.realizaPedido()
"""
"""
def sub_cp(topic, msg):
def sub_cp(topic, msg):
print("Recibido topic", topic.decode(), " mensage ", msg.decode())
print("Recibido topic", topic.decode(), " mensage ", msg.decode())
...
...
robot.py
View file @
51c3f537
...
@@ -9,8 +9,8 @@ import camino
...
@@ -9,8 +9,8 @@ import camino
from
camino
import
MovGiro
as
mov
from
camino
import
MovGiro
as
mov
class
Robot
:
class
Robot
:
green_rgb
=
(
3
5
,
55
,
37
)
green_rgb
=
(
3
9
,
74
,
36
)
black_rgb
=
(
6
,
3
,
18
)
black_rgb
=
(
6
,
6
,
13
)
tolerancia
=
10
tolerancia
=
10
contadorNegros
=
0
contadorNegros
=
0
valorW
=
30
valorW
=
30
...
@@ -21,7 +21,7 @@ class Robot:
...
@@ -21,7 +21,7 @@ class Robot:
radiusCurve
=
20
radiusCurve
=
20
interfono
=
None
interfono
=
None
mapa
=
None
mapa
=
None
casillaActual
=
(
6
,
0
)
casillaActual
=
(
6
,
4
)
pedido
=
None
pedido
=
None
casillaSig
=
None
casillaSig
=
None
...
@@ -132,7 +132,7 @@ class Robot:
...
@@ -132,7 +132,7 @@ class Robot:
self
.
sigueRecto
()
self
.
sigueRecto
()
def
mediaVuelta
(
self
):
def
mediaVuelta
(
self
):
self
.
robot
.
straight
(
6
0
)
self
.
robot
.
straight
(
7
0
)
self
.
giro
(
90
)
self
.
giro
(
90
)
self
.
giro
(
90
)
self
.
giro
(
90
)
...
@@ -173,17 +173,17 @@ class Robot:
...
@@ -173,17 +173,17 @@ class Robot:
contNegroAnterior
=
self
.
contadorNegros
contNegroAnterior
=
self
.
contadorNegros
self
.
incrementaContNegros
()
self
.
incrementaContNegros
()
# Actualizacion de casilla
# Actualizacion de casilla
if
self
.
queNegroEs
(
self
.
contadorNegros
)
==
1
:
#
if self.queNegroEs(self.contadorNegros) == 1:
self
.
actualizaCasilla
()
#
self.actualizaCasilla()
#Pendiente comprobar si hilo va a su bola o se para
#Pendiente comprobar si hilo va a su bola o se para
self
.
robot
.
drive
(
self
.
velocidad
,
self
.
w
)
self
.
robot
.
drive
(
self
.
velocidad
,
self
.
w
)
#print(self.contadorNegros
,contNegroAnterior
)
#print(self.contadorNegros)
def
recogePaquete
(
self
):
def
recogePaquete
(
self
):
self
.
robot
.
stop
()
self
.
robot
.
stop
()
self
.
pala
.
run_target
(
70
,
-
10
0
)
self
.
pala
.
run_target
(
70
,
-
6
0
)
def
soltarPaquete
(
self
):
def
soltarPaquete
(
self
):
...
@@ -205,6 +205,7 @@ class Robot:
...
@@ -205,6 +205,7 @@ class Robot:
def
recorreRuta
(
self
,
rutaDirecciones
,
rutaCoordenadas
):
def
recorreRuta
(
self
,
rutaDirecciones
,
rutaCoordenadas
):
for
dir
,
coor
in
zip
(
rutaDirecciones
,
rutaCoordenadas
):
for
dir
,
coor
in
zip
(
rutaDirecciones
,
rutaCoordenadas
):
self
.
casillaSig
=
coor
self
.
casillaSig
=
coor
self
.
actualizaCasilla
()
if
dir
is
2
:
if
dir
is
2
:
self
.
giraDerecha
()
self
.
giraDerecha
()
elif
dir
is
0
:
elif
dir
is
0
:
...
@@ -222,6 +223,8 @@ class Robot:
...
@@ -222,6 +223,8 @@ class Robot:
self
.
recorreRuta
(
rutaDirecciones
,
rutaCoordenadas
)
self
.
recorreRuta
(
rutaDirecciones
,
rutaCoordenadas
)
self
.
recogePaquete
()
self
.
recogePaquete
()
self
.
mediaVuelta
()
self
.
mediaVuelta
()
self
.
casillaSig
=
rutaCoordenadas
[
-
1
]
self
.
actualizaCasilla
()
#Ir desde punto A ---> B
#Ir desde punto A ---> B
print
(
"Entrega Principio"
,
self
.
pedido
[
0
],
" Final "
,
self
.
pedido
[
1
])
print
(
"Entrega Principio"
,
self
.
pedido
[
0
],
" Final "
,
self
.
pedido
[
1
])
...
@@ -230,4 +233,6 @@ class Robot:
...
@@ -230,4 +233,6 @@ class Robot:
self
.
recorreRuta
(
rutaDirecciones
,
rutaCoordenadas
)
self
.
recorreRuta
(
rutaDirecciones
,
rutaCoordenadas
)
self
.
soltarPaquete
()
self
.
soltarPaquete
()
self
.
mediaVuelta
()
self
.
mediaVuelta
()
self
.
casillaSig
=
rutaCoordenadas
[
-
1
]
self
.
actualizaCasilla
()
self
.
robot
.
stop
()
self
.
robot
.
stop
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment