Skip to content

Commit

Permalink
refactor<com> remove comments and use docstrinfg for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahelsamahy committed Sep 19, 2024
1 parent 2f953e7 commit 2529c7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
5 changes: 3 additions & 2 deletions coms/coms/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import signal
import threading
from byodr.utils.ssh import Router
from .communication import start_communication
from .communication import CommunicationHandler
from .common_utils import *
from .robot_comm import *

Expand Down Expand Up @@ -35,9 +35,10 @@ def main():
application = ComsApplication(event=quit_event, config_dir=args.config)
tel_chatter = TeleopChatter(application.get_robot_config_file(), application.get_user_config_file())
socket_manager = SocketManager(tel_chatter, quit_event=quit_event)
communication_handler = CommunicationHandler(quit_event)

# Starting the functions that will allow the client and server of each segment to start sending and receiving data
communication_thread = threading.Thread(target=start_communication, args=(socket_manager, application.get_robot_config_file()))
communication_thread = threading.Thread(target=communication_handler.start_communication, args=(socket_manager, application.get_robot_config_file()))

application.setup()
socket_manager.start_threads()
Expand Down
13 changes: 4 additions & 9 deletions coms/coms/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from .robot_comm import *


common_queue = Queue(maxsize=1)


class ComsApplication(Application):
def __init__(self, event, config_dir=os.getcwd(), hz=20):
"""set up configuration directory and a configuration file path
Expand Down Expand Up @@ -62,8 +59,6 @@ def setup(self):
if _hash != self._config_hash:
self._config_hash = _hash

# logger.info(tel_data["command"]["robot_config"])


class SocketManager:
def __init__(self, teleop_chatter, quit_event):
Expand All @@ -80,11 +75,11 @@ def __init__(self, teleop_chatter, quit_event):
self.threads = [self.tel_chatter_socket, self.teleop_receiver, self.vehicle_receiver, self.pilot_receiver]

def publish_to_pilot(self, message):
# Method to publish a message using coms_to_pilot_publisher
"""Method to publish a message using coms_to_pilot_publisher"""
self.coms_to_pilot_publisher.publish(message)

def get_teleop_input(self):
# Method to get data from teleop_receiver
"""Method to get data from teleop_receiver"""
return self.teleop_receiver.get()

def get_teleop_chatter(self):
Expand All @@ -95,11 +90,11 @@ def get_teleop_chatter(self):

def chatter_message(self, cmd):
"""Broadcast message from COMS chatter with a timestamp. It is a one time message"""
logger.info(cmd)
# logger.info(cmd)
self.coms_chatter.publish(dict(time=timestamp(), command=cmd))

def get_velocity(self):
# Method to get data from vehicle_receiver
"""Method to get data from vehicle_receiver"""
return self.vehicle_receiver.get()

def get_watchdog_status(self):
Expand Down
3 changes: 0 additions & 3 deletions coms/coms/robot_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
logger = logging.getLogger(__name__)


# This file will have the ZMQ socket and dealing with the robot configuration file


class DataPublisher(threading.Thread):
def __init__(self, data, event, robot_config_dir, message=" ", sleep_time=5, pub_port=5454, rep_port=5455):
super(DataPublisher, self).__init__()
Expand Down
6 changes: 0 additions & 6 deletions coms/coms/server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import socket
import logging
import json
from byodr.utils.ssh import Nano

# import signal
# signal.signal(signal.SIGPIPE,signal.SIG_DFL)

nano_ip = Nano.get_ip_address()


# Declaring the logger
Expand Down

0 comments on commit 2529c7a

Please sign in to comment.