在ROS master上的Python程式,可將控制FRC的Networktables程式,與ROS python的rclpy來publish程式,結合在一起。

但不需要去研究Network tables如何轉換成ROS topic messages,或是ROS怎麼控制Network tables,那都太複雜。而是藉由JSON的檔案格式作為兩者之間的溝通媒介。
之前的文章透過mqtt client監聽到雲端傳來的by topics的JSON訊息。
self.client = mqtt.Client()
self.client.on_message = self.subscribe_from_iot
#透過rclpy.node產生publisher node 
self.ros_publishers[topic] = self.create_publisher(PointStamped, ros_topic, 10)
#初始化Network Tables
NetworkTables.initialize(self.ip)
將資料同時傳給ROS cluster與寫入NetworkTables
def subscribe_from_iot(self, client, userdata, msg):
    if msg.topic == 'clicked_point':
       data = json.loads(msg.payload.decode('utf-8'))
       pub_msg = PointStamped()
       pub_msg.header.stamp = self.get_clock().now().to_msg()
       pub_msg.header.frame_id = 'map'
       if "point" in data:
         pub_msg.point.x = float(data['point']['x'])
         pub_msg.point.y = float(data['point']['y'])
         pub_msg.point.z = float(data['point']['z'])
       #將資料傳給ROS
       self.ros_publishers[msg.topic].publish(pub_msg)
       
       #將資料傳給FRC
       sd = NetworkTables.getTable("SmartDashboard")
       sd.putNumber("ProcessVariable positions", pub_msg.point);