Пример #1
0
    def create_list(self):
        msg = List_coord_msg()
        msg.from_node = node_name
        nanten2 = EarthLocation(lat=-22.96995611 * u.deg,
                                lon=-67.70308139 * u.deg,
                                height=4863.85 * u.m)
        list_num = 600
        delta_t = 1  #[s]
        while not rospy.is_shutdown():
            command = self.command
            self.command = ""
            if command:
                print("start_create_list")
                pass
            else:
                time.sleep(0.1)
                continue
            time_list = [
                dt.fromtimestamp(command.timestamp + delta_t * i)
                for i in range(list_num)
            ]

            if not command.planet.lower() in self.planet_list:
                rospy.logerr("planet name is false...")
                continue
            else:
                pass
            target_list = get_body(command.planet.lower(),
                                   Time(time_list))  #gcrs
            target_list.location = nanten2
            altaz_list = target_list.altaz
            if not all((0. < i < 90. for i in altaz_list.alt.deg)):
                rospy.logerr("This planet is not rizing...")
                continue
            ret = calc_offset.calc_offset(altaz_list.az.deg,
                                          altaz_list.alt.deg, "altaz",
                                          command.off_x, command.off_y,
                                          command.offcoord, command.dcos,
                                          time_list)

            current_time = time.time()

            msg.x_list = ret[0]
            msg.y_list = ret[1]
            msg.time_list = [
                command.timestamp + delta_t * i for i in range(list_num)
            ]
            msg.coord = "planet"
            msg.off_az = ret[2]
            msg.off_el = ret[3]
            msg.hosei = command.hosei
            msg.lamda = command.lamda
            msg.limit = command.limit
            msg.timestamp = current_time
            self.pub.publish(msg)
        return
Пример #2
0
    def create_list(self):
        msg = List_coord_msg()
        msg.from_node = node_name
        while not rospy.is_shutdown():
            command = self.command
            self.command = ""
            if command:
                print("start_create_list")
                #ret = calc_offset.calc_offset(command.x, command.y, command.coord,
                #                              command.off_x, command.off_y, command.offcoord,
                #                              command.dcos)

                start_x = command.off_x - float(command.dx) / 2. - float(
                    command.dx) / float(command.dt) * command.rampt
                start_y = command.off_y - float(command.dy) / 2. - float(
                    command.dy) / float(command.dt) * command.rampt
                total_t = command.rampt * 2 + command.dt * command.num
                end_x = command.off_x + command.dx * (
                    command.rampt / command.dt + command.num - 0.5)
                end_y = command.off_y + command.dy * (
                    command.rampt / command.dt + command.num - 0.5)
                print(start_x, end_x, command.x)
                #off_dx_vel = (end_x - start_x) / total_t #(obs_end - obs_start)
                #off_dy_vel = (end_y - start_y) / total_t #(obs_end - obs_start)
                #x_list = [command.x+(start_x+off_dx_vel*i*0.1)/3600. for i in range(int(round(total_t/command.dt))*10)]
                #y_list = [command.y+(start_y+off_dy_vel*i*0.1)/3600. for i in range(int(round(total_t/command.dt))*10)]

                msg.x_list = [
                    command.x * 3600. + start_x, command.x * 3600. + end_x
                ]
                msg.y_list = [
                    command.y * 3600. + start_y, command.y * 3600. + end_y
                ]
                current_time = time.time()

                msg.time_list = [
                    command.timestamp + command.delay,
                    command.timestamp + command.delay + total_t
                ]
                msg.coord = command.coord_sys
                msg.off_az = 0
                msg.off_el = 0
                msg.hosei = command.hosei
                msg.lamda = command.lamda
                msg.limit = command.limit
                msg.timestamp = current_time
                self.pub.publish(msg)
                print(msg)
                print("publish status!!\n")
                print("end_create_list\n")
            else:
                pass
            time.sleep(0.1)
        return
Пример #3
0
    def create_list(self):
        msg = List_coord_msg()
        msg.from_node = node_name
        while not rospy.is_shutdown():
            command = self.command
            self.command = ""
            if command:
                print("start_create_list")

                ret = calc_offset.calc_offset([command.x], [command.y],
                                              command.coord,
                                              [command.off_x], [command.off_y],
                                              command.offcoord,
                                              command.dcos,
                                              [dt.fromtimestamp(command.timestamp)])
                if not ret:
                    continue
                current_time = time.time()

                msg.x_list = [ret[0], ret[0]]
                msg.y_list = [ret[1], ret[1]]
                msg.time_list = [command.timestamp, command.timestamp+3600.]
                msg.coord = command.coord
                msg.off_az = ret[2]
                msg.off_el = ret[3]
                msg.hosei = command.hosei
                msg.lamda = command.lamda
                msg.limit = command.limit
                msg.rotation = command.rotation
                msg.timestamp = current_time
                self.pub.publish(msg)
                print(msg)
                print("publish status!!\n")
                print("end_create_list\n")
            else:
                pass
            time.sleep(0.1)
        return
