Skip to content

Commit

Permalink
merged dev into dev-sim
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredmales committed Oct 29, 2024
2 parents c4649e5 + 8f39396 commit 56918fe
Show file tree
Hide file tree
Showing 25 changed files with 4,777 additions and 3,752 deletions.
23 changes: 21 additions & 2 deletions apps/alignLoop/alignLoop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class alignLoop : public MagAOXApp<true>, public dev::shmimMonitor<alignLoop>
mx::improc::eigenImage<float> m_intMat;

mx::improc::eigenImage<float> m_measurements;
float m_delta0 {0};
float m_delta1 {0};

mx::improc::eigenImage<float> m_commands;

float m_ggain {0};
Expand Down Expand Up @@ -130,6 +133,8 @@ class alignLoop : public MagAOXApp<true>, public dev::shmimMonitor<alignLoop>

//INDI

pcf::IndiProperty m_indiP_deltas;

pcf::IndiProperty m_indiP_ggain;
pcf::IndiProperty m_indiP_ctrlEnabled;

Expand Down Expand Up @@ -229,6 +234,12 @@ int alignLoop::appStartup()
}
}

CREATE_REG_INDI_RO_NUMBER( m_indiP_deltas, "deltas", "Deltas", "Deltas");
m_indiP_deltas.add(pcf::IndiElement("delta0"));
m_indiP_deltas["delta0"] = 0;
m_indiP_deltas.add(pcf::IndiElement("delta1"));
m_indiP_deltas["delta1"] = 0;

m_gains.resize(m_defaultGains.size());
for(size_t n=0; n < m_defaultGains.size(); ++n) m_gains[n] = m_defaultGains[n];

Expand Down Expand Up @@ -367,6 +378,8 @@ int alignLoop::processImage( void* curr_src,
}


m_delta0 = m_measurements(0,0);
m_delta1 = m_measurements(1,0);

std::cout << "measurements: ";
for(int cc = 0; cc < m_measurements.rows(); ++cc)
Expand All @@ -379,6 +392,8 @@ int alignLoop::processImage( void* curr_src,

m_commands.matrix() = m_intMat.matrix() * m_measurements.matrix();



std::cout << "delta commands: ";
for(int cc = 0; cc < m_measurements.rows(); ++cc)
{
Expand All @@ -398,14 +413,18 @@ int alignLoop::processImage( void* curr_src,
std::cout << "\n";

//And send commands.
int rv;
if(m_ctrlEnabled)
{
return sendCommands(commands);
rv = sendCommands(commands);
}
else
{
return 0;
rv = 0;
}

updateIfChanged(m_indiP_deltas, std::vector<std::string>({"delta0", "delta1"}), std::vector<float>({m_delta0, m_delta1}));
return rv;
}

inline
Expand Down
22 changes: 20 additions & 2 deletions apps/closedLoopIndi/closedLoopIndi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class closedLoopIndi : public MagAOXApp<true>

int64_t m_counter = -1; ///< The latest value of the loop counter
mx::improc::eigenImage<float> m_measurements; ///< The latest value of the measurements
float m_delta0 {0};
float m_delta1 {0};

mx::improc::eigenImage<float> m_commands; ///< The latest commands

float m_ggain {0}; ///< The global gain
Expand Down Expand Up @@ -126,6 +129,8 @@ class closedLoopIndi : public MagAOXApp<true>

//INDI

pcf::IndiProperty m_indiP_deltas;

pcf::IndiProperty m_indiP_reference0;
INDI_NEWCALLBACK_DECL(closedLoopIndi, m_indiP_reference0);

Expand Down Expand Up @@ -301,6 +306,12 @@ int closedLoopIndi::appStartup()
{
REG_INDI_SETPROP(m_indiP_inputs, m_inputDevice, m_inputProperty);

CREATE_REG_INDI_RO_NUMBER( m_indiP_deltas, "deltas", "Deltas", "Deltas");
m_indiP_deltas.add(pcf::IndiElement("delta0"));
m_indiP_deltas["delta0"] = 0;
m_indiP_deltas.add(pcf::IndiElement("delta1"));
m_indiP_deltas["delta1"] = 0;

CREATE_REG_INDI_NEW_NUMBERF( m_indiP_reference0, "reference0", -1e15, 1e15, 1, "%g", "reference0", "references");
m_indiP_reference0["current"] = m_references(0,0);
m_indiP_reference0["target"] = m_references(0,0);
Expand Down Expand Up @@ -436,6 +447,9 @@ int closedLoopIndi::updateLoop()
return 0;
}

m_delta0 = m_measurements(0,0) - m_references(0,0);
m_delta1 = m_measurements(1,0) - m_references(1,0);

m_commands.matrix() = m_intMat.matrix() * (m_measurements - m_references).matrix();

std::vector<float> commands;
Expand All @@ -447,14 +461,18 @@ int closedLoopIndi::updateLoop()
}

//And send commands.
int rv;
if(m_loopClosed)
{
return sendCommands(commands);
rv = sendCommands(commands);
}
else
{
return 0;
rv = 0;
}

updateIfChanged(m_indiP_deltas, std::vector<std::string>({"delta0", "delta1"}), std::vector<float>({m_delta0, m_delta1}));
return rv;
}

inline
Expand Down
Loading

0 comments on commit 56918fe

Please sign in to comment.