Skip to content

Commit

Permalink
Allow targets without coordinates & use them in targets.sql (#68)
Browse files Browse the repository at this point in the history
* rts2-newtarget: Create targets with no coordinates

Sometimes we want to deal with scripts that will move the telescope to a position we don't know beforehand, hence, it's useful to have RTS2 don't move the telescope when executing the target.

This commit allows us to create targets with null coordinates. This behaviour is not problematic for RTS2 since the ecpg code has indicator variables that will set the position to NAN (do nothing) if tar_ra or tar_dec is null.

Signed-off-by: Eduardo Alonso <eduardo.alonso@quasarsr.com>

* sql: targets: Don't use 0 for targets with undefined position

Some target types, such as DarkTarget, will prevent the telescope from moving no matter which coordinates the target specifies. For some other targets, such as target 3 (Focusing Frames) we don't want the telescope to move to 00:00:00 +00:00:00, although it does until the focusing script kicks in:

EXEC executing now target Focusing frames(#3) at RA DEC 00:00:00.000 +00:00:00.00
T0 moving from (...) to 00:00:00.000 +000:00:00.00 (altaz +026:24:16.86 +176:14:00.00)
T0 moving from (..) to 23:55:29.804 +063:31:42.24 (altaz +089:00:00.00 +090:00:00.00)

Moreover, I find this behaviour a bit inconsistent, since DarkTarget sets the position to NAN but ConstTarget and CalibrationTarget set it to 0 (which is a valid position in the sky).

In the focusing example I highlighted earlier, it's a OportunityTarget, so it simply moves until the script instructs to move to another position.

Instead of having target 3 as a CalibrationTarget, I propose setting the position of these objects to null, instead of zero.

Signed-off-by: Eduardo Alonso <eduardo.alonso@quasarsr.com>

---------

Signed-off-by: Eduardo Alonso <eduardo.alonso@quasarsr.com>
  • Loading branch information
XePeleato authored Oct 7, 2023
1 parent 882a2e2 commit f1c9f66
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
7 changes: 7 additions & 0 deletions include/rts2db/targetres.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@
*/
rts2db::Target *createTargetByString (std::string tar_string, bool debug);

/**
* Return new target object, with null position.
*
* @return new target object. Caller must deallocate target object (delete it).
*/
rts2db::Target *createEmptyTarget ();

#endif // __RTS2_TARGETRES__
10 changes: 10 additions & 0 deletions lib/rts2db/targetres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,13 @@ Target *createTargetByString (std::string tar_string, bool debug)
return rtar;
}
}

Target *createEmptyTarget()
{
ConstTarget *constTarget = new ConstTarget ();

constTarget->setTargetName("RTS2_EMPTY");
constTarget->setPosition(NAN, NAN);
constTarget->setTargetType (TYPE_OPORTUNITY);
return constTarget;
}
9 changes: 9 additions & 0 deletions man/rts2-newtarget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<arg choice="opt"><option>-m</option></arg>
<arg choice="opt"><option>-r</option> <replaceable class="parameter">radius</replaceable></arg>
<arg choice="opt"><option>-f</option></arg>
<arg choice="opt"><option>-n</option></arg>
<arg choice="opt"><option>--pi</option> <replaceable class="parameter">PI name</replaceable></arg>
<arg choice="opt"><option>--program</option> <replaceable class="parameter">program name</replaceable></arg>
&dbapp;
Expand Down Expand Up @@ -158,6 +159,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-n</option></term>
<listitem>
<para>
No coordinates. Don't move the telescope.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--pi <replaceable class="parameter">PI name</replaceable></option></term>
<listitem>
Expand Down
15 changes: 15 additions & 0 deletions src/db/newtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "rts2db/appdb.h"
#include "rts2db/target.h"
#include "rts2db/targetres.h"
#include "rts2db/targetset.h"
#include "configuration.h"
#include "libnova_cpp.h"
Expand Down Expand Up @@ -51,6 +52,7 @@ class Rts2NewTarget:public Rts2TargetApp
int n_tar_id;
bool tryMatch;
bool forcedRun;
bool nullCoords;
const char *n_tar_name;
const char *n_tar_ra_dec;
double radius;
Expand All @@ -66,6 +68,7 @@ Rts2NewTarget::Rts2NewTarget (int in_argc, char **in_argv):Rts2TargetApp (in_arg
n_tar_id = -1;
tryMatch = false;
forcedRun = false;
nullCoords = false;
n_tar_name = NULL;
n_tar_ra_dec = NULL;

Expand All @@ -78,6 +81,7 @@ Rts2NewTarget::Rts2NewTarget (int in_argc, char **in_argv):Rts2TargetApp (in_arg
addOption ('m', NULL, 0, "try to match target name and RA DEC");
addOption ('r', NULL, 2, "radius for target checks");
addOption ('f', NULL, 0, "force run, don't ask questions about target overwrite");
addOption ('n', NULL, 0, "no coordinates, don't move the telescope");

addOption (OPT_PI_NAME, "pi", 1, "set PI name");
addOption (OPT_PROGRAM_NAME, "program", 1, "set program name");
Expand All @@ -102,6 +106,8 @@ void Rts2NewTarget::usage ()
<< " " << getAppName () << " 1003 NGC567 '20:10:11 +11:14:15'" << std::endl
<< "Same as above, but don't bug user with questions:" << std::endl
<< " " << getAppName () << " -f 1003 NGC567 '20:10:11 +11:14:15'" << std::endl
<< "To enter new target called Custom_Routine1, with ID 1003 that won't move the telescope:" << std::endl
<< " " << getAppName () << " -n 1003 Custom_Routine1" << std::endl
<< std::endl;
}

Expand All @@ -125,6 +131,9 @@ int Rts2NewTarget::processOption (int in_opt)
case 'f':
forcedRun = true;
break;
case 'n':
nullCoords = true;
break;
case OPT_PI_NAME:
n_pi = optarg;
break;
Expand Down Expand Up @@ -256,6 +265,12 @@ int Rts2NewTarget::doProcessing ()
if (!std::isnan (radius))
t_radius = radius;
int ret;

if (nullCoords) {
target = createEmptyTarget();
ret = 0;
}
else
// ask for target name..
if (n_tar_ra_dec == NULL)
{
Expand Down
16 changes: 8 additions & 8 deletions src/sql/data/targets.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-- standart targets (tar_id < 100)

COPY targets (tar_id, type_id, tar_name, tar_ra, tar_dec, tar_comment, tar_enabled, tar_priority, tar_bonus, tar_bonus_time) FROM stdin;
1 d Dark frames 0 0 Used to produce darks t 0 0 \N
2 f Flat frames 0 0 Used to produce flatfields t 0 0 \N
3 o Focusing frames 0 0 Used to focusc cameras t 0 0 \N
4 m Default model 0 0 Used to model get enought pictures for mount model t 0 0 \N
6 c Master calibration target 0 0 Used to calibration frames t 0 0 \N
7 p Master plan 0 0 Observe by plan t 1 0 \N
10 W Swift FOV 0 0 Swift Field of View, based on GCN t 0 0 \N
11 I Integral FOV 0 0 Integral Field of View, based on GCN t 0 0 \N
1 d Dark frames \N \N Used to produce darks t 0 0 \N
2 f Flat frames \N \N Used to produce flatfields t 0 0 \N
3 c Focusing frames \N \N Used to focusc cameras t 0 0 \N
4 m Default model \N \N Used to model get enought pictures for mount model t 0 0 \N
6 c Master calibration target \N \N Used to calibration frames t 0 0 \N
7 p Master plan \N \N Observe by plan t 1 0 \N
10 W Swift FOV \N \N Swift Field of View, based on GCN t 0 0 \N
11 I Integral FOV \N \N Integral Field of View, based on GCN t 0 0 \N
\.

COPY target_model (tar_id, alt_start, alt_stop, alt_step, az_start, az_stop, az_step, noise, step) FROM stdin;
Expand Down

0 comments on commit f1c9f66

Please sign in to comment.