PYTHON   16

follow tle offset demo py

Guest on 15th August 2022 12:35:22 PM

  1. # Sample code to follow a TLE entry retrieved fromfrom
  2. # https://www.celestrak.com/NORAD/elements/geo.txt
  3. # Also perform some position offsets around that target.
  4. #
  5. # To see a demonstration of this code in action,
  6. # please visit https://www.youtube.com/watch?v=6f52QBC5k9k
  7.  
  8. import time
  9.  
  10. from pwi4_client import PWI4
  11.  
  12. # Boilerplate: define a function to wait for user input that
  13. # works with both Python2 and Python3
  14. try:
  15.     wait_for_input = raw_input  # For Python 2
  16. except NameError:
  17.     wait_for_input = input  # For Python 3
  18.  
  19.  
  20.  
  21. # Create the PWI4 object
  22. print("Connecting to PWI4...")
  23. pwi4 = PWI4()
  24.  
  25.  
  26. # Make sure mount is connected and motors are energized
  27. print("Connecting to mount and enabling motors...")
  28. pwi4.mount_connect()
  29. pwi4.mount_enable(0)
  30. pwi4.mount_enable(1)
  31.  
  32. # ARSAT 2 is a geosynchronous satellite that should typically be visible
  33. # from North and South America. The TLE data was retrieved on 2020-05-09.
  34. # The position will become increasingly inaccurate the farther you are
  35. # from this data. Updated TLE data for ARSAT 2 should be retrieved from:
  36. # https://www.celestrak.com/NORAD/elements/geo.txt
  37. tle1 = "ARSAT 2"
  38. tle2 = "1 40941U 15054B   20130.57823185 -.00000235  00000-0  00000-0 0  9999"
  39. tle3 = "2 40941   0.0571 108.1874 0001980 312.1056 294.7159  1.00271294 16963"
  40.  
  41. # If you are instead testing from Europe or Africa, EUTELSAT 33E
  42. # should be a good target that is always above the horizon:
  43. #tle1 = "EUTELSAT 33E"
  44. #tle2 = "1 33750U 09008B   20130.51155170  .00000145  00000-0  00000-0 0  9996"
  45. #tle3 = "2 33750   0.0630  32.6825 0004272  13.0575  39.2896  1.00274144 41095"
  46.  
  47. # If testing from Asia or Australia, EXPRESS-AM3 may be a good target:
  48. #tle1 = "EXPRESS-AM3"
  49. #tle2 = "1 28707U 05023A   20130.62624640 -.00000333  00000-0  00000-0 0  9990"
  50. #tle3 = "2 28707   1.7484  90.9080 0001407 311.8879 153.5809  1.00270011 54489"
  51.  
  52.  
  53. print("Selected TLE:")
  54. print(tle1)
  55. print(tle2)
  56. print(tle3)
  57. wait_for_input("Press enter to begin slewing to follow this TLE")
  58. pwi4.mount_follow_tle(tle1, tle2, tle3)
  59. time.sleep(1) # Give the mount a chance to begin slewing
  60.  
  61. # Monitor distance to target to determine when we have arrived
  62. while True:
  63.     status = pwi4.status()
  64.     dist0 = status.mount.axis0.dist_to_target_arcsec
  65.     dist1 = status.mount.axis1.dist_to_target_arcsec
  66.     print("Distance to target: %.1f x %.1f arcsec" % (dist0, dist1))
  67.  
  68.     # If both axes are within 2 arcseconds of target,
  69.     # break out of loop
  70.     if abs(dist0) < 2 and abs(dist1) < 2:
  71.         print("Arrived at target")
  72.         break
  73.  
  74.     time.sleep(0.2)
  75.  
  76. # Perform a 20 arcsecond offset in the native "axis0" coordinates of the mount,
  77. # For an EQ mount: Axis0 = RA axis, Axis1 = Dec axis
  78. # For an Alt-Az mount: Axis0 = Azimuth axis, Axis1 = Altitude axis
  79. #
  80. # As long as you do not rotate your camera, these directions should remain consistent
  81. # in your field of view, so this coordiante system is a good candidate for performing
  82. # centering/guiding corrections.
  83. wait_for_input("Press Enter to offset mount 20 arcsec in Axis0")
  84. pwi4.mount_offset(axis0_add_arcsec=20)
  85.  
  86.  
  87. # Make a 20 arcsecond correction in the axis1 direction
  88. wait_for_input("Press Enter to offset mount 20 arcsec in Axis1")
  89. pwi4.mount_offset(axis1_add_arcsec=20)
  90.  
  91. # You can also set both offsets simultaneously
  92. wait_for_input("Press Enter to offset 20 arcsec in both Axis0 and Axis1")
  93. pwi4.mount_offset(axis0_add_arcsec=20, axis1_add_arcsec=20)
  94.  
  95. # You can also set both offsets simultaneously
  96. wait_for_input("Press Enter to clear all accumulated offsets and return to original position")
  97. pwi4.mount_offset(axis0_reset=0, axis1_reset=0)
  98.  
  99. # Other coordinate systems are available as well, such as RA/Dec
  100. wait_for_input("Press Enter to offset 20 arcsec in Dec")
  101. pwi4.mount_offset(dec_add_arcsec=20)
  102.  
  103. wait_for_input("Press Enter to offset 20 arcsec in RA")
  104. pwi4.mount_offset(ra_add_arcsec=20)
  105.  
  106. # You can also set offset tracking rates in any of these axes
  107. wait_for_input("Press Enter to move 5 arcsec/sec along Axis1")
  108. pwi4.mount_offset(axis1_set_rate_arcsec_per_sec=5)
  109.  
  110. wait_for_input("Press Enter to stop moving along Axis1")
  111. pwi4.mount_offset(axis1_stop_rate=0)
  112.  
  113.  
  114. # Stop
  115. wait_for_input("Press Enter to stop mount")
  116. pwi4.mount_stop()

Raw Paste


Login or Register to edit or fork this paste. It's free.