Skip to content

Commit

Permalink
Merge pull request #179 from schuetzepaul/assembly_features
Browse files Browse the repository at this point in the history
Assembly features
  • Loading branch information
Negusbuk authored Apr 20, 2022
2 parents 8e9151e + 4116bb4 commit 7983bda
Show file tree
Hide file tree
Showing 40 changed files with 730 additions and 226 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ html/
.orig
doxygen

build/
bin/
lib/
1 change: 0 additions & 1 deletion assembly/assembly.cfg

This file was deleted.

36 changes: 35 additions & 1 deletion assembly/assembly/assembly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <QApplication>
#include <QDateTime>
#include <QFile>
#include <QCommandLineParser>
#include <QCoreApplication>

#include <opencv2/opencv.hpp>

Expand All @@ -45,12 +47,44 @@ int main(int argc, char** argv)
}
#else
QApplication app(argc, argv);
QCoreApplication::setApplicationName("Automated Assembly Software");
QCoreApplication::setApplicationVersion("1.0");
#endif

app.setStyle("cleanlooks");

QCommandLineParser parser;
parser.setApplicationDescription("Automated Assembly Software");
parser.addHelpOption();
parser.addVersionOption();

parser.addOptions({
{{"g", "glass"},
QCoreApplication::translate("main", "Use configuration for glass assembly")},
{{"s", "silicon"},
QCoreApplication::translate("main", "Use configuration for silicon assembly")}
}
);

parser.process(app);

// ensure that either glass or silicon is specified
if(parser.isSet("glass") + parser.isSet("silicon") != 1)
{
std::cout << "Please specify the use of either glass or silicon via -g (--glass) or -s (--silicon)!" << std::endl << std::endl;
parser.showHelp(1);
exit(1);
}

// choose configuration file
auto relative_config_path = "/assembly/assembly_SiDummyPS.cfg";
if(parser.isSet("glass"))
{
relative_config_path = "/assembly/assembly_glass.cfg";
}

// log output -----------
ApplicationConfig* config = ApplicationConfig::instance(std::string(Config::CMSTkModLabBasePath)+"/assembly/assembly.cfg", "main");
ApplicationConfig* config = ApplicationConfig::instance(std::string(Config::CMSTkModLabBasePath)+relative_config_path, "main");

const NQLog::LogLevel nqloglevel_stdout = ((NQLog::LogLevel) config->getDefaultValue<int>("main", "LogLevel_stdout" , 2));
const NQLog::LogLevel nqloglevel_logfile = ((NQLog::LogLevel) config->getDefaultValue<int>("main", "LogLevel_logfile", 2));
Expand Down
98 changes: 98 additions & 0 deletions assembly/assembly/parameters/SiDummyPS.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#-- Last updated on July 29th 2021 (second functional module)

# Sensor Ref-Point = corner of fiducial marker measured with Pattern Recognition
# Spacer Ref-Point = corner of spacer in correspondence with the Sensor Ref-Point
# Baseplate Ref-Point = corner [...]
# NB: 'edge' <-> corner

####################################
### DIMENSIONS #####################
####################################

# dimensions: thickness of assembly components -- to be remeasured for each assembly
Thickness_Baseplate 0.210
Thickness_PSS 0.250 #From zfocus on PSs
Thickness_PSP 0.215 #From zfocus on PSp
Thickness_MPA 0.420 #From zfocus on MPA
Thickness_Spacer 3.200 #May check with caliper or zfocus
Depth_SpacerSlots 0.350
Thickness_GlueLayer 0.020

####################################
### POSITIONS ######################
####################################

# position: Camera pointing to Sensor Ref-Point area #These coordinates correspond to an arbitrary position where to position the sensor's ref. marker, so that it is quickly recognized by PatRec
RefPointSensor_X -61.15
RefPointSensor_Y -82.49
RefPointSensor_Z -16.595 #PSS: X-61.12/Y-81.10/Z-16.625 #PSP Z-16.625 ((avg [-16.62;-16.63])) #Values taken around center of platform, for direct comparison with 'CameraFocusOnAssemblyStage_Z'
RefPointSensor_A 0.000

# 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 #Make sure 'AngleOfCameraFrameInRefFrame_dA' is calibrated first
RefPointPlatform_X -74.094
RefPointPlatform_Y -150.999
RefPointPlatform_Z -16.90
RefPointPlatform_A -0.156

# position: z-position where camera is focused on Assembly Stage surface #NB: now focusing near the center of the vacuum plate, as different z-focus values at different points indicate slight tilt
CameraFocusOnAssemblyStage_X -12.2
CameraFocusOnAssemblyStage_Y -105.42
CameraFocusOnAssemblyStage_Z -16.94
CameraFocusOnAssemblyStage_A 0.00

# position: z-position where camera is focused on Gluing Stage surface #In Y, the spacers should be reasonably centered; in X, the spacer's 'bumps' should be well-positioned on the fast glue lego pieces
CameraFocusOnGluingStage_X -144.25
CameraFocusOnGluingStage_Y -102.33
CameraFocusOnGluingStage_Z -84.16
CameraFocusOnGluingStage_A 0.00

####################################
### DISTANCES ######################
####################################
#NB: 'PSS/PSP RefPoint' below correspond to the ref. point on the PSS/PSP markers. In practice these point are identified via PatRec, i.e. they are assembly-dependent <-> these distances are all relative

# distance: Angle of Camera Frame in the XY Motion Stage Ref-Frame [deg] #Obtained with the macro 'calibrations/AngleOfCameraFrameInRefFrame_dA.cc'
AngleOfCameraFrameInRefFrame_dA -89.4655

# distance: from Sensor Ref-Point to Sensor Pickup position
FromSensorRefPointToSensorPickup_dX 85.75
FromSensorRefPointToSensorPickup_dY 40.80

# distance: dZ distance to go from Z position where camera provides best-focus on object,
# to Z position where free pickup-tool (i.e. with no other objects attached) touches the object
# - empirical value calibrated with multi-pickup tests
FromCameraBestFocusToPickupHeight_dZ -18.38

# distance: from PS-p Ref-Point to PS-s Ref-Point
# This 'nominal distance' is taken from the properly-superimposed GDS drawings of the PSP and PSS <-> XY distance between the (arbitrary) reference points used by PatRec on the PSP and PSS ref. markers
FromPSPRefPointToPSSRefPoint_dX -0.16
FromPSPRefPointToPSSRefPoint_dY 0.20

# distance: from Spacer physical edge to PS-s Ref-Point
# This 'nominal distance' is obtained from the CAD drawing of the [assembly platform + module] <-> XY distance between the 'top-left' corner of the top-most spacer (pushing against the stops) and the (arbitrary) reference point used by PatRec on the PSS ref. marker
FromSpacerEdgeToPSSRefPoint_dX -1.486
FromSpacerEdgeToPSSRefPoint_dY 0.76

# distance: from PS-p physical edge to PS-p Ref-Point
# This 'nominal distance' is taken from the GDS drawing of the PSP <-> XY distance between PSP 'top-left' reference corner and the (arbitrary) reference point used by PatRec on the PSP ref. marker
# NB: although we do not rely on the actual dicing of the PSP's edges, we do use the nominal PSP corner position in the code's logic to position the PSP on the baseplate
FromPSPEdgeToPSPRefPoint_dX 0.90
FromPSPEdgeToPSPRefPoint_dY -0.34

# distance: XY distance from 'final position to lower PSs+Spacers onto PSp' to 'position to lower PSs+Spacers onto Gluing Stage'
# This 'ad hoc' distance is defined such that the [PSS + spacers] get positioned properly above the gluing stage (with the spacers' bumps above the fast glue, etc.)
FromPSSPlusSpacersToMaPSAPositionToGluingStage_dX -170.25
FromPSSPlusSpacersToMaPSAPositionToGluingStage_dY -5.0

# distance: from ref-point on assembly platform to spacer's edge corresponding to sensor ref. marker (in spacers platform orientation -- now same as baseplate orientation)
# This 'nominal distance' is obtained from the CAD drawing of the [assembly platform] <-> XY distance between the ref. point on assembly platform and the 'top-left' corner of the top-most spacer (pushing against the stops)
# NB: this distance is platform-dependent only
FromRefPointPlatformToSpacerEdge_dX 13.355
FromRefPointPlatformToSpacerEdge_dY 69.18

# distance: from ref-point on assembly platform to PSp ref. edge (in baseplate platform orientation)
# This 'nominal distance' is obtained from the CAD drawing of the [assembly platform + module] <-> XY distance between the ref. point on assembly platform and the 'top-left' corner of the PSP
# NB: although we do not rely on the actual dicing of the PSP's edges, we do use the nominal PSP corner position in the code's logic to position the PSP on the baseplate
FromRefPointPlatformToPSPEdge_dX 11.13
FromRefPointPlatformToPSPEdge_dY 70.08
89 changes: 89 additions & 0 deletions assembly/assembly/parameters/glass.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#-- Created on May 6th 2021 (re-calibrate setup after recent changes: re-machined vacuum plate with updated HV tail slot)

# Sensor Ref-Point = corner of fiducial marker measured with Pattern Recognition
# Spacer Ref-Point = corner of spacer in correspondence with the Sensor Ref-Point
# Baseplate Ref-Point = corner [...]
# NB: 'edge' <-> corner

####################################
### DIMENSIONS #####################
####################################

# dimensions: thickness of assembly components
Thickness_Baseplate 0.220
Thickness_PSS 0.700
Thickness_PSP 0.690
Thickness_MPA 0.000
Thickness_Spacer 3.250
Depth_SpacerSlots 0.350
Thickness_GlueLayer 0.100

####################################
### POSITIONS ######################
####################################

# position: Camera pointing to Sensor Ref-Point area #These coordinates correspond to an arbitrary position where to position the sensor's ref. marker, so that it is quickly recognized by PatRec
RefPointSensor_X -61.15
RefPointSensor_Y -82.49
RefPointSensor_Z -16.24 #PSS: X-61.12/Y-81.10/Z-16.625 #PSP Z-16.625 ((avg [-16.62;-16.63])) #V
RefPointSensor_A 0.000

# 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 #Make sure 'AngleOfCameraFrameInRefFrame_dA' is calibrated first
RefPointPlatform_X -74.094
RefPointPlatform_Y -150.999
RefPointPlatform_Z -16.90
RefPointPlatform_A -0.156

# position: z-position where camera is focused on Assembly Stage surface
CameraFocusOnAssemblyStage_X -12.2
CameraFocusOnAssemblyStage_Y -105.42
CameraFocusOnAssemblyStage_Z -16.94
CameraFocusOnAssemblyStage_A 0.00

# position: z-position where camera is focused on Gluing Stage surface #In Y, the spacers should be reasonably centered; in X, the spacer's 'bumps' should be well-positioned on the fast glue lego pieces
CameraFocusOnGluingStage_X -144.25
CameraFocusOnGluingStage_Y -102.33
CameraFocusOnGluingStage_Z -84.16
CameraFocusOnGluingStage_A 0.00

####################################
### DISTANCES ######################
####################################
#NB: below 'PSS/PRefPoint' correspond to the ref. point identified by PatRec, i.e. it is assembly-dependent

# distance: Angle of Camera Frame in the XY Motion Stage Ref-Frame [deg] #Obtained with the macro 'calibrations/AngleOfCameraFrameInRefFrame_dA.cc'
AngleOfCameraFrameInRefFrame_dA -89.4655

# distance: from Sensor Ref-Point to Sensor Pickup position
FromSensorRefPointToSensorPickup_dX 86.50
FromSensorRefPointToSensorPickup_dY 40.30

# distance: dZ distance to go from Z position where camera provides best-focus on object,
# to Z position where free pickup-tool (i.e. with no other objects attached) touches the object
# - empirical value calibrated with multi-pickup tests
FromCameraBestFocusToPickupHeight_dZ -18.38

# distance: from PS-p Ref-Point to PS-s Ref-Point
FromPSPRefPointToPSSRefPoint_dX 1.25
FromPSPRefPointToPSSRefPoint_dY 0.00

# distance: from Spacer physical edge to PS-s Ref-Point
FromSpacerEdgeToPSSRefPoint_dX 0.00
FromSpacerEdgeToPSSRefPoint_dY 0.75

# distance: from PS-p physical edge to PS-p Ref-Point
FromPSPEdgeToPSPRefPoint_dX 0.85
FromPSPEdgeToPSPRefPoint_dY -0.15

# distance: XY distance from 'final position to lower PSs+Spacers onto PSp' to 'position to lower PSs+Spacers onto Gluing Stage'
FromPSSPlusSpacersToMaPSAPositionToGluingStage_dX -170.25
FromPSSPlusSpacersToMaPSAPositionToGluingStage_dY -5.0

# distance: from ref-point on assembly platform to spacer's edge corresponding to sensor ref. marker (in spacers platform orientation -- now same as baseplate orientation)
FromRefPointPlatformToSpacerEdge_dX 13.34
FromRefPointPlatformToSpacerEdge_dY 69.18

# distance: from ref-point on assembly platform to PSp ref. edge (in baseplate platform orientation)
FromRefPointPlatformToPSPEdge_dX 11.13
FromRefPointPlatformToPSPEdge_dY 70.08
27 changes: 26 additions & 1 deletion assembly/assemblyCommon/AssemblyAssemblyActionWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <nqlogger.h>
#include <AssemblyAssemblyActionWidget.h>

#include <QMessageBox>

AssemblyAssemblyActionWidget::AssemblyAssemblyActionWidget(QWidget* parent)
: QWidget(parent)

Expand All @@ -25,6 +27,8 @@ AssemblyAssemblyActionWidget::AssemblyAssemblyActionWidget(QWidget* parent)
, qobject_(nullptr)
, start_slot_(nullptr)
, stop_signal_(nullptr)

, inhibit_dialogue_(false)
{
// layout
layout_ = new QHBoxLayout;
Expand Down Expand Up @@ -61,6 +65,26 @@ void AssemblyAssemblyActionWidget::disable(const int state)
{
if(state == 2)
{
if(!inhibit_dialogue_)
{
QMessageBox* msgBox = new QMessageBox;
msgBox->setStyleSheet("QLabel{min-width: 300px;}");
msgBox->setInformativeText("WARNING: this will not perform any action but just mark the step as \"done\".\nWould you like to proceed?");
msgBox->setStandardButtons(QMessageBox::No | QMessageBox::Yes);
msgBox->setDefaultButton(QMessageBox::Yes);
int ret = msgBox->exec();
switch(ret)
{
case QMessageBox::No:
checkbox_->setCheckState(Qt::Unchecked);
return;
case QMessageBox::Yes:
break;
default: return;
}
} else {
inhibit_dialogue_ = false;
}
label_->setEnabled(false);
button_->setEnabled(false);
}
Expand Down Expand Up @@ -124,7 +148,8 @@ void AssemblyAssemblyActionWidget::disable_action()

disconnect(qobject_, stop_signal_, this, SLOT(disable_action()));

checkbox_->setChecked(true);
inhibit_dialogue_ = true;
checkbox_->setCheckState(Qt::Checked);
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions assembly/assemblyCommon/AssemblyAssemblyActionWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class AssemblyAssemblyActionWidget : public QWidget
const char* start_slot_;
const char* stop_signal_;

bool inhibit_dialogue_;

public slots:
void disable(const bool b=true);
void disable(const int);
Expand Down
59 changes: 59 additions & 0 deletions assembly/assemblyCommon/AssemblyAssemblyTextWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// //
/////////////////////////////////////////////////////////////////////////////////

#include <nqlogger.h>
#include <AssemblyAssemblyTextWidget.h>

AssemblyAssemblyTextWidget::AssemblyAssemblyTextWidget(QWidget* parent)
Expand Down Expand Up @@ -66,3 +67,61 @@ void AssemblyAssemblyTextWidget::disable(const int state)

return;
}

void AssemblyAssemblyTextWidget::reset_action()
{
qobject_ = nullptr;
check_slot_ = nullptr;
uncheck_slot_ = nullptr;
}


void AssemblyAssemblyTextWidget::connect_check_action(const QObject* qobject, const char* check_slot, const char* uncheck_slot)
{
if(qobject_) {this->reset_action();}

if(qobject)
{
qobject_ = qobject;
check_slot_ = check_slot;
uncheck_slot_ = uncheck_slot;

connect(checkbox_, SIGNAL(stateChanged(int)), this, SLOT(change_action(int)));
}
else
{
NQLog("AssemblyAssemblyTextWidget", NQLog::Warning) << "connect_check_action"
<< ": invalid (NULL) input pointer to QObject, no action taken";
}
}

void AssemblyAssemblyTextWidget::change_action(int state)
{
NQLog("AssemblyAssemblyTextWidget", NQLog::Spam) << "calling check_action";

if(qobject_)
{
if(state == Qt::Checked)
{
if(check_slot_)
{
connect(this, SIGNAL(action_request()), qobject_, check_slot_);
emit action_request();
disconnect(this, SIGNAL(action_request()), qobject_, check_slot_);
}
} else if(state == Qt::Unchecked)
{
if(uncheck_slot_)
{
connect(this, SIGNAL(action_request()), qobject_, uncheck_slot_);
emit action_request();
disconnect(this, SIGNAL(action_request()), qobject_, uncheck_slot_);
}
}
}
else
{
NQLog("AssemblyAssemblyTextWidget", NQLog::Warning) << "check_action"
<< ": invalid (NULL) pointer to QObject, no action taken";
}
}
Loading

0 comments on commit 7983bda

Please sign in to comment.