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
b267f2cb
authored
May 06, 2024
by
Vicente Castellano Gómez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
- Conexion funcando pendite de prueba total
parent
754f3408
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
19 deletions
conexion.py
main.py
mensajeRobot.py
conexion.py
View file @
b267f2cb
...
...
@@ -83,8 +83,8 @@ class Conexion:
print
(
"Desconectado"
)
def
desubscribir
(
self
,
topic
):
self
.
client
.
unsubscribe
(
topic
)
#print(f"Desubscrito topic : {topic}"
)
#
self.client.unsubscribe(topic)
print
(
"Desubscrito topic : "
,
topic
)
def
checkMensages
(
self
):
self
.
client
.
check_msg
()
...
...
main.py
View file @
b267f2cb
...
...
@@ -6,31 +6,22 @@ from umqtt.robust import MQTTClient
import
conexion
as
cn
"""
def sub_cp(topic, msg):
print("Recibido topic", topic.decode(), " mensage ", msg.decode())
subs = ["A3-467/GrupoL/Robot","A3-467/GrupoL/SincRobot"]
send = ["A3-467/GrupoL/Interfaz","A3-467/GrupoL/SincInterfaz"]
#cx = cn.Conexion(subs,on_msg=sub_cp)
#cx.publicar(send[0],"BBBBBBBBBB")
cx
=
cn
.
Conexion
(
subs
,
sub_cp
)
print
(
"Creado"
)
while
True
:
cx
.
checkMensages
()
"""
import mensajeRobot as m
mR = m.MensajeRobot()
print("Creado")
print("creada conexion")
mapa = mR.getMapa()
print(mapa)
pos = (4,4)
mR.sendPosicion(pos)
"""
"""
robot
=
Robot
()
...
...
@@ -43,4 +34,3 @@ robot.recorreRuta(mov,cas)
robot
.
recogePaquete
()
"""
\ No newline at end of file
mensajeRobot.py
View file @
b267f2cb
...
...
@@ -11,12 +11,12 @@ class MensajeRobot:
print
(
"Inicizlizando"
)
def
sub_cp
(
topic
,
msg
):
print
(
"Recibido topic"
,
topic
,
" mensage "
,
msg
)
if
(
topic
==
self
.
topicSubs
[
-
2
]):
def
sub_cp
(
topic
,
msg
):
print
(
"Recibido topic"
,
topic
.
decode
(),
" mensage "
,
msg
.
decode
()
)
if
(
topic
.
decode
()
==
self
.
topicSubs
[
-
1
]):
self
.
sinc
=
True
else
:
self
.
mensaje
=
str
(
msg
.
decode
(
'utf-8'
))
self
.
mensaje
=
str
(
msg
.
decode
())
def
on_message_default
(
client
,
userdata
,
message
):
...
...
@@ -66,6 +66,7 @@ class MensajeRobot:
def
__sincronizacion
(
self
):
while
(
not
self
.
sinc
):
self
.
conex
.
checkMensages
()
self
.
conex
.
publicar
(
self
.
topicSend
[
-
1
],
self
.
prefMsg
[
'sinc'
])
time
.
sleep
(
2
)
print
(
"SINCRONIZADO"
)
...
...
@@ -78,6 +79,7 @@ class MensajeRobot:
while
(
self
.
mensaje
.
split
(
self
.
sepMsg
)[
0
]
!=
self
.
prefMsg
[
'mapa'
]):
self
.
conex
.
checkMensages
()
time
.
sleep
(
2
)
return
self
.
mensaje
.
split
(
self
.
sepMsg
)[
1
]
...
...
@@ -87,6 +89,7 @@ class MensajeRobot:
self
.
conex
.
publicar
(
self
.
topicSend
[
0
],
self
.
prefMsg
[
'pedido'
]
+
self
.
sepMsg
)
while
(
self
.
mensaje
.
split
(
self
.
sepMsg
)[
0
]
!=
self
.
prefMsg
[
'pedido'
]):
self
.
conex
.
checkMensages
()
#print(f"Esperando Pedido - {self.mensaje.split(self.sepMsg)[0],self.prefMsg['pedido']}")
time
.
sleep
(
1
)
...
...
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