Пример #4
0
    def create_list(self):
        msg = List_coord_msg()
        msg.from_node = node_name
        while not rospy.is_shutdown():
            command = self.command
            self.command = ""
            if command:
                num_x = 0
                num_y = 0
                try:
                    coord = command.coord.replace("horizontal", "altaz")
                except:
                    coord = command.coord
                try:
                    offcoord = command.offcoord.replace("horizontal", "altaz")
                except:
                    offcoord = command.offcoord
                coord = SkyCoord(command.x,
                                 command.y,
                                 frame=coord,
                                 unit="deg",
                                 location=nanten2,
                                 obstime=dt.utcnow())

                _coord = coord.transform_to(offcoord)
                for i in range(3601):
                    if -360. * 3600. <= command.off_x * i <= 360. * 3600.:
                        num_x = i
                        pass
                    else:
                        break
                    if -90 * 3600. < _coord.data.lat.arcsec + command.off_y * i < 90 * 3600.:
                        num_y = i
                        pass
                    else:
                        break
                delta_t = min(num_x, num_y)
                rospy.loginfo(command.off_x)
                print(delta_t)
                off_x_list = [
                    command.off_x * delta_t / 4 * i for i in range(5)
                ]
                off_y_list = [
                    command.off_y * delta_t / 4 * i for i in range(5)
                ]
                time_list = [
                    dt.fromtimestamp(command.timestamp + delta_t / 4 * i)
                    for i in range(5)
                ]
                rospy.loginfo(off_x_list)
                ret = calc_offset.calc_offset([command.x for i in range(5)],
                                              [command.y for i in range(5)],
                                              command.coord, off_x_list,
                                              off_y_list, command.offcoord,
                                              command.dcos, time_list)
                rospy.loginfo(command.x)
                rospy.loginfo(ret[0])
                if not ret:
                    continue
                current_time = time.time()

                print(ret[0], ret[1])

                msg.x_list = ret[0]
                msg.y_list = ret[1]
                msg.time_list = [
                    command.timestamp + delta_t / 4 * i for i in range(5)
                ]
                msg.coord = command.coord
                msg.off_az = 0
                msg.off_el = 0
                msg.hosei = command.hosei
                msg.lamda = command.lamda
                msg.limit = command.limit
                msg.timestamp = current_time
                self.pub.publish(msg)
                self.move_on = command.timestamp + delta_t + 0.1
                print(msg)
                print("publish status!!\n")
                print("end_create_list\n")
            else:
                if 0 < self.move_on < time.time():
                    self.pub_stop.publish(True, node_name, time.time())
                    print("emergency stop!!")
                    self.move_on = 0
                    pass
                else:
                    pass
                pass
            time.sleep(0.1)
        return
Пример #5
0
    def create_list(self):
        msg = List_coord_msg()
        msg.from_node = node_name
        nanten2 = EarthLocation(lat=-22.96995611 * u.deg,
                                lon=-67.70308139 * u.deg,
                                height=4863.85 * u.m)
        while not rospy.is_shutdown():
            command = self.command
            self.command = ""
            if command:
                print("start_create_list")
                #ret = calc_offset.calc_offset(command.x, command.y, command.coord,
                #                              command.off_x, command.off_y, command.offcoord,
                #                              command.dcos)

                start_x = command.off_x - float(command.dx) / 2. - float(
                    command.dx) / float(command.dt) * command.rampt
                start_y = command.off_y - float(command.dy) / 2. - float(
                    command.dy) / float(command.dt) * command.rampt
                total_t = command.rampt + command.dt * command.num
                end_x = command.off_x + command.dx * (command.num - 0.5)
                end_y = command.off_y + command.dy * (command.num - 0.5)
                print(start_x, end_x, command.x)

                if not command.planet.lower() in self.planet_list:
                    self.pub_obs_stop.publish("planet name is false...",
                                              node_name, time.time())
                    rospy.logerr("planet name is false...")
                    continue
                else:
                    pass

                time_list = [
                    command.timestamp + command.delay,
                    command.timestamp + command.delay + total_t
                ]
                target_list = get_body(command.planet.lower(),
                                       Time(time_list))  #gcrs
                target_list.location = nanten2
                altaz_list = target_list.altaz
                if not all((0. < i < 90. for i in altaz_list.alt.deg)):
                    self.pub_obs_stop.publish("This planet is not rizing...",
                                              node_name, time.time())
                    rospy.logerr("This planet is not rizing...")
                    continue
                else:
                    pass
                ret_start = calc_offset.calc_offset(altaz_list.az.deg,
                                                    altaz_list.alt.deg,
                                                    "altaz", start_x, start_y,
                                                    "altaz", command.dcos,
                                                    time_list)
                ret_end = calc_offset.calc_offset(altaz_list.az.deg,
                                                  altaz_list.alt.deg, "altaz",
                                                  end_x, end_y, "altaz",
                                                  command.dcos, time_list)

                msg.x_list = [ret_start[0], ret_end[1]]
                msg.y_list = [ret_start[0], ret_end[1]]
                print("x_list", msg.x_list)
                print("y_list", msg.y_list)
                current_time = time.time()

                msg.time_list = [
                    command.timestamp + command.delay,
                    command.timestamp + command.delay + total_t
                ]
                msg.coord = command.coord_sys
                msg.off_az = 0
                msg.off_el = 0
                msg.hosei = command.hosei
                msg.lamda = command.lamda
                msg.limit = command.limit
                msg.timestamp = current_time
                self.pub.publish(msg)
                print(msg)
                print("publish status!!\n")
                print("end_create_list\n")
            else:
                pass
            time.sleep(0.1)
        return