Skip to content

src/robot/communication #28

Closed
Closed

Description

@KavinduMethpura
No description provided.

Activity

  1. Hasala-Kavinda commented on Nov 13, 2025

    @Hasala-Kavinda

    MODIFICATION #1
    src/robot/communication/directed_comm.py
    Instead of havind COMMUNICATION_IN_DIR as a string, it can be implemented as a Enum

    class MqttTopic(Enum):
        COMMUNICATION_IN_DIR = "COMMUNICATION_IN_DIR"
        
    
        def __init__(self, robot_id: int, mqtt_client: RobotMqttClient):
            super().__init__(robot_id, mqtt_client)
            self._topics_sub: dict[str, str] = {}
             self._subscribe(self.MqttTopic.COMMUNICATION_IN_DIR, f"comm/in/direct/{robot_id}")
    
        def _subscribe(self, key: MqttTopic, topic: str) -> None:
            self._topics_sub[key] = topic
            self.robot_mqtt_client.subscribe(topic)
    
       def handle_subscription(self, robot, m: MqttMsg) -> None:
            topic, msg = m.topic, m.message
            if topic ==self.topics_sub.get(self.MqttTopic.COMMUNICATION_IN_DIR.value):
                robot.communication_interrupt(msg)
    
           else:
                print(f"Received (unknown dir): {topic}> {msg}")
        
    

    MODIFICATION #2
    [src/robot/communication/simple_comm.py
    can implement the enum feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions