def add_local_dns_to_robot(self): self._print_title("ADDING LOCAL DNS TO ROBOT") rospy.loginfo("IPS FOUND: " + str(self.MY_IPS)) if not self.using_the_robot: self._print_warning("Not checking. ROS_MASTER_URI no contains " + str(ROBOTS_NAME)) return succeeded for robot_name in ROBOTS_NAME: if robot_name in ROS_MASTER_URI.lower(): robot_ip = socket.gethostbyname(ROBOT_COMPUTER_NAME) command = "ip route get %s" % str(robot_ip) out, err = Popen(command, shell=True, stdout=PIPE, stderr=PIPE).communicate() route_to_robot = out.split("\n")[0] my_ip = route_to_robot.split(" ")[len(route_to_robot.split(" ")) - 2] rospy.loginfo("SELECTED IP: %s" % my_ip) command = "addLocalDns -u %s -i %s " % (COMPUTERNAME, my_ip) status = RunCommandOnRobot(command).execute(UserdataHacked()) if status == succeeded: self._print_info("Successfully added {%s, %s}" % (COMPUTERNAME, my_ip)) else: self.ALL_OK = False self._print_fatal("Failed adding {%s, %s}." % (COMPUTERNAME, my_ip)) return status # self.ALL_OK = False self._print_warning("Not added. Running on the robot.")
def synchronize_time(self): self._print_title("SYNCHRONIZING TIME") if not self.using_the_robot: self._print_warning("Not synchronizing. ROS_MASTER_URI no contains %s " % ROBOTS_NAME) return succeeded for robot_name in ROBOTS_NAME: if robot_name in ROS_MASTER_URI.lower(): command = "ntpdate -u " + str(ROBOT_COMPUTER_NAME) if RunCommandLocal(command=command, sudo_enabled=True).execute(UserdataHacked()) == succeeded: self._print_info("Synchronizing time: OK") else: self.ALL_OK = False self._print_fatal("Synchronizing time: FAILED") break