Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Robobin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plw1g21
Robobin
Commits
2f74fda4
Commit
2f74fda4
authored
6 months ago
by
Paul-Winpenny
Browse files
Options
Downloads
Patches
Plain Diff
Added logging statements.
parent
c8a20474
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ros2/src/robobin/robobin/api_node.py
+2
-0
2 additions, 0 deletions
ros2/src/robobin/robobin/api_node.py
ros2/src/robobin/robobin/connection_manager.py
+4
-4
4 additions, 4 deletions
ros2/src/robobin/robobin/connection_manager.py
with
6 additions
and
4 deletions
ros2/src/robobin/robobin/api_node.py
+
2
−
0
View file @
2f74fda4
...
@@ -33,8 +33,10 @@ class ApiNode(Node):
...
@@ -33,8 +33,10 @@ class ApiNode(Node):
data
=
client_socket
.
recv
(
1024
).
decode
()
data
=
client_socket
.
recv
(
1024
).
decode
()
if
not
data
:
if
not
data
:
break
break
self
.
get_logger
().
info
(
f
"
Received data:
{
data
}
"
)
topic
,
message
=
self
.
message_handler
.
handle_message
(
client_socket
,
data
)
topic
,
message
=
self
.
message_handler
.
handle_message
(
client_socket
,
data
)
if
topic
is
not
None
:
if
topic
is
not
None
:
self
.
get_logger
().
info
(
f
"
Publishing to topic:
{
topic
}
"
)
self
.
publish_to_topic
(
topic
,
message
)
self
.
publish_to_topic
(
topic
,
message
)
finally
:
finally
:
client_socket
.
close
()
client_socket
.
close
()
...
...
This diff is collapsed.
Click to expand it.
ros2/src/robobin/robobin/connection_manager.py
+
4
−
4
View file @
2f74fda4
...
@@ -28,13 +28,13 @@ class ConnectionManager:
...
@@ -28,13 +28,13 @@ class ConnectionManager:
try
:
try
:
data
,
addr
=
udp_sock
.
recvfrom
(
1024
)
data
,
addr
=
udp_sock
.
recvfrom
(
1024
)
if
data
.
decode
()
==
"
CONNECT
"
:
if
data
.
decode
()
==
"
CONNECT
"
:
print
(
f
"
Connection request
from
{
addr
}
"
)
self
.
api_node
.
get_logger
().
info
(
f
"
Received CONNECT message
from
{
addr
}
"
)
tcp_sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
tcp_sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
tcp_sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
tcp_sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
tcp_sock
.
bind
((
''
,
self
.
LISTEN_PORT
))
tcp_sock
.
bind
((
''
,
self
.
LISTEN_PORT
))
tcp_sock
.
listen
(
1
)
tcp_sock
.
listen
(
1
)
client_socket
,
client_addr
=
tcp_sock
.
accept
()
client_socket
,
client_addr
=
tcp_sock
.
accept
()
print
(
f
"
Client connected from
{
client_addr
}
"
)
self
.
api_node
.
get_logger
().
info
(
f
"
Client connected from
{
client_addr
}
"
)
threading
.
Thread
(
target
=
self
.
api_node
.
handle_client_connection
,
args
=
(
client_socket
,)).
start
()
threading
.
Thread
(
target
=
self
.
api_node
.
handle_client_connection
,
args
=
(
client_socket
,)).
start
()
except
socket
.
timeout
:
except
socket
.
timeout
:
continue
continue
...
@@ -54,13 +54,13 @@ class ConnectionManager:
...
@@ -54,13 +54,13 @@ class ConnectionManager:
location
=
"
(0,0)
"
#At some point this will be retrieved from navigation node
location
=
"
(0,0)
"
#At some point this will be retrieved from navigation node
message
=
f
"
ROBOBIN_PRESENT
{
location
}
"
.
encode
()
message
=
f
"
ROBOBIN_PRESENT
{
location
}
"
.
encode
()
sock
.
sendto
(
message
,
(
self
.
UDP_IP
,
self
.
UDP_PORT
))
sock
.
sendto
(
message
,
(
self
.
UDP_IP
,
self
.
UDP_PORT
))
print
(
"
Broadcasting presence.
"
)
self
.
api_node
.
get_logger
().
info
(
"
Broadcasting presence.
"
)
time
.
sleep
(
5
)
time
.
sleep
(
5
)
except
OSError
:
except
OSError
:
break
break
sock
.
close
()
sock
.
close
()
print
(
"
Stopped broadcasting presence.
"
)
self
.
api_node
.
get_logger
().
info
(
"
Stopped broadcasting presence.
"
)
def
stop
(
self
):
def
stop
(
self
):
"""
Stops the connection manager.
"""
"""
Stops the connection manager.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment