KStars1 has been around a long time, since 2001 in fact. With the addition of the Ekos telescope control, imaging, solving, focus and guiding module, it has become a very core application for astrophotography on Linux, Macintosh and Windows platforms, with very close ties to the INDI standard for interfacing with astronomy equipment. INDI will only run on UNIX-derived operating systems like Linux and Macintosh, although the Mac version of INDI does not have an easy-to-install distribution, having essentially forked into INDIGO2 on Linux and MacOS. KStars and Ekos are also embedded in ASI products like the ASIAir and SeeStar, with more vendors like Celestron probably hopping on board to use Open Source to control their equipment for autoscopes like the forthcoming Celestron Origin line of telescopes.
It’s easy to write clients to control INDI equipment in Python - there’s a library available named PyINDI3 for that purpose. For example, I open and close my observatory currently (while I revamp my INDI compatible controller) with Python scripts using PyIndi to park the telescope prior to moving the roof so it doesn’t strike the telescope.
My ambitions are greater than that, of course- I would like to write code to control all aspects of the observatory based on weather conditions. So I would like to do the following via Python:
Determine if weather conditions are good for opening the roof (see my Detecting Clouds and Arduino Rain Detector articles for more info)
Open the Roof of the Micro-Observatory
Ensure KStars is running and invoke an Ekos Schedule
Shut down the schedule if the weather turns bad
Park the telescope and close the roof
All of this work can be done from Python either using PyIndi or by directly controlling KStars and EKOS via D-Bus. D-Bus was developed as part of the freedesktop.org project, initiated by GNOME developer Havoc Pennington to standardize services provided by Linux desktop environments such as GNOME and KDE4.
It’s easy to see how D-Bus works using the qdbus command line tool. To see what services (paths) are offered by KStars simply use qdbus from the command line
$ qdbus org.kde.kstars
To ask KStars to do something, send the appropriate service a message with your request. For example to position the pointer on the KStars main screen you could use this command:
$ qdbus org.kde.kstars /KStars org.kde.kstars.lookTowards "M 33"
So org.kde.kstars
is the service name, /KStars
is the path, and org.kde.kstars.lookTowards
is the method that is being invoked. To see what methods are provided by the Scheduler, you can use:
$ qdbus org.kde.kstars /KStars/Ekos/Scheduler
Here’s the result:
property read QStringList org.kde.kstars.Ekos.Scheduler.logText
property readwrite QString org.kde.kstars.Ekos.Scheduler.profile
property read int org.kde.kstars.Ekos.Scheduler.status
signal void org.kde.kstars.Ekos.Scheduler.newLog(QString text)
signal void org.kde.kstars.Ekos.Scheduler.newStatus({D-Bus type "(i)"} status)
method bool org.kde.kstars.Ekos.Scheduler.loadScheduler(QString fileURL)
method Q_NOREPLY void org.kde.kstars.Ekos.Scheduler.removeAllJobs()
method Q_NOREPLY void org.kde.kstars.Ekos.Scheduler.resetAllJobs()
method Q_NOREPLY void org.kde.kstars.Ekos.Scheduler.setSequence(QString sequenceFileURL)
method Q_NOREPLY void org.kde.kstars.Ekos.Scheduler.start()
method Q_NOREPLY void org.kde.kstars.Ekos.Scheduler.stop()
signal void org.freedesktop.DBus.Properties.PropertiesChanged(QString interface_name, QVariantMap changed_properties, QStringList invalidated_properties)
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()
So now we have the tools we need to check if Ekos is running, load a Scheduler, and Start and Stop it. In the next article we’ll start to code this stuff in Python.
https://kstars.kde.org/
https://www.indigo-astronomy.org/
pip3 install pyindi-client