def test(sg1: common.stargate):

    print("--- read current degrees ---")
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    print("--- set degree to 0 ---")
    sg1.motor_dec.set_degree(0)
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    print("--- call move_degree ---")
    threading2 = threading.Thread(target=sg1.motor_dec.move_degree(10, 5, sg1))
    threading2.daemon = True
    threading2.start()
    threading2.join()
    print("---start ---")
    time.sleep(1)
    print("---after 1sec ---")
    print("current steps = " + str(sg1.motor_dec.get_steps()))
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    time.sleep(5)
    print("--- after 5sec ---")
    print("current steps = " + str(sg1.motor_dec.get_steps()))
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    time.sleep(10)
    print("--- after 10sec ---")
    print("current steps = " + str(sg1.motor_dec.get_steps()))
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    time.sleep(20)
    print("--- after 20sec ---")
    print("current steps = " + str(sg1.motor_dec.get_steps()))
    print("current degrees = " + str(sg1.motor_dec.get_degree()))
    print("--- END ---")
    common.read_character()
def mode_test(sg1):
    MOTOR_BASEADDR = 0x43c40000 + (0x2000 * 4)
    Motor_1_steps = 0x0A
    Motor_1_command = 0x08

    motor1 = motor(MOTOR_BASEADDR, Motor_1_command, Motor_1_steps, 5)
    print(motor1.get_steps())
    motor1.set_steps(33)
    print(motor1.get_steps())
    thread1 = threading.Thread(target=motor1.set_steps(66))
    thread1.daemon = True
    thread1.start()
    thread1.join()
    print(motor1.get_steps())

    cord = class_steps.hl_goto_koord(0, 0, 5, 15)
    print(cord.get_rektanzension())
    print(cord.get_deklination())
    threading2 = threading.Thread(target=motor1.move(200, 0, 1))
    threading2.daemon = True
    threading2.start()
    threading2.join()
    print("ok")
    time.sleep(1)
    print(motor1.get_steps())
    print(motor1.get_degree())

    cmd_in = common.read_character()
예제 #3
0
def test(sg1: common.stargate):
    print('start')
    sg1.mystatus.observe = "TRUE"
    eph = magic.ephemeris_calculations(None, sg1.mydata.gps_latitude,
                                       sg1.mydata.gps_longitude,
                                       sg1.mydata.gps_altitude)
    eph.make_new_objekt("star", "Vega")
    #eph.get_pos_spherical(dict1)
    #print(dict1)
    print('thread')
    threadingc = threading.Thread(target=eph.get_pos_spherical, args=(sg1, ))
    threadingc.daemon = True
    threadingc.start()
    print(sg1.mycalc.ra_sp)
    print(sg1.mycalc.dec_sp)
    print('ra')
    sg1.motor_ra.move_degree(sg1.mycalc.ra_sp, 2, sg1)
    print('dec')
    sg1.motor_dec.move_degree(sg1.mycalc.dec_sp, 2, sg1)

    common.read_character()
예제 #4
0
def main(sg1):
    # flags
    kill = []
    gps_setup = True

    # start thread
    thread1 = threading.Thread(target=print_setup,
                               args=(sg1, 'continius', kill))
    thread1.daemon = True
    thread1.start()
    while gps_setup:
        cmd_in = common.read_character()
        if cmd_in == 'x':
            kill.append(True)
            gps_setup = False
            print('gps setup finished? [y/n]')
            print('press x to exit gps setup without saving')
            cmd_in = common.read_character()
            if cmd_in == 'y':
                sg1.mydata.set_nmod_gps(True)
                common
            elif cmd_in == 'n':
                main()
            elif cmd_in == 'x':
                sg1.mydata.set_nmod_gps(False)
            else:
                main()
            print('set system date and time to: ' +
                  str(sg1.mydata.get_gps_time()) + ' [y/n]')
            print('press x to exit without seting date and time')
            cmd_in = common.read_character()
            if cmd_in == 'y':
                common.set_time(sg1.mydata)
            elif cmd_in == 'n':
                main()
            elif cmd_in == 'x':
                gps_setup = False
            else:
                main()
예제 #5
0
def main(sg1: common.stargate):
    # flags

    print()
    print('------------ Set polaris ------------')
    print('--------------------------------------')
    print("  motor ra: " + str(sg1.motor_ra.get_steps()))
    print("  motor dec: " + str(sg1.motor_dec.get_steps()))
    print('--------------------------------------')
    print('please aligne the telescope to the northstar')
    print('press x to exit')
    cmd_in = common.read_character()
    if cmd_in == 'x':
        print('aligment finished, set step to ra=0 und dec=0? [y/n]')
        print('press x to exit without setting steps')
        cmd_in = common.read_character()
        if cmd_in == 'y':
            threading_decS = threading.Thread(
                target=sg1.motor_dec.move_steps(1, 0, 5, 1))
            threading_decS.daemon = True
            threading_decS.start()
            threading_raS = threading.Thread(
                target=sg1.motor_ra.move_steps(1, 0, 5, 1))
            threading_raS.daemon = True
            threading_raS.start()
            sg1.mydata.set_polaris(True)
            sg1.motor_ra.set_degree(90 * (-1))
            sg1.motor_dec.set_degree(90 * (-1))
            print('--------------------------------------')
            print("  motor1 ra: " + str(sg1.motor_ra.get_steps()))
            print("  motor1 dec: " + str(sg1.motor_dec.get_steps()))
            print('--------------------------------------')
            time.sleep(1)
        elif cmd_in == 'n':  #HIR vll gef
            main(sg1)
        elif cmd_in == 'x':
            sg1.mydata.set_polaris(False)
        else:
            main(sg1)
예제 #6
0
def test(myData):
    print("star1")
    print(myData.get_T_sp())
    calc_spherical_to_cartesian(myData, 0, 10.1, 20.3, 30.5, 19.9, 29.6)
    calc_spherical_to_cartesian(myData, 1, 10.1, 50.3, 80.5, 50.3, 80.5)
    calc_spherical_to_cartesian(myData, 2, 10.1, 70.3, 110.5, 70.3, 110.5)
    print(myData.get_T_sp())
    calc_T_corr(myData)
    print("start2")
    calc_sp_corr(myData, 10.1, 20.3, 30.5)
    '''
    print("TEST vektor")
    mat = np.array([(1,-1,2), (0,-3,1)])
    vec = np.array([(2),(1),(0)])
    vec_sp = mat * vec
    print(mat)
    print("*")
    print(vec)
    print("=")
    print(vec_sp)
    '''
    common.read_character()
예제 #7
0
def test2(sg1: common.stargate):
    print('create object of observation ... ')
    sg1.mystatus.observe = "TRUE"
    eph = magic.ephemeris_calculations(None, sg1.mydata.gps_latitude,
                                       sg1.mydata.gps_longitude,
                                       sg1.mydata.gps_altitude)
    eph.make_new_objekt("star", "Vega")
    print('start calculations ... ')
    print('thread')
    threading1 = threading.Thread(name='calc',
                                  target=eph.get_pos_spherical,
                                  args=(sg1, ))
    threading1.daemon = True
    threading1.start()
    print('start observation ... ')
    time.sleep(2)
    threading3 = threading.Thread(name='header',
                                  target=header,
                                  args=(sg1, "Vega"))
    threading3.daemon = True
    threading3.start()
    while (sg1.mystatus.observe == "TRUE"):
        cmd_in = common.read_character()
        if cmd_in == 'x':
            sg1.mystatus.observe = "False"
        elif cmd_in == 's':
            threading4 = threading.Thread(
                target=sg1.motor_dec.move_steps(10, 0, 5, 1))
            threading4.daemon = True
            threading4.start()
            threading5 = threading.Thread(
                target=sg1.motor_ra.move_steps(10, 0, 5, 1))
            threading5.daemon = True
            threading5.start()
        elif cmd_in == 'g':
            threading6 = threading.Thread(target=sg1.motor_ra.move_degree,
                                          args=(sg1.mycalc.ra_sp, 5))
            threading6.daemon = True
            threading6.start()
        elif cmd_in == 'm':
            sg1.mystatus.observe = "MANUAL"
            motor_control.mode_manual(sg1)
예제 #8
0
 elif 'manual_correction' in answers["tasks"]:
     motor_control.mode_manual(sg1)
 elif 'star3_verification' in answers["tasks"]:
     star3_verification.main(sg1)
 elif 'goto' in answers["tasks"]:
     goto.main(sg1)
 elif 'observe' in answers["tasks"]:
     observe.main(sg1)            
 elif 'test' in answers["tasks"]:
     #motor_control.mode_test(sg1)
     #magic.test_runtime_star(sg1)
     #magic.test_runtime_planet(sg1)
     #magic.test_runtime_moon(sg1)
     #magic.test_runtime_sat(sg1)
     motor_control.test(sg1)
     common.read_character()
 elif 'debug mode' in answers["tasks"]:
     if sg1.mydata.get_debug_mode() == False:
         sg1.mydata.set_debug_mode(True)
     elif sg1.mydata.get_debug_mode() == True:
         sg1.mydata.set_debug_mode(False)
 elif 'exit' in answers["tasks"]:
     running = False
     
 
     
     
     
     
     
     
예제 #9
0
def main(sg1: common.stargate, target=None):
    if target == None and sg1.mytarget.target == None:
        print('no target selected')
        sg1.mystatus.observe = "False"
        time.sleep(1)
    else:
        print('start')
        # creating an target object
        sg1.mystatus.observe = "TRUE"
        eph = magic.ephemeris_calculations(None, sg1.mydata.gps_latitude,
                                           sg1.mydata.gps_longitude,
                                           sg1.mydata.gps_altitude)
        eph.make_new_objekt("star", str(target))
        print('start calculations ... ')
        print('thread')
        # calculation the angles of the target
        threading_calc = threading.Thread(name='calc',
                                          target=eph.get_pos_spherical,
                                          args=(sg1, ))
        threading_calc.daemon = True
        threading_calc.start()
        #threading6 = threading.Thread(target=sg1.motor_ra.move_steps(64836,0,2,0))
        #threading6.daemon = True
        #threading6.start()

        # starting the motors
        threading_ra = threading.Thread(name='ra',
                                        target=sg1.motor_ra.move_degree,
                                        args=(sg1.mycalc.ra_sp, 2, sg1))
        threading_ra.daemon = True
        threading_ra.start()
        threading_dec = threading.Thread(name='dec',
                                         target=sg1.motor_dec.move_degree,
                                         args=(sg1.mycalc.dec_sp, 2, sg1))
        threading_dec.daemon = True
        threading_dec.start()

        # header
        threading_header = threading.Thread(name='header',
                                            target=header,
                                            args=(sg1, sg1.mytarget.target))
        threading_header.daemon = True
        threading_header.start()

    # keyboard input
    while (sg1.mystatus.observe == "TRUE"):
        cmd_in = common.read_character()
        if cmd_in == 'x':
            sg1.mystatus.observe = False
            os.system('clear')
        elif cmd_in == 'g':
            threading6 = threading.Thread(
                target=sg1.motor_dec.move_steps(10, 0, 5, 1))
            threading6.daemon = True
            threading6.start()
        elif cmd_in == 's':
            threading_decS = threading.Thread(
                target=sg1.motor_dec.move_steps(0, 0, 5, 1))
            threading_decS.daemon = True
            threading_decS.start()
            threading_raS = threading.Thread(
                target=sg1.motor_ra.move_steps(0, 0, 5, 1))
            threading_raS.daemon = True
            threading_raS.start()
        elif cmd_in == 'm':
            sg1.mystatus.observe = "MANUAL"
            motor_control.mode_manual(sg1)
        elif cmd_in == 'y':
            sg1.mystatus.observe = "MANUAL"
            motor_control.mode_manual(sg1)
예제 #10
0
def get_degree_z(x, y, z):
    zAngle = math.atan(math.sqrt((x * x) + (y * y)) / z)
    zAngle = zAngle * 180 / 3.141592
    return zAngle


def get_compass(x, y):
    D = math.atan(y / x) * 180 / 3.141592
    return D


qm = class_queue.QueueMap()

while True:
    cmd_in = common.read_character()
    if cmd_in == 'v':
        print('starting')
        thread1 = threading.Thread(nav.acc_get_value(qm))
        thread1.daemon = True
        thread1.start()
        print(threading.active_count())
        thread1.join()
        print(threading.active_count())
        print('done')
        print(qm.pop('acc_x'))
        print(qm.pop('acc_y'))
        print(qm.pop('acc_z'))
        time.sleep(3)
    elif cmd_in == 'e':
        sys.exit()
def mode_manual(sg1: common.stargate):
    manual_on = True
    motor_speed = 5
    mot_dec_pos_start = sg1.motor_dec.get_steps()
    mot_ra_pos_start = sg1.motor_ra.get_steps()
    while manual_on:
        common.header_move(sg1)
        print('speed: ' + str(motor_speed))
        cmd_in = common.read_character()
        if cmd_in == 'w':
            # move dec north
            threading2 = threading.Thread(
                target=sg1.motor_dec.move_steps(100, 0, motor_speed, 1))
            threading2.daemon = True
            threading2.start()
            threading2.join()
        elif cmd_in == 's':
            # move dec south
            threading2 = threading.Thread(
                target=sg1.motor_dec.move_steps(100, 0, motor_speed, 0))
            threading2.daemon = True
            threading2.start()
            threading2.join()
        elif cmd_in == 'a':
            # move ra east
            threading2 = threading.Thread(
                target=sg1.motor_ra.move_steps(100, 0, motor_speed, 1))
            threading2.daemon = True
            threading2.start()
            threading2.join()
        elif cmd_in == 'd':
            # move ra west
            threading2 = threading.Thread(
                target=sg1.motor_ra.move_steps(100, 0, motor_speed, 0))
            threading2.daemon = True
            threading2.start()
            threading2.join()
        elif cmd_in == 'q':
            # increase pause between steps
            motor_speed = motor_speed + 1
            if motor_speed > 10:
                motor_speed = 10
            print(motor_speed)
        elif cmd_in == 'e':
            # decrease pause between steps
            motor_speed = motor_speed - 1
            if motor_speed < 1:
                motor_speed = 1
            print(motor_speed)
        elif cmd_in == 'x':
            # exit
            mot_dec_pos_diff = sg1.motor_dec.get_steps() - mot_dec_pos_start
            mot_ra_pos_diff = sg1.motor_ra.get_steps() - mot_ra_pos_start
            sg1.mydata.set_motor_dec_diff(mot_dec_pos_diff)
            sg1.mydata.set_motor_ra_diff(mot_ra_pos_diff)
            manual_on = False
            if sg1.mystatus.observe == "MANUAL":
                if sg1.mytarget.target == sg1.mytarget.star1:
                    sg1.mytarget.star1_ok = "finished"
                elif sg1.mytarget.target == sg1.mytarget.star2:
                    sg1.mytarget.star2_ok = "finished"
                elif sg1.mytarget.target == sg1.mytarget.star3:
                    sg1.mytarget.star3_ok = "finished"
                star3_verification.select(sg1)