Skip to content

Commit

Permalink
Merge pull request #148 from missirol/master
Browse files Browse the repository at this point in the history
[devices] [common] [assembly] updates to automatically find device files for ConradModel and LStepExpressModel
  • Loading branch information
Negusbuk authored Jun 14, 2019
2 parents 270f0a3 + f664ee1 commit 62abf6f
Show file tree
Hide file tree
Showing 33 changed files with 408 additions and 355 deletions.
40 changes: 24 additions & 16 deletions assembly/assembly.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ SensorMarkerLinesHoughThreshold 110
SensorMarkerLinesHoughMinLineLength 100.0
SensorMarkerLinesHoughMaxLineGap 20.0

## Keyence (currently not used by main assembly interface)
KeyenceDevice /dev/ttyUSB0

###########################################################################

LogLevel_stdout 1
LogLevel_logfile 1

LStepExpressDevice /dev/ttyUSB1 # LANG Motion Stage
KeyenceDevice /dev/ttyUSB0 # Vacuum System
## LANG Motion Stage
LStepExpressDevice /dev/ttyUSB* # port path (accepts wildcard "*" in file basename)
LStepExpressDevice_ver "PE43 1.00.01" # LANG Version
LStepExpressDevice_iver E2018.02.27-2002 # LANG Internal Version

## Conrad
ConradDevice /dev/ttyUSB* # port path (accepts wildcard "*" in file basename)

# Vacuum
Vacuum_PickupTool 1
Expand Down Expand Up @@ -66,29 +74,29 @@ AssemblyObjectAlignerView_angle_max_dontIter 0.50 # maximum angular differenc
AssemblyObjectAlignerView_angle_max_complete 0.01 # maximum angular difference (required-measured) allowed to declare alignment procedure completed

# AssemblyObjectFinderPatRecView
AssemblyObjectFinderPatRecView_template_fpath share/assembly/markedglass_marker1_drawing_588x588_BL.png
AssemblyObjectFinderPatRecView_threshold 30
AssemblyObjectFinderPatRecView_adaptiveThreshold 587
AssemblyObjectFinderPatRecView_angles_prescan 0
AssemblyObjectFinderPatRecView_angles_finemax 2
AssemblyObjectFinderPatRecView_angles_finestep 0.15
AssemblyObjectFinderPatRecView_template_fpath share/assembly/markedglass_marker1_drawing_588x588_BL.png
AssemblyObjectFinderPatRecView_threshold 30
AssemblyObjectFinderPatRecView_adaptiveThreshold 587
AssemblyObjectFinderPatRecView_angles_prescan 0
AssemblyObjectFinderPatRecView_angles_finemax 2
AssemblyObjectFinderPatRecView_angles_finestep 0.15

# AssemblyObjectAligner

# AssemblyObjectAlignerView
AssemblyObjectAlignerView_PatRec1_template_fpath share/assembly/markedglass_marker1_drawing_588x588_BL.png
AssemblyObjectAlignerView_PatRec1_template_fpath share/assembly/markedglass_marker1_drawing_588x588_BL.png
AssemblyObjectAlignerView_PatRec1_threshold 30
AssemblyObjectAlignerView_PatRec1_adaptiveThreshold 587
AssemblyObjectAlignerView_PatRec1_angles_prescan 0
AssemblyObjectAlignerView_PatRec1_angles_finemax 2
AssemblyObjectAlignerView_PatRec1_angles_finestep 0.15
AssemblyObjectAlignerView_PatRec1_angles_prescan 0
AssemblyObjectAlignerView_PatRec1_angles_finemax 2
AssemblyObjectAlignerView_PatRec1_angles_finestep 0.15

