Ejemplo n.º 1
0
 def registration(self, name, user=""):
     msg = String_necst()
     if user == "master":
         msg.data = name
         msg.from_node = "master"
         msg.timestamp = time.time()
     else:
         msg.data = name
         msg.from_node = self.node_name
         msg.timestamp = time.time()
     self.pub_regist.publish(msg)
     return
Ejemplo n.º 2
0
def node_active():
    fmsg = NECST_list_msg()
    fmsg.from_node = node_name
    nmsg = String_necst()
    nmsg.from_node = node_name
    while not rospy.is_shutdown():
        #ct=dt.utcnow()
        #date = ct.strftime("%Y-%m-%d")
        #try:
        #data1=db.SELECT("Node_status", date, date, num=1)
        if func_status:
            #data_dict1 = ast.literal_eval(data1[1])
            #func_status.update(data_dict1)
            param = func_status
            fmsg.m2 = param["m2_controller"]
            fmsg.m4 = param["m4_controller"]
            fmsg.hot = param["abs_controller"]
            fmsg.scan_linear = param["worldcoordinate_linear"]
            fmsg.scan_onepoint = param["worldcoordinate_onepoint"]
            fmsg.scan_planet = param["worldcoordinate_planet"]
            fmsg.scan_otf = param["worldcoordinate_otf"]
            fmsg.encoder = param["encoder_status"]
            fmsg.azel_list = param["azel_list"]
            fmsg.timestamp = time.time()
            pub_func.publish(fmsg)
        if node_status:
            #node_status = ast.literal_eval(data1[2])
            param = str(node_status)
            nmsg.data = param
            nmsg.timestamp = time.time()
            pub_node.publish(nmsg)
        #except Exception as e:
        #rospy.logerr(e)
        time.sleep(0.1)
    return
Ejemplo n.º 3
0
 def registration(self, name=""):
     msg = String_necst()
     msg.data = name
     msg.from_node = self.node_name
     msg.timestamp = time.time()
     self.pub.publish(msg)
     return
 def authority_check(self):
     msg = String_necst()
     while not rospy.is_shutdown():
         self.node_alive()
         msg.data = self.authority
         self.pub.publish(msg)
         #print(msg)
         time.sleep(1.)
     return
Ejemplo n.º 5
0
 def pub_status(self):
     msg = String_necst()
     msg.from_node = node_name
     while not rospy.is_shutdown():
         msg.data = self.position  #dev.get_pos()
         msg.timestamp = time.time()
         self.pub.publish(msg)
         time.sleep(0.1)
     return
Ejemplo n.º 6
0
def pub_topic():
    msg = String_necst()
    while not rospy.is_shutdown():
        ctopic = topic_dict
        dump = json.dumps(ctopic)
        msg.from_node = node_name
        msg.timestamp = time.time()
        msg.data = dump
        pub.publish(msg)
        time.sleep(1)
Ejemplo n.º 7
0
 def alert(self, message, node_name="", emergency=False):
     msg = String_necst()
     msg.data = message
     msg.from_node = node_name
     msg.timestamp = time.time()
     self.pub_alert.publish(msg)
     if emergency:
         self.pub_obs_stop.publish(message, self.node_name, time.time())
     else:
         pass
     return
Ejemplo n.º 8
0
    def move_hot(self, position):
        """hotload move

        Parameter
        ---------
        position : in or out
        """
        status = String_necst()
        status.data = position
        status.from_node = self.node_name
        status.timestamp = time.time()        
        self.pub_hot.publish(status)
        return
Ejemplo n.º 9
0
    def drive(self, switch = ""):
        """change drive

        Parameters
        ----------
        swith : on or off
        
        """
        msg = String_necst()
        self.move_stop()
        if not switch:
            switch = str(input("drive change (on/off) : ")).lower()
        msg.data =  switch
        msg.from_node = self.node_name
        msg.timestamp = time.time()
        if switch in ["on", "off", "ON", "OFF"]:
            self.pub_drive.publish(msg)
            self.pub_contactor.publish(msg)
            print("drive : ", switch, "!!")
        else:
            rospy.logwarn("!!bad command!!")
            pass
        return