/usr/include/libindi/indidome.h is in libindi-dev 1.7.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | /*******************************************************************************
INDI Dome Base Class
Copyright(c) 2014 Jasem Mutlaq. All rights reserved.
The code used calculate dome target AZ and ZD is written by Ferran Casarramona, and adapted from code from Markus Wildi.
The transformations are based on the paper Matrix Method for Coodinates Transformation written by Toshimi Taki (http://www.asahi-net.or.jp/~zs3t-tk).
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*******************************************************************************/
#pragma once
#include "defaultdevice.h"
#include <libnova/ln_types.h>
#include <string>
// Defines a point in a 3 dimension space
typedef struct
{
double x, y, z;
} point3D;
namespace Connection
{
class Serial;
class TCP;
}
/**
* \class INDI::Dome
\brief Class to provide general functionality of a Dome device.
Both relative and absolute position domes are supported. Furthermore, if no position feedback is available from the dome, an open-loop control is possible with simple direction commands (Clockwise and counter clockwise).
Before using any of the dome functions, you must define the capabilities of the dome by calling SetDomeCapability() function. All positions are represented as degrees of azimuth.
Relative motion is specified in degrees as either positive (clock wise direction), or negative (counter clock-wise direction).
Slaving is used to synchronizes the dome's azimuth position with that of the mount. The mount's coordinates are snooped from the active mount that has its name specified in ACTIVE_TELESCOPE property in the ACTIVE_DEVICES vector.
Dome motion begins when it receives TARGET_EOD_COORD property from the mount driver when the mount starts slewing to the desired target coordinates /em OR
when the mount's current tracking position exceeds the AutoSync threshold. Therefore, slaving is performed while slewing and tracking. The user is required to fill in all required parameters before slaving can be used.
The AutoSync threshold is the difference in degrees between the dome's azimuth angle and the mount's azimuth angle that should trigger a dome motion.
By default, it is set to 0.5 degrees which would trigger dome motion due to any difference between the dome and mount azimuth angles that exceeds 0.5 degrees.
For example, if the threshold is set to 5 degrees, the dome will only start moving to sync with the mount's azimuth angle once the difference in azimuth angles is equal or exceeds 5 degrees.
Custom parking position is available for absolute/relative position domes.
For roll-off observatories, parking state reflects whether the roof is closed or open.
Developers need to subclass INDI::Dome to implement any driver for Domes within INDI.
\note The code used calculate dome target AZ and ZD is written by Ferran Casarramona, and adapted from code from Markus Wildi. The transformations are based on the paper Matrix Method for Coodinates
Transformation written by Toshimi Taki (http://www.asahi-net.or.jp/~zs3t-tk).
\author Jasem Mutlaq
*/
namespace INDI
{
class Dome : public DefaultDevice
{
public:
/** \typedef DomeMeasurements
\brief Measurements necessary for dome-slit synchronization. All values are in meters. The displacements are measured from the true dome centre, and the dome is assumed spherical.
\note: The mount centre is the point where RA and Dec. axis crosses, no matter the kind of mount. For example, for a fork mount this displacement is typically 0 if it's perfectly centred with RA axis.
*/
typedef enum {
DM_DOME_RADIUS, /*!< Dome RADIUS */
DM_SHUTTER_WIDTH, /*!< Shutter width */
DM_NORTH_DISPLACEMENT, /*!< Displacement to north of the mount center */
DM_EAST_DISPLACEMENT, /*!< Displacement to east of the mount center */
DM_UP_DISPLACEMENT, /*!< Up Displacement of the mount center */
DM_OTA_OFFSET /*!< Distance from the optical axis to the mount center*/
} DomeMeasurements;
enum DomeDirection
{
DOME_CW,
DOME_CCW
};
enum DomeMotionCommand
{
MOTION_START,
MOTION_STOP
};
/*! Dome Parking data type enum */
enum DomeParkData
{
PARK_NONE, /*!< Open loop Parking */
PARK_AZ, /*!< Parking via azimuth angle control */
PARK_AZ_ENCODER, /*!< Parking via azimuth encoder control */
};
/** \typedef ShutterOperation
\brief Shutter operation command.
*/
typedef enum {
SHUTTER_OPEN, /*!< Open Shutter */
SHUTTER_CLOSE /*!< Close Shutter */
} ShutterOperation;
/** \typedef DomeState
\brief Dome status
*/
typedef enum {
DOME_IDLE, /*!< Dome is idle */
DOME_MOVING, /*!< Dome is in motion */
DOME_SYNCED, /*!< Dome is synced */
DOME_PARKING, /*!< Dome is parking */
DOME_UNPARKING, /*!< Dome is unparking */
DOME_PARKED, /*!< Dome is parked */
DOME_UNPARKED, /*!< Dome is unparked */
} DomeState;
/** \typedef ShutterStatus
\brief Shutter Status
*/
typedef enum {
SHUTTER_OPENED, /*!< Shutter is open */
SHUTTER_CLOSED, /*!< Shutter is closed */
SHUTTER_MOVING, /*!< Shutter is in motion */
SHUTTER_UNKNOWN /*!< Shutter status is unknown */
} ShutterStatus;
enum
{
DOME_CAN_ABORT = 1 << 0, /*!< Can the dome motion be aborted? */
DOME_CAN_ABS_MOVE = 1 << 1, /*!< Can the dome move to an absolute azimuth position? */
DOME_CAN_REL_MOVE =
1
<< 2, /*!< Can the dome move to a relative position a number of degrees away from current position? Positive degress is Clockwise direction. Negative Degrees is counter clock wise direction */
DOME_CAN_PARK = 1 << 3, /*!< Can the dome park and unpark itself? */
DOME_HAS_SHUTTER = 1 << 4, /*!< Does the dome has a shutter than can be opened and closed electronically? */
DOME_HAS_VARIABLE_SPEED = 1 << 5 /*!< Can the dome move in different configurable speeds? */
};
/** \struct DomeConnection
\brief Holds the connection mode of the Dome.
*/
enum
{
CONNECTION_NONE = 1 << 0, /** Do not use any connection plugin */
CONNECTION_SERIAL = 1 << 1, /** For regular serial and bluetooth connections */
CONNECTION_TCP = 1 << 2 /** For Wired and WiFI connections */
} DomeConnection;
Dome();
virtual ~Dome();
virtual bool initProperties();
virtual void ISGetProperties(const char *dev);
virtual bool updateProperties();
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n);
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n);
virtual bool ISSnoopDevice(XMLEle *root);
static void buttonHelper(const char *button_n, ISState state, void *context);
/**
* @brief setDomeConnection Set Dome connection mode. Child class should call this in the constructor before Dome registers
* any connection interfaces
* @param value ORed combination of DomeConnection values.
*/
void setDomeConnection(const uint8_t &value);
/**
* @return Get current Dome connection mode
*/
uint8_t getDomeConnection() const;
/**
* @brief GetDomeCapability returns the capability of the dome
*/
uint32_t GetDomeCapability() const { return capability; }
/**
* @brief SetDomeCapability set the dome capabilities. All capabilities must be initialized.
* @param cap pointer to dome capability
*/
void SetDomeCapability(uint32_t cap);
/**
* @return True if dome support aborting motion
*/
bool CanAbort() { return capability & DOME_CAN_ABORT; }
/**
* @return True if dome has absolute postion encoders.
*/
bool CanAbsMove() { return capability & DOME_CAN_ABS_MOVE; }
/**
* @return True if dome has relative position encoders.
*/
bool CanRelMove() { return capability & DOME_CAN_REL_MOVE; }
/**
* @return True if dome can park.
*/
bool CanPark() { return capability & DOME_CAN_PARK; }
/**
* @return True if dome has controllable shutter door
*/
bool HasShutter() { return capability & DOME_HAS_SHUTTER; }
/**
* @return True if dome support multiple speeds
*/
bool HasVariableSpeed() { return capability & DOME_HAS_VARIABLE_SPEED; }
/**
* @brief isLocked, is the dome currently locked?
* @return True if lock status equals true, and TelescopeClosedLockTP is Telescope Locks.
*/
bool isLocked();
DomeState getDomeState() const;
void setDomeState(const DomeState &value);
IPState getWeatherState() const;
IPState getMountState() const;
protected:
/**
* @brief SetSpeed Set Dome speed. This does not initiate motion, it sets the speed for the next motion command. If motion is in progress, then change speed accordingly.
* @param rpm Dome speed (RPM)
* @return true if successful, false otherwise
*/
virtual bool SetSpeed(double rpm);
/** \brief Move the Dome in a particular direction.
\param dir Direction of Dome, either DOME_CW or DOME_CCW.
\return Return IPS_OK if dome operation is complete. IPS_BUSY if operation is in progress. IPS_ALERT on error.
*/
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation);
/** \brief Move the Dome to an absolute azimuth.
\param az The new position of the Dome.
\return Return IPS_OK if motion is completed and Dome reached requested position. Return IPS_BUSY if Dome started motion to requested position and is in progress.
Return IPS_ALERT if there is an error.
*/
virtual IPState MoveAbs(double az);
/** \brief Move the Dome to an relative position.
\param azDiff The relative azimuth angle to move. Positive degree is clock-wise direction. Negative degrees is counter clock-wise direction.
\return Return IPS_OK if motion is completed and Dome reached requested position. Return IPS_BUSY if Dome started motion to requested position and is in progress.
Return IPS_ALERT if there is an error.
*/
virtual IPState MoveRel(double azDiff);
/**
* \brief Abort all dome motion
* \return True if abort is successful, false otherwise.
*/
virtual bool Abort();
/**
* \brief Goto Park Position. The park position is an absolute azimuth value.
* \return Return IPS_OK if motion is completed and Dome reached park position. Return IPS_BUSY if Dome started motion to park requested position and is in progress.
Return -IPS_ALERT if there is an error.
*/
virtual IPState Park();
/**
* \brief UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutter and moving to home position. When UnPark() is successful
* The observatory should be in a ready state to utilize the mount to perform observations.
* \return Return IPS_OK if motion is completed and Dome is unparked. Return IPS_BUSY if Dome unparking is in progress.
Return -IPS_ALERT if there is an error.
*/
virtual IPState UnPark();
/**
* \brief Open or Close shutter
* \param operation Either open or close the shutter.
* \return Return IPS_OK if shutter operation is complete. Return IPS_BUSY if shutter operation is in progress.
Return IPS_ALERT if there is an error.
*/
virtual IPState ControlShutter(ShutterOperation operation);
/**
* @brief getShutterStatusString
* @param status Status of shutter
* @return Returns string representation of the shutter status
*/
const char *GetShutterStatusString(ShutterStatus status);
/**
* \brief setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
* \param type parking data type. If PARK_NONE then no properties will be presented to the user for custom parking position.
*/
void SetParkDataType(DomeParkData type);
/**
* @brief InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status
* and parking position. InitPark() should be called after successful connection to the dome on startup.
* @return True if loading is successful and data is read, false otherwise. On success, you must call
* SetAzParkDefault() to set the default parking values. On failure, you must call
* SetAzParkDefault() to set the default parking values in addition to SetAzPark()
* to set the current parking position.
*/
bool InitPark();
/**
* @brief isParked is dome currently parked?
* @return True if parked, false otherwise.
*/
bool isParked();
/**
* @brief SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData.xml) is updated in the process.
* @param isparked set to true if parked, false otherwise.
*/
void SetParked(bool isparked);
/**
* @return Get current AZ parking position.
*/
double GetAxis1Park();
/**
* @return Get default AZ parking position.
*/
double GetAxis1ParkDefault();
/**
* @brief SetRAPark Set current AZ parking position. The data park file (stored in ~/.indi/ParkData.xml) is updated in the process.
* @param value current Axis 1 value (AZ either in angles or encoder values as specificed by the DomeParkData type).
*/
void SetAxis1Park(double value);
/**
* @brief SetAxis1Park Set default AZ parking position.
* @param value Default Axis 1 value (AZ either in angles or encoder values as specificed by the DomeParkData type).
*/
void SetAxis1ParkDefault(double steps);
/**
* @brief SetCurrentPark Set current coordinates/encoders value as the desired parking position
* \note This function performs no action unless subclassed by the child class if required.
*/
virtual bool SetCurrentPark();
/**
* @brief SetDefaultPark Set default coordinates/encoders value as the desired parking position
* \note This function performs no action unless subclassed by the child class if required.
*/
virtual bool SetDefaultPark();
//Park
char *LoadParkData();
bool WriteParkData();
/**
* @brief GetTargetAz
* @param Az Returns Azimuth required to the dome in order to center the shutter aperture with telescope
* @param Alt
* @param minAz Returns Minimum azimuth in order to avoid any dome interference to the full aperture of the telescope
* @param maxAz Returns Maximum azimuth in order to avoid any dome interference to the full aperture of the telescope
* @return Returns false if it can't solve it due bad geometry of the observatory
*/
bool GetTargetAz(double &Az, double &Alt, double &minAz, double &maxAz);
/**
* @brief Intersection Calculate the intersection of a ray and a sphere. The line segment is defined from p1 to p2. The sphere is of radius r and centered at (0,0,0).
* From http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/
* There are potentially two points of intersection given by
* p := p1 + mu1 (p2 - p1)
* p := p1 + mu2 (p2 - p1)
* @param p1 First point
* @param p2 Direction of the ray
* @param r RADIUS of sphere
* @param mu1 First point of potentional intersection.
* @param mu2 Second point of potentional intersection.
* @return Returns FALSE if the ray doesn't intersect the sphere.
*/
bool Intersection(point3D p1, point3D p2, double r, double &mu1, double &mu2);
/**
* @brief OpticalCenter This function calculates the distance from the optical axis to the Dome center
* @param MountCenter Distance from the Dome center to the point where mount axis crosses
* @param dOpticalAxis Distance from the mount center to the optical axis.
* @param Lat Latitude
* @param Ah Hour Angle (in hours)
* @param OP a 3D point from the optical center to the Dome center.
* @return false in case of error.
*/
bool OpticalCenter(point3D MountCenter, double dOpticalAxis, double Lat, double Ah, point3D &OP);
/**
* @brief OpticalVector This function calculates a second point for determining the optical axis
* @param Az Azimuth
* @param Alt Altitude
* @param OV a 3D point that determines the optical line.
* @return false in case of error.
*/
bool OpticalVector(double Az, double Alt, point3D &OV);
/**
* @brief CheckHorizon Returns true if telescope points above horizon.
* @param HA Hour angle
* @param dec Declination
* @param lat observer's latitude
* @return True if telescope points above horizon, false otherwise.
*/
bool CheckHorizon(double HA, double dec, double lat);
/**
* @brief saveConfigItems Saves the Device Port and Dome Presets in the configuration file
* @param fp pointer to configuration file
* @return true if successful, false otherwise.
*/
virtual bool saveConfigItems(FILE *fp);
/**
* @brief updateCoords updates the horizontal coordinates (Az & Alt) of the mount from the snooped RA, DEC and observer's location.
*/
void UpdateMountCoords();
/**
* @brief UpdateAutoSync This function calculates the target dome azimuth from the mount's target coordinates given the dome parameters.
* If the difference between the dome's and mount's azimuth angles exceeds the AutoSync threshold, the dome will be commanded to sync to the mount azimuth position.
*/
virtual void UpdateAutoSync();
/** \brief perform handshake with device to check communication */
virtual bool Handshake();
double Csc(double x);
double Sec(double x);
INumberVectorProperty DomeSpeedNP;
INumber DomeSpeedN[1];
ISwitchVectorProperty DomeMotionSP;
ISwitch DomeMotionS[2];
INumberVectorProperty DomeAbsPosNP;
INumber DomeAbsPosN[1];
INumberVectorProperty DomeRelPosNP;
INumber DomeRelPosN[1];
ISwitchVectorProperty AbortSP;
ISwitch AbortS[1];
INumberVectorProperty DomeParamNP;
INumber DomeParamN[1];
ISwitchVectorProperty DomeShutterSP;
ISwitch DomeShutterS[2];
ISwitchVectorProperty ParkSP;
ISwitch ParkS[2];
INumber ParkPositionN[1];
INumberVectorProperty ParkPositionNP;
ISwitch ParkOptionS[3];
ISwitchVectorProperty ParkOptionSP;
ISwitch AutoParkS[2];
ISwitchVectorProperty AutoParkSP;
uint32_t capability;
ShutterStatus shutterState;
DomeParkData parkDataType;
ITextVectorProperty ActiveDeviceTP;
IText ActiveDeviceT[2] {};
// Switch to lock id mount is unparked
ISwitchVectorProperty TelescopeClosedLockTP;
ISwitch TelescopeClosedLockT[2];
INumber PresetN[3];
INumberVectorProperty PresetNP;
ISwitch PresetGotoS[3];
ISwitchVectorProperty PresetGotoSP;
INumber DomeMeasurementsN[6];
INumberVectorProperty DomeMeasurementsNP;
ISwitchVectorProperty OTASideSP;
ISwitch OTASideS[2];
ISwitchVectorProperty DomeAutoSyncSP;
ISwitch DomeAutoSyncS[2];
double prev_az, prev_alt, prev_ra, prev_dec;
// For Serial and TCP connections
int PortFD = -1;
Connection::Serial *serialConnection = NULL;
Connection::TCP *tcpConnection = NULL;
// States
DomeState domeState;
IPState mountState;
IPState weatherState;
// Observer geographic coords. Snooped from mount driver.
struct ln_lnlat_posn observer;
// Do we have valid geographic coords from mount driver?
bool HaveLatLong = false;
// Mount horizontal and equatorial coords. Snoops from mount driver.
struct ln_hrz_posn mountHoriztonalCoords;
struct ln_equ_posn mountEquatorialCoords;
// Do we have valid coords from mount driver?
bool HaveRaDec = false;
private:
void processButton(const char *button_n, ISState state);
void triggerSnoop(const char *driverName, const char *propertyName);
Controller *controller = nullptr;
bool IsParked = false;
bool IsMountParked = false;
bool IsLocked = true;
const char *ParkDeviceName;
const char *Parkdatafile;
XMLEle *ParkdataXmlRoot, *ParkdeviceXml, *ParkstatusXml, *ParkpositionXml, *ParkpositionAxis1Xml;
double Axis1ParkPosition;
double Axis1DefaultParkPosition;
bool callHandshake();
uint8_t domeConnection = CONNECTION_SERIAL | CONNECTION_TCP;
};
}
|