AssemblyObjectAlignerView_PatRec2_template_fpath share/assembly/markedglass_marker1_drawing_588x588_TL.png
AssemblyObjectAlignerView_PatRec2_template_fpath share/assembly/markedglass_marker1_drawing_588x588_TL.png
AssemblyObjectAlignerView_PatRec2_threshold 30
AssemblyObjectAlignerView_PatRec2_adaptiveThreshold 587
AssemblyObjectAlignerView_PatRec2_angles_prescan 0
AssemblyObjectAlignerView_PatRec2_angles_finemax 2
AssemblyObjectAlignerView_PatRec2_angles_finestep 0.15
AssemblyObjectAlignerView_PatRec2_angles_prescan 0
AssemblyObjectAlignerView_PatRec2_angles_finemax 2
AssemblyObjectAlignerView_PatRec2_angles_finestep 0.15

# AssemblySmartMotionManager
AssemblySmartMotionManager_steps_dZ 0.5,0.5,0.2,0.2,0.2,0.2,0.1,0.1
Expand Down
11 changes: 9 additions & 2 deletions assembly/assembly/AssemblyMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
/// -------------------

/// Motion
motion_model_ = new LStepExpressModel(config->getValue<std::string>("LStepExpressDevice").c_str(), 1000, 1000);
motion_model_ = new LStepExpressModel(
config->getValue<std::string>("LStepExpressDevice"),
config->getValue<std::string>("LStepExpressDevice_ver"),
config->getValue<std::string>("LStepExpressDevice_iver"),
1000,
1000
);

motion_manager_ = new LStepExpressMotionManager(motion_model_);

motion_thread_ = new LStepExpressMotionThread(motion_manager_, this);
Expand All @@ -125,7 +132,7 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
/// -------------------

/// Vacuum Manager
conradModel_ = new ConradModel;
conradModel_ = new ConradModel(config->getValue<std::string>("ConradDevice"));
conradManager_ = new ConradManager(conradModel_);
/// -------------------

Expand Down
12 changes: 6 additions & 6 deletions assembly/assembly/assembly_parameters_DAF_190513_balljoint.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ RefPointSensor_Z -2.763
RefPointSensor_A -0.307

# position: ref-point on assembly platform for calibration of baseplate position (spacer aligned along x-axis)
# values correspond to bottom-left reference-edge on assembly platform (commented values: top-right reference-edge)
PlatformRefPointCalibrationBaseplate_X -73.978 # 47.022
PlatformRefPointCalibrationBaseplate_Y -147.989 # -56.990
PlatformRefPointCalibrationBaseplate_Z -3.458 # -3.506
PlatformRefPointCalibrationBaseplate_A -0.146 # -0.146
# values correspond to bottom-left reference-edge on assembly platform
PlatformRefPointCalibrationBaseplate_X -73.978
PlatformRefPointCalibrationBaseplate_Y -147.989
PlatformRefPointCalibrationBaseplate_Z -3.458
PlatformRefPointCalibrationBaseplate_A -0.146

# position: ref-point on assembly platform for calibration of spacers position (spacer aligned along x-axis)
# values correspond to top-left reference-edge on assembly platform
Expand Down Expand Up @@ -88,4 +88,4 @@ FromPlatformRefPointCalibrationSpacersToSpacerEdge_dY -36.82

# distance: from ref-point on assembly platform (for baseplate calibration) to baseplate's edge
FromPlatformRefPointCalibrationBaseplateToPSPEdge_dX 11.13
FromPlatformRefPointCalibrationBaseplateToPSPEdge_dY -70.08 # -(20.92+49.16) 49.16=PSp_shortSide_length
FromPlatformRefPointCalibrationBaseplateToPSPEdge_dY 70.08
26 changes: 13 additions & 13 deletions assembly/assemblyCommon/AssemblyAssemblyView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,40 +209,40 @@ AssemblyAssemblyView::AssemblyAssemblyView(const AssemblyAssembly* const assembl
QVBoxLayout* PSSToSpacers_lay = new QVBoxLayout;
wid_PSSToSpacers_->setLayout(PSSToSpacers_lay);

// step: Dispense Glue on Spacers
// step: Go To XYA Position To Glue PS-s to Spacers
{
++assembly_step_N_;

AssemblyAssemblyTextWidget* tmp_wid = new AssemblyAssemblyTextWidget;
tmp_wid->label()->setText(QString::number(assembly_step_N_));
tmp_wid->text() ->setText("Dispense Glue on Spacers and Place them on Assembly Platform");
AssemblyAssemblyActionWidget* tmp_wid = new AssemblyAssemblyActionWidget;
tmp_wid->label() ->setText(QString::number(assembly_step_N_));
tmp_wid->button()->setText("Go To XYA Position To Glue PS-s to Spacers");
PSSToSpacers_lay->addWidget(tmp_wid);

tmp_wid->connect_action(assembly, SLOT(GoToXYAPositionToGluePSSToSpacers_start()), SIGNAL(GoToXYAPositionToGluePSSToSpacers_finished()));
}
// ----------

// step: Enable Vacuum on Spacers
// step: Dispense Glue on Spacers and Place them on Assembly Platform
{
++assembly_step_N_;

AssemblyAssemblyActionWidget* tmp_wid = new AssemblyAssemblyActionWidget;
tmp_wid->label() ->setText(QString::number(assembly_step_N_));
tmp_wid->button()->setText("Enable Vacuum on Spacers");
AssemblyAssemblyTextWidget* tmp_wid = new AssemblyAssemblyTextWidget;
tmp_wid->label()->setText(QString::number(assembly_step_N_));
tmp_wid->text() ->setText("Dispense Glue on Spacers and Place them on Assembly Platform");
PSSToSpacers_lay->addWidget(tmp_wid);

tmp_wid->connect_action(assembly, SLOT(EnableVacuumSpacers_start()), SIGNAL(EnableVacuumSpacers_finished()));
}
// ----------

// step: Go To XYA Position To Glue PS-s to Spacers
// step: Enable Vacuum on Spacers
{
++assembly_step_N_;

AssemblyAssemblyActionWidget* tmp_wid = new AssemblyAssemblyActionWidget;
tmp_wid->label() ->setText(QString::number(assembly_step_N_));
tmp_wid->button()->setText("Go To XYA Position To Glue PS-s to Spacers");
tmp_wid->button()->setText("Enable Vacuum on Spacers");
PSSToSpacers_lay->addWidget(tmp_wid);

tmp_wid->connect_action(assembly, SLOT(GoToXYAPositionToGluePSSToSpacers_start()), SIGNAL(GoToXYAPositionToGluePSSToSpacers_finished()));
tmp_wid->connect_action(assembly, SLOT(EnableVacuumSpacers_start()), SIGNAL(EnableVacuumSpacers_finished()));
}
// ----------

Expand Down
30 changes: 0 additions & 30 deletions assembly/assemblyCommon/AssemblyParametersView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,36 +200,6 @@ AssemblyParametersView::AssemblyParametersView(QWidget* parent)
posi_lay->addWidget(new QLabel(tr("A")) , row_index, 7, Qt::AlignRight);
posi_lay->addWidget(this->get(tmp_tag+"_A"), row_index, 8, Qt::AlignRight);

//!! // position: Z-position (height) to put pickup tool in contact with rotation stage
//!! ++row_index;
//!!
//!! tmp_tag = "PickupToolOnRotStage";
//!! tmp_des = "Pickup Tool on Rotation Stage :";
//!!
//!! map_lineEdit_[tmp_tag+"_Z"] = new QLineEdit(tr(""));
//!!
//!! posi_lay->addWidget(new QLabel(tmp_des) , row_index, 0, Qt::AlignLeft);
//!! posi_lay->addWidget(new QLabel(tr("Z")) , row_index, 5, Qt::AlignRight);
//!! posi_lay->addWidget(this->get(tmp_tag+"_Z"), row_index, 6, Qt::AlignRight);
//!!
//!! // position: XY pickup position on glue-dispensing platform + Z-position (height) to put pickup tool in contact with platform
//!! ++row_index;
//!!
//!! tmp_tag = "PickupToolOnGluingStage";
//!! tmp_des = "Pickup Tool on Gluing Stage :";
//!!
//!! map_lineEdit_[tmp_tag+"_X"] = new QLineEdit(tr(""));
//!! map_lineEdit_[tmp_tag+"_Y"] = new QLineEdit(tr(""));
//!! map_lineEdit_[tmp_tag+"_Z"] = new QLineEdit(tr(""));
//!!
//!! posi_lay->addWidget(new QLabel(tmp_des) , row_index, 0, Qt::AlignLeft);
//!! posi_lay->addWidget(new QLabel(tr("X")) , row_index, 1, Qt::AlignRight);
//!! posi_lay->addWidget(this->get(tmp_tag+"_X"), row_index, 2, Qt::AlignRight);
//!! posi_lay->addWidget(new QLabel(tr("Y")) , row_index, 3, Qt::AlignRight);
//!! posi_lay->addWidget(this->get(tmp_tag+"_Y"), row_index, 4, Qt::AlignRight);
//!! posi_lay->addWidget(new QLabel(tr("Z")) , row_index, 5, Qt::AlignRight);
//!! posi_lay->addWidget(this->get(tmp_tag+"_Z"), row_index, 6, Qt::AlignRight);

// position: z-position where camera is focused on Assembly Stage surface
++row_index;

Expand Down
66 changes: 37 additions & 29 deletions assembly/assemblyCommon/ConradManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
#include <ConradManager.h>
#include <nqlogger.h>

ConradManager::ConradManager(ConradModel* cnrd)
{
ConradModel_ = cnrd;
#include <cassert>

channelNumber = 0;
ConradManager::ConradManager(ConradModel* const cnrd)
: conradModel_(cnrd)
, channelNumber_(0)
{
conradModel();

liveTimer_ = new QTimer(this);
liveTimer_->setSingleShot(true);
Expand All @@ -27,33 +29,40 @@ ConradManager::ConradManager(ConradModel* cnrd)
NQLog("ConradManager", NQLog::Debug) << "constructed";
}

ConradModel* ConradManager::conradModel() const
{
assert(conradModel_);

return conradModel_;
}

/// toggleVacuum slot description
void ConradManager::toggleVacuum(const int chNumber)
{
if(ConradModel_->getSwitchState(chNumber) == 0)
if(conradModel()->getSwitchState(chNumber) == 0)
{
NQLog("ConradManager", NQLog::Debug) << "toggleVacuum(" << chNumber << ")"
<< ": emitting signal \"disableVacuumButton\"";

emit disableVacuumButton();

//NQLog("ConradManager") << ": attempt to turn ON the vacuum on channel " << chNumber;
ConradModel_->setSwitchEnabled(chNumber, true);
channelNumber = chNumber;
conradModel()->setSwitchEnabled(chNumber, true);
channelNumber_ = chNumber;

// here will be a QtTimer for about 2 secs
liveTimer_->start(togglingVacuumDelay);
}
else if(ConradModel_->getSwitchState(chNumber) == 1)
else if(conradModel()->getSwitchState(chNumber) == 1)
{
NQLog("ConradManager", NQLog::Debug) << "toggleVacuum(" << chNumber << ")"
<< ": emitting signal \"disableVacuumButton\"";

emit disableVacuumButton();

//NQLog("ConradManager") << ": attempt to turn OFF the vacuum on channel " << chNumber;
ConradModel_->setSwitchEnabled(chNumber, false);
channelNumber = chNumber;
conradModel()->setSwitchEnabled(chNumber, false);
channelNumber_ = chNumber;

// here will be a QtTimer for about 2 secs
liveTimer_->start(togglingVacuumDelay);
Expand All @@ -64,16 +73,15 @@ void ConradManager::toggleVacuum(const int chNumber)
<< ": ERROR! Toggling vacuum error : SwithState != 0|1";
}

//looped status checking with qt timer
// looped status checking with qt timer
}

void ConradManager::vacuumToggled()
{
NQLog("ConradManager", NQLog::Debug) << "vacuumToggled"
<< ": emitting signal \"vacuumChannelState("
<< channelNumber << ", " << ConradModel_->getSwitchState(channelNumber) << ")\"";
<< ": emitting signal \"vacuumChannelState(" << channelNumber_ << ", " << conradModel()->getSwitchState(channelNumber_) << ")\"";

emit vacuumChannelState(channelNumber, ConradModel_->getSwitchState(channelNumber));
emit vacuumChannelState(channelNumber_, conradModel()->getSwitchState(channelNumber_));

NQLog("ConradManager", NQLog::Debug) << "vacuumToggled"
<< ": emitting signal \"enableVacuumButton\"";
Expand All @@ -90,29 +98,29 @@ void ConradManager::transmit_vacuumChannelState(const int chNumber)
{
NQLog("ConradManager", NQLog::Debug) << "transmit_vacuumChannelState(" << chNumber << ")"
<< ": emitting signal \"vacuumChannelState("
<< chNumber << ", " << ConradModel_->getSwitchState(chNumber) << ")\"";
<< chNumber << ", " << conradModel()->getSwitchState(chNumber) << ")\"";

emit vacuumChannelState(chNumber, ConradModel_->getSwitchState(chNumber));
emit vacuumChannelState(chNumber, conradModel()->getSwitchState(chNumber));
}

// maybe need checkStatus SLOT

void ConradManager::enableVacuum(const int chNumber)
{
const auto state = ConradModel_->getSwitchState(chNumber);
const auto state = conradModel()->getSwitchState(chNumber);

if(state == 0) // vacuum line is OFF
{
ConradModel_->setSwitchEnabled(chNumber, true);
channelNumber = chNumber;
conradModel()->setSwitchEnabled(chNumber, true);
channelNumber_ = chNumber;

liveTimer_->start(togglingVacuumDelay);
}
else if(state == 1) // vacuum line is ON
{
channelNumber = chNumber;
channelNumber_ = chNumber;

NQLog("ConradManager", NQLog::Spam) << "enableVacuum(" << chNumber << ")"
NQLog("ConradManager", NQLog::Debug) << "enableVacuum(" << chNumber << ")"
<< ": emitting signal \"vacuum_enabled\"";

emit vacuum_enabled();
Expand All @@ -122,7 +130,7 @@ void ConradManager::enableVacuum(const int chNumber)
NQLog("ConradManager", NQLog::Critical) << "toggleVacuum(" << chNumber << ")"
<< ": ERROR! Toggling vacuum error : SwithState != 0|1";

NQLog("ConradManager", NQLog::Spam) << "enableVacuum(" << chNumber << ")"
NQLog("ConradManager", NQLog::Debug) << "enableVacuum(" << chNumber << ")"
<< ": emitting signal \"vacuum_error\"";

emit vacuum_error();
Expand All @@ -133,30 +141,30 @@ void ConradManager::enableVacuum(const int chNumber)

void ConradManager::disableVacuum(const int chNumber)
{
const auto state = ConradModel_->getSwitchState(chNumber);
const auto state = conradModel()->getSwitchState(chNumber);

if(state == 0) // vacuum line is OFF
{
channelNumber = chNumber;
channelNumber_ = chNumber;

NQLog("ConradManager", NQLog::Spam) << "disableVacuum(" << chNumber << ")"
NQLog("ConradManager", NQLog::Debug) << "disableVacuum(" << chNumber << ")"
<< ": emitting signal \"vacuum_disabled\"";

emit vacuum_disabled();
}
else if(state == 1) // vacuum line is ON
{
ConradModel_->setSwitchEnabled(chNumber, false);
channelNumber = chNumber;
conradModel()->setSwitchEnabled(chNumber, false);
channelNumber_ = chNumber;

liveTimer_->start(togglingVacuumDelay);
}
else
{
NQLog("ConradManager", NQLog::Critical) << "toggleVacuum(" << chNumber << ")"
<< ": ERROR! Toggling vacuum error : SwithState != 0|1";
<< ": ERROR! Toggling vacuum error : SwitchState (" << state << ") != 0|1";

NQLog("ConradManager", NQLog::Spam) << "disableVacuum(" << chNumber << ")"
NQLog("ConradManager", NQLog::Debug) << "disableVacuum(" << chNumber << ")"
<< ": emitting signal \"vacuum_error\"";

emit vacuum_error();
Expand Down
Loading

0 comments on commit 62abf6f

Please sign in to comment.