There was a python script for attempting to track satellites written a few years back by user Farom.
www.indilib.org/forum/wish-list/1765-sat...nfusion.html?start=0
The script no-longer appears to work properly with ongoing developments. Specifically there are problems importing PyIndi and a depreciated file causing an import error for libindi.so.1.
I would like to get it working again, but coding is not my field of expertise. But I have attempted to make changes to the Geographic Location portion to get Lat/Long by parsing NMEA sentences straight from the GPS. I think it's ok, but I could use a second opinion.
It would also be nice if the TLE information could be fetched automatically.
Here is the Python3 script. Thanks in advance
# --- Settings ---
# Change following parameters according to your need
# Geographic location
import serial
port = "/dev/tty0"
def parseGPS(data):
if data[0:6] == "$GPRMS":
sdata = data.split(",")
latitude = decode(sdata[3])
longitude = decode(sdata[5])
# Satellite TLE (can be retreived on https://www.space-track.org)
TLE_line_1 = '1 25544U 98067A 19136.87606988 .00001918 00000-0 37995-4 0 9998'
TLE_line_2 = '2 25544 51.6418 156.7644 0001513 1.2176 59.1588 15.52681763170397'
# INDI settings
host = 'localhost'
port = 7624
driver_name ="Telescope Simulator"
# Script settings
update_delay = 1 # delay in s between updates
# --- Code ---
import PyIndi
import time
import sys
import threading
import ephem
from math import pi
# default client
class IndiClient(PyIndi.BaseClient):
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
pass
def newProperty(self, p):
pass
def removeProperty(self, p):
pass
def newBLOB(self, bp):
pass
def newSwitch(self, svp):
pass
def newNumber(self, nvp):
pass
def newText(self, tvp):
pass
def newLight(self, lvp):
pass
def newMessage(self, d, m):
pass
def serverConnected(self):
pass
def serverDisconnected(self, code):
pass
# connect the server
print("Connection to " + host + ":" + str(port) + " ... ", end='')
indiclient=IndiClient()
indiclient.setServer(host,port)
if (not(indiclient.connectServer())):
print("FAILED")
print("No indiserver running on "+indiclient.getHost()+":"+str(indiclient.getPort()))
sys.exit(1)
print("OK")
# get the telescope device
print("Get driver '"+ driver_name + "' ... ", end='')
device_telescope=None
telescope_connect=None
device_telescope=indiclient.getDevice(driver_name)
while not(device_telescope):
time.sleep(0.5)
device_telescope=indiclient.getDevice(driver_name)
print("OK")
# wait CONNECTION property be defined for telescope
print("Wait CONNECTION property be defined ... ", end='')
telescope_connect=device_telescope.getSwitch("CONNECTION")
while not(telescope_connect):
time.sleep(0.5)
telescope_connect=device_telescope.getSwitch("CONNECTION")
print("OK")
# if the telescope device is not connected, we do connect it
if not(device_telescope.isConnected()):
print("Driver not connected, try to connect it ... ", end='')
# Property vectors are mapped to iterable Python objects
# Hence we can access each element of the vector using Python indexing
# each element of the "CONNECTION" vector is a ISwitch
telescope_connect[0].s=PyIndi.ISS_ON # the "CONNECT" switch
telescope_connect[1].s=PyIndi.ISS_OFF # the "DISCONNECT" switch
indiclient.sendNewSwitch(telescope_connect) # send this new value to the device
t=10
while not(device_telescope.isConnected()) and t>0:
time.sleep(1)
t-=1
if not(device_telescope.isConnected()):
print("FAILED")
print("Failed to connect the driver")
sys.exit(1)
print("OK")
# We want to set the ON_COORD_SET switch to engage tracking after goto
# device.getSwitch is a helper to retrieve a property vector
print("Set tracking mode ... ", end='')
telescope_on_coord_set=device_telescope.getSwitch("ON_COORD_SET")
while not(telescope_on_coord_set):
time.sleep(0.5)
telescope_on_coord_set=device_telescope.getSwitch("ON_COORD_SET")
# the order below is defined in the property vector, look at the standard Properties page
# or enumerate them in the Python shell when you're developing your program
telescope_on_coord_set[0].s=PyIndi.ISS_ON # TRACK
telescope_on_coord_set[1].s=PyIndi.ISS_OFF # SLEW
telescope_on_coord_set[2].s=PyIndi.ISS_OFF # SYNC
indiclient.sendNewSwitch(telescope_on_coord_set)
telescope_radec=device_telescope.getNumber("EQUATORIAL_EOD_COORD")
while not(telescope_radec):
time.sleep(0.5)
telescope_radec=device_telescope.getNumber("EQUATORIAL_EOD_COORD")
print("OK")
# Configure PyEphem
print("Configure PyEphem ... ", end='')
obs = ephem.Observer()
obs.lon = longitude
obs.lat = latitude
satellite = ephem.readtle('TARGET',TLE_line_1,TLE_line_2)
print("OK")
while 1:
# compute satellite coordinates
obs.date = ephem.now()
satellite.compute(obs)
print(obs.date)
print(" RA: ",satellite.ra)
print(" DEC:",satellite.dec)
print(" ALT:",satellite.alt)
print(" AZ: ",satellite.az)
# We set the desired coordinates
telescope_radec[0].value=ephem.hours(satellite.ra)*24/2/pi
telescope_radec[1].value=ephem.degrees(satellite.dec)*360/2/pi
indiclient.sendNewNumber(telescope_radec)
time.sleep(update_delay)
When I run the script, this is what I get back
Traceback (most recent call last):
File "trackgps.py", line 26, in <module>
import PyIndi
File "/home/astropi/.local/lib/python3.5/site-packages/pyindi_client-0.1.0a1-py3.5-linux-armv7l.egg/PyIndi.py", line 28, in <module>
_PyIndi = swig_import_helper()
File "/home/astropi/.local/lib/python3.5/site-packages/pyindi_client-0.1.0a1-py3.5-linux-armv7l.egg/PyIndi.py", line 24, in swig_import_helper
_mod = imp.load_module('_PyIndi', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libindi.so.1: cannot open shared object file: No such file or directory