Cov txheej txheem:
Video: Robotic Bead Sorting: 3 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:28
Hauv txoj haujlwm no, peb yuav tsim tus neeg hlau los txheeb cov hlaws Perler los ntawm cov xim.
Kuv ib txwm xav tsim cov xim sib txawv neeg hlau, yog li thaum kuv tus ntxhais tau txaus siab rau Perler hlaws paj ntaub, kuv pom qhov no yog lub sijhawm zoo tshaj plaws.
Perler hlaws tau siv los tsim cov txuj ci fused los ntawm kev tso ntau cov hlaws dai rau ntawm lub pegboard, thiab tom qab ntawd ua ke ua ke nrog hlau. Koj feem ntau yuav cov hlaws dai no loj heev 22, 000 hlaws sib xyaw xim pob, thiab siv sijhawm ntau los tshawb nrhiav cov xim uas koj xav tau, yog li kuv xav tias kev txheeb lawv yuav ua rau kev kos duab zoo dua.
Kuv ua haujlwm rau Phidgets Inc. yog li kuv siv feem ntau Phidgets rau txoj haujlwm no - tab sis qhov no tuaj yeem ua tiav siv cov cuab yeej tsim nyog.
Kauj ruam 1: Kho vajtse
Nov yog qhov kuv tau siv los tsim qhov no. Kuv ua nws 100% nrog ntu los ntawm phidgets.com, thiab yam uas kuv tau dag nyob ib puag ncig lub tsev.
Phidgets Boards, Motors, Hardware
- HUB0000 - VINT Hub Phidget
- 1108 - Sib nqus Sensor
- 2x STC1001 - 2.5A Stepper Phidget
- 2x 3324 - 42STH38 NEMA -17 Bipolar Gearless Stepper
- 3x 3002 - Phidget Cable 60 cm
- 3403 - USB2.0 4 -Port Hub
- 3031 - Poj Niam Pigtail 5.5x2.1mm
- 3029 - 2 xaim 100 'Twisted Cable
- 3604 - 10mm Dawb LED (Hnab ntawm 10)
- 3402 - USB Webcam
Lwm Yam
- 24VDC 2.0A Fais Fab Khoom
- Tshem ntoo thiab hlau los ntawm lub nkas -las
- Zip kev sib txuas
- Cov thawv yas nrog rau hauv qab txiav tawm
Kauj Ruam 2: Tsim Tus Neeg Hlau
Peb yuav tsum tsim qee yam uas tuaj yeem nqa ib lub hlaws los ntawm lub plhaw nkag, tso rau hauv qab lub vev xaib, thiab tom qab ntawd txav nws mus rau hauv lub thoob uas tsim nyog.
Bead Pickup
Kuv txiav txim siab ua ntu 1 nrog 2 daim ntawm plywood puag ncig, txhua qhov nrog lub qhov drilled nyob hauv tib qhov chaw. Cov thooj hauv qab tau tsau, thiab daim thooj sab saum toj tau txuas rau lub tshuab hluav taws xob, uas tuaj yeem tig nws hauv qab lub plhaw uas muaj cov hlaws dai. Thaum lub qhov ncig hauv qab lub plhaw, nws khaws ib lub hlaws. Kuv tuaj yeem tig nws hauv qab lub vev xaib, thiab tom qab ntawd tig ntxiv kom txog thaum nws sib phim nrog lub qhov hauv qab daim, ntawm qhov uas nws poob los.
Hauv daim duab no, kuv tabtom sim tias lub kaw lus tuaj yeem ua haujlwm. Txhua yam raug tsau tshwj tsis yog daim plywood puag ncig sab saum toj, uas tau txuas nrog lub cav stepper tawm ntawm kev saib hauv qab. Lub webcam tseem tsis tau teeb tsa. Kuv tsuas yog siv Phidget Tswj Vaj Huam Sib Luag tig mus rau lub cev muaj zog ntawm qhov no.
Khaub Ncaws Cia
Tshooj tom ntej yog tsim lub kaw lus rau tuav txhua xim. Kuv txiav txim siab siv lub tshuab thib ob lub cav hauv qab no los txhawb nqa thiab tig lub thawv puag ncig nrog qhov sib npaug sib npaug. Qhov no tuaj yeem siv los tig lub qhov kom raug hauv qab lub qhov uas cov hlaws yuav poob tawm.
Kuv ua qhov no siv cov duab los qhia thiab kab xev. Qhov tseem ceeb tshaj plaws ntawm no yog qhov sib xws - txhua qhov yuav tsum yog qhov loj me, thiab txhua yam yuav tsum sib npaug sib npaug kom nws tig yam tsis hla.
Kev tshem tawm cov hlaws yog ua tiav los ntawm kev kaw lub hau nruj uas nthuav tawm ib lub qhov nyob hauv ib lub sijhawm, yog li cov hlaws tuaj yeem hliv tawm.
Lub Koob Yees Duab
Lub vev xaib tau teeb tsa saum lub phaj saum nruab nrab ntawm lub plhaw thiab cov phaj qis qhov chaw. Qhov no tso cai rau lub kaw lus los saib cov hlaws ua ntej tso nws. Ib qho LED tau siv los ua kom pom cov hlaws hauv qab lub koob yees duab, thiab lub teeb ib puag ncig raug thaiv, txhawm rau muab qhov pom kev ib puag ncig ib puag ncig. Qhov no tseem ceeb heev rau kev txheeb xyuas qhov tseeb xim, vim tias qhov pom kev ib puag ncig tuaj yeem cuam tshuam qhov xim pom tseeb.
Nrhiav Qhov Chaw
Nws yog ib qho tseem ceeb rau lub kaw lus kom tuaj yeem txheeb xyuas qhov sib hloov ntawm cov hlaws sib cais. Qhov no yog siv los teeb tsa thawj txoj haujlwm thaum pib ua haujlwm, tab sis kuj tseem txhawm rau txheeb xyuas yog tias lub tshuab hluav taws xob stepper tau tawm ntawm qhov ua tiav. Hauv kuv lub cev, cov hlaws yuav qee zaum jam thaum raug khaws, thiab lub kaw lus yuav tsum muaj peev xwm txheeb xyuas thiab daws qhov xwm txheej no - los ntawm kev thim me ntsis thiab sim ua agian.
Muaj ntau txoj hauv kev los daws qhov no. Kuv txiav txim siab siv 1108 lub ntsuas hluav taws xob sib nqus, nrog cov hlau nplaum txuas rau ntawm ntug ntawm phaj saum toj kawg nkaus. Qhov no tso cai rau kuv txheeb xyuas txoj haujlwm ntawm txhua qhov kev sib hloov. Kev daws teeb meem zoo dua tej zaum yuav yog tus lej nkag rau ntawm lub cav tsav, tab sis kuv muaj 1108 dag ib puag ncig yog li kuv siv qhov ntawd.
Tiav Tus Neeg Hlau
Txij ntawm no, txhua yam tau ua tiav, thiab sim. Nws yog lub sijhawm los txhim kho txhua yam kom zoo thiab txav mus rau kev sau software.
2 lub tshuab hluav taws xob stepper tau tsav los ntawm STC1001 stepper tswj. HUB000 - USB VINT hub yog siv rau kev ua haujlwm cov tswj kev tswj hwm, nrog rau nyeem cov ntawv sib nqus thiab tsav lub LED. Lub vev xaib thiab HUB0000 yog ob qho txuas nrog lub USB me me. 3031 pigtail thiab qee cov xaim tau siv nrog 24V lub zog xa hluav taws xob rau lub cav.
Kauj ruam 3: Sau Code
C# thiab Visual Studio 2015 tau siv rau txoj haujlwm no. Rub tawm qhov chaw nyob rau sab saum toj ntawm nplooj ntawv no thiab ua raws nrog - cov ntu tseem ceeb tau piav qhia hauv qab no
Kev pib ua
Ua ntej, peb yuav tsum tsim, qhib thiab pib ua Phidget khoom. Qhov no tau ua tiav hauv daim foos teeb meem tshwm sim, thiab Phidget txuas tus tuav haujlwm.
ntiag tug void Form1_Load (tus xa khoom, EventArgs e) {
/ * Pib thiab qhib Phidgets */
top. HubPort = 0; top. Attach += Top_Attach; top. Detach += Top_Detach; top. PositionChange += Top_PositionChange; saum. Open ();
hauv qab. HubPort = 1;
hauv qab. Attach += Qab_Attach; bottom. Detach += Bottom_Detach; hauv qab. PositionChange += Bottom_PositionChange; hauv qab. Open ();
magSensor. HubPort = 2;
magSensor. IsHubPortDevice = muaj tseeb; magSensor. Attach += MagSensor_Attach; magSensor. Detach += MagSensor_Detach; magSensor. SensorChange += MagSensor_SensorChange; magSensor. Open ();
led. HubPort = 5;
led. IsHubPortDevice = muaj tseeb; coj. Channel = 0; led. Attach += Led_Attach; led. Detach += Led_Detach; coj. Open (); }
ntiav void Led_Attach (tus xa khoom, Phidget22. Events. AttachEventArgs e) {
ledAttachedChk. Checked = tseeb; coj. State = tseeb; ledChk. Checked = tseeb; }
ntiag tug tsis muaj dab tsi MagSensor_Attach (tus xa khoom, Phidget22. Events. AttachEventArgs e) {
magSensorAttachedChk. Checked = muaj tseeb; magSensor. SensorType = VoltageRatioSensorType. PN_1108; magSensor. DataInterval = 16; }
ntiav void Bottom_Attach (tus xa khoom, Phidget22. Events. AttachEventArgs e) {
bottomAttachedChk. Checked = tseeb; hauv qab. CurrentLimit = hauv qabCurrentLimit; hauv qab. Engaged = muaj tseeb; hauv qab. VelocityLimit = hauv qabVelocityLimit; hauv qab. Acceleration = bottomAccel; hauv qab. DataInterval = 100; }
ntiag tug void Top_Attach (tus xa khoom, Phidget22. Events. AttachEventArgs e) {
topAttachedChk. Checked = tseeb; top. CurrentLimit = topCurrentLimit; top. Engaged = tseeb; top. RescaleFactor = -1; top. VelocityLimit = -topVelocityLimit; top. Acceleration = -topAccel; top. DataInterval = 100; }
Peb kuj nyeem hauv cov ntaub ntawv xim khaws tseg thaum pib, yog li kev ua yav dhau los tuaj yeem txuas ntxiv mus.
Tsav Tsheb
Txoj cai tswj lub cev muaj cov haujlwm yooj yim rau kev txav lub cav. Cov motors kuv siv yog 3, 200 1/16 cov kauj ruam ib kiv puag ncig, yog li kuv tau tsim qhov tsis tu ncua rau qhov no.
Txog rau lub cev muaj zog saum toj kawg nkaus, muaj 3 txoj haujlwm peb xav kom tuaj yeem xa mus rau lub cev muaj zog rau: lub vev xaib, lub qhov, thiab qhov chaw tso hlau nplaum. Muaj txoj haujlwm taug kev mus rau txhua txoj haujlwm no:
private void nextMagnet (Boolean tos = tsis tseeb) {
ob npaug posn = top. Position % stepsPerRev;
top. TargetPosition += (stepsPerRev - posn);
yog (tos)
thaum (top. IsMoving) Xov. Sleep (50); }
private void nextCamera (Boolean tos = tsis tseeb) {
ob npaug posn = top. Position % stepsPerRev; yog (posn <Properties. Settings. Default.cameraOffset) top. TargetPosition += (Properties. Settings. Default.cameraOffset - posn); lwm sab saum toj. TargetPosition + = ((Properties. Settings. Default.cameraOffset - posn) + stepsPerRev);
yog (tos)
thaum (top. IsMoving) Xov. Sleep (50); }
ntiag tug void nextHole (Boolean tos = tsis tseeb) {
ob npaug posn = top. Position % stepsPerRev; yog (posn <Properties. Settings. Default.holeOffset) top. TargetPosition += (Properties. Settings. Default.holeOffset - posn); lwm sab saum toj. TargetPosition + = ((Properties. Settings. Default.holeOffset - posn) + stepsPerRev);
yog (tos)
thaum (top. IsMoving) Xov. Sleep (50); }
Ua ntej pib khiav, lub phaj sab saum toj tau koom nrog siv lub tshuab nqus hlau. Kev ua haujlwm alignMotor tuaj yeem raug hu nyob rau txhua lub sijhawm kom ua raws cov phaj saum toj kawg nkaus. Txoj haujlwm no ua ntej tig lub phaj sai li 1 lub kiv puag ncig kom txog thaum nws pom cov ntaub ntawv hlau nplaum saum toj saud. Nws mam li thim rov qab me ntsis thiab txav mus rau tom ntej qeeb, ntes cov ntaub ntawv sensor thaum nws mus. Thaum kawg, nws teeb tsa txoj haujlwm mus rau qhov siab tshaj plaws cov ntaub ntawv cov ntaub ntawv qhov chaw, thiab rov ua haujlwm txoj haujlwm offset rau 0. Yog li, txoj haujlwm siab tshaj plaws ntawm cov hlau nplaum yuav tsum ib txwm nyob ntawm (saum. Position % stepsPerRev)
Xov alignMotorThread; Boolean pomMagnet; ob npaug magSensorMax = 0; ntiag tug tsis muaj dab tsi alignMotor () {
// Nrhiav cov hlau nplaum
top. DataInterval = top. MinDataInterval;
sawMagnet = cuav;
magSensor. SensorChange += magSensorStopMotor; top. VelocityLimit = -1000;
ua tryCount = 0;
rov ua dua:
top. TargetPosition += stepsPerRev;
thaum (top. IsMoving &&! sawMagnet) Xov. Sleep (25);
yog (! sawMagnet) {
yog (tryCount> 3) {Console. WriteLine ("Ua tsis tiav"); top. Engaged = tsis tseeb; hauv qab. Engaged = tsis tseeb; runtest = tsis tseeb; rov qab; }
tryCount ++;
Console. WriteLine ("Peb puas nyam? Sim thaub qab …"); top. TargetPosition -= 600; thaum (top. IsMoving) Xov. Sleep (100);
rov qab ua dua;
}
top. VelocityLimit = -100;
magData = Cov npe tshiab> (); magSensor. SensorChange += magSensorCollectPositionData; top. TargetPosition += 300; thaum (top. IsMoving) Xov. Sleep (100);
magSensor. SensorChange -= magSensorCollectPositionData;
top. VelocityLimit = -topVelocityLimit;
KeyValuePair max = magData [0];
foreach (KeyValuePair khub hauv magData) yog (khub. Value> max. Value) max = khub;
top. AddPositionOffset (-max. Key);
magSensorMax = max. Value;
top. TargetPosition = 0;
thaum (top. IsMoving) Xov. Sleep (100);
Console. WriteLine ("Ua kom tau zoo");
}
Sau> magData;
ntiag tug void magSensorCollectPositionData (tus xa khoom, Phidget22. Events. VoltageRatioInputSensorChangeEventArgs e) {magData. Add (KeyValuePair tshiab (top. Position, e. SensorValue)); }
ntiag tug void magSensorStopMotor (tus xa khoom, Phidget22. Events. VoltageRatioInputSensorChangeEventArgs e) {
yog (top. IsMoving && e. SensorValue> 5) {top. TargetPosition = top. Position - 300; magSensor. SensorChange -= magSensorStopMotor; sawMagnet = muaj tseeb; }}
Thaum kawg, lub cav qis hauv qab yog tswj los ntawm kev xa nws mus rau ib qho ntawm cov hlaws ntim cov haujlwm. Txog txoj haujlwm no, peb muaj 19 txoj haujlwm. Lub algorithm yog xaiv txoj hauv kev luv tshaj plaws, thiab tig mus raws lub moos los yog lub moos xaum moos.
private int BottomPosition {tau {int posn = (int) bottom. Position % stepsPerRev; yog (posn <0) posn += stepsPerRev;
return (int) Math. Round (((posn * beadCompartments) / (double) stepsPerRev));
} }
ntiag tug void SetBottomPosition (int posn, bool tos = tsis tseeb) {
posn = posn % beadCompartments; ob npaug targetPosn = (posn * stepsPerRev) / hlawsCompartments;
ob npaug tam sim noPosn = hauv qab. Position % stepsPerRev;
ob npaug posnDiff = targetPosn - currentPosn;
// Khaws nws raws qib tag nrho
posnDiff = ((int) (posnDiff / 16)) * 16;
yog (posnDiff <= 1600) hauv qab. TargetPosition += posnDiff; lwm qhov hauv qab. TargetPosition - = (stepsPerRev - posnDiff);
yog (tos)
thaum (hauv qab. IsMoving) Xov. Sleep (50); }
Lub Koob Yees Duab
OpenCV yog siv los nyeem cov duab los ntawm lub vev xaib. Lub koob yees duab xov yog pib ua ntej pib lub ntsiab sorting xov. Cov xov no txuas ntxiv nyeem hauv cov duab, suav qhov nruab nrab xim rau ib cheeb tsam tshwj xeeb siv Txhais thiab hloov kho cov xim thoob ntiaj teb. Cov xov kuj tseem siv HoughCircles txhawm rau txhawm rau txheeb xyuas ib qho hlaws, lossis lub qhov nyob rau sab saum toj phaj, txhawm rau kho qhov chaw nws tab tom saib kom pom xim. Tus lej thiab HoughCircles tus lej tau txiav txim siab los ntawm kev sim thiab ua yuam kev, thiab vam khom ntau ntawm lub vev xaib, teeb pom kev zoo, thiab qhov sib nrug.
bool runVideo = tseeb; bool videoRunning = tsis tseeb; VideoCapture ntes; Xov cvThread; Xim kuajColor; Boolean ntes = cuav; int detectCnt = 0;
ntiag tug tsis muaj dab tsi cvThreadFunction () {
videoRunning = tsis tseeb;
ntes = tshiab VideoCapture (xaiv lub koob yees duab);
siv (Qhov rai qhov rai = Qhov rai tshiab ("ntes")) {
Mat duab = Mat tshiab (); Mat duab 2 = Mat tshiab (); thaum (runVideo) {capture. Read (duab); yog (duab. Empty ()) tawg;
yog (kuaj pom)
detectCnt ++; lwm tus detectCnt = 0;
yog (kuaj pom || circleDetectChecked || showDetectionImgChecked) {
Cv2. CvtColor (duab, duab 2, ColorConversionCodes. BGR2GRAY); Mat thres = image2. Threshold ((ob npaug) Properties. Settings. Default.videoThresh, 255, ThresholdTypes. Binary); thres = thres. GaussianBlur (OpenCvSharp. Size tshiab (9, 9), 10);
yog (showDetectionImgChecked)
duab = thres;
yog (kuaj pom || circleDetectChecked) {
CircleSegment hlaws = thres. HoughCircles (HoughMethods. Gradient, 2, /*thres. Rows/4*/20, 200, 100, 20, 65); yog (hlaws. Length> = 1) {image. Circle (hlaws [0]. Center, 3, Scalar tshiab (0, 100, 0), -1); duab. Circle (hlaws [0]. Center, (int) hlaws [0]. Radius, Scalar tshiab (0, 0, 255), 3); yog (hlaws [0]. Radius> = 55) {Properties. Settings. Default.x = (decimal) hlaws [0]. Center. X + (decimal) (hlaws [0]. Radius / 2); Properties. Settings. Default.y = (decimal) hlaws [0]. Center. Y - (decimal) (hlaws [0]. Radius / 2); } lwm {Properties. Settings. Default.x = (decimal) hlaws [0]. Center. X + (decimal) (hlaws [0]. Radius); Properties. Settings. Default.y = (decimal) hlaws [0]. Center. Y - (decimal) (hlaws [0]. Radius); } Properties. Settings. Default.size = 15; Properties. Settings. Default.height = 15; lwm yam {
CircleSegment voj voog = thres. HoughCircles (HoughMethods. Gradient, 2, /*thres. Rows/4*/5, 200, 100, 60, 180);
yog (Circles. Length> 1) {Sau xs = Circles. Select (c => cCenter. X). ToList (); xws. Sort (); Sau ys = Circles. Select (c => cCenter. Y). ToList (); ys. Sort ();
int medianX = (int) xs [xs. Count / 2];
int medianY = (int) ys [ys. Count / 2];
yog (medianX> duab. dav - 15)
medianX = image. Width - 15; yog (nruab nrab Y> duab. Height - 15) nruab nrab Y = duab. Height - 15;
duab. Circle (medianX, medianY, 100, Scalar tshiab (0, 0, 150), 3);
yog (kuaj pom) {
Properties. Settings. Default.x = medianX - 7; Properties. Settings. Default.y = nruab nrab Y - 7; Properties. Settings. Default.size = 15; Properties. Settings. Default.height = 15; }
Rect r = tshiab Rect ((int) Properties. Settings. Default.x, (int) Properties. Settings. Default.y, (int) Properties. Settings. Default.size, (int) Properties. Settings. Default.height);
Mat beadSample = Mat tshiab (duab, r);
Nplai avgColor = Cv2. Mean (beadSample); kuaj pom Colour = Color. FromArgb ((int) avgColor [2], (int) avgColor [1], (int) avgColor [0]);
duab. Rectangle (r, Scalar tshiab (0, 150, 0));
window. ShowImage (duab);
Cv2. WaitKey (1); videoRunning = tseeb; }
videoRunning = tsis tseeb;
} }
tsis pub lwm tus pom lub koob yees duabStartBtn_Click (tus xa khoom, EventArgs e) {
yog (cameraStartBtn. Text == "pib") {
cvThread = xov tshiab (ThreadStart tshiab (cvThreadFunction)); runVideo = tseeb; cvThread. Start (); cameraStartBtn. Text = "nres"; thaum (! videoRunning) Xov. Sleep (100);
updateColorTimer. Start ();
lwm yam {
runVideo = tsis tseeb; cvThread. Join (); cameraStartBtn. Text = "pib"; }}
Xim
Tam sim no, peb tuaj yeem txiav txim siab cov xim ntawm cov hlaws, thiab txiav txim siab raws li cov xim twg uas ntim kom tso rau hauv.
Cov kauj ruam no tso siab rau kev sib piv xim. Peb xav kom tuaj yeem qhia cov xim sib nrug los txwv qhov tsis zoo, tab sis kuj tseem tso cai kom txwv qhov txwv tsis zoo qhov tsis zoo. Sib piv cov xim yog qhov nyuaj ua tsis txaus ntseeg, vim tias txoj kev khoos phis tawj khaws cov xim zoo li RGB, thiab txoj kev uas tib neeg pom cov xim tsis sib cuam tshuam ncaj qha. Txhawm rau ua teeb meem tsis zoo, xim ntawm lub teeb ib qho xim tau raug saib hauv qab kuj yuav tsum raug coj los txiav txim.
Muaj cov txheej txheem nyuaj rau xam xim sib txawv. Peb siv CIE2000, uas ua rau tus lej nyob ze 1 yog 2 xim yuav tsis sib thooj rau tib neeg. Peb tab tom siv ColorMine C# lub tsev qiv ntawv los ua cov lus teb nyuaj no. Tus DeltaE tus nqi ntawm 5 tau pom tias muaj kev cuam tshuam zoo ntawm qhov tsis raug zoo thiab tsis raug cuav.
Raws li muaj ntau xim ntau dua tom qab ntim, txoj haujlwm zaum kawg tau tshwj tseg raws li lub thawv ntim khoom. Kuv feem ntau teeb tsa cov no ib sab kom khiav txawm hais tias lub tshuab ua haujlwm thib ob.
Sau
xim = Tshiab Sau (); Sau ximPanels = Tshiab Sau (); Sau cov ximTxts = Cov npe tshiab (); Sau colorCnts = Sau Tshiab ();
const int numColorSpots = 18;
const int tsis paubColorIndex = 18; int findColorPosition (Xim c) {
Console. WriteLine ("Nrhiav xim …");
var cRGB = tshiab Rgb ();
cRGB. R = c. R; cRGB. G = c. G; cRGB. B = cB;
int bestMatch = -1;
double matchDelta = 100;
rau (int kuv = 0; kuv <xim. Count; kuv ++) {
var RGB = tshiab Rgb ();
RGB. R = xim . R; RGB. G = xim . G; RGB. B = xim . B;
ob qho tib si delta = cRGB. Compare (RGB, CieDe2000Comparison tshiab ());
// double delta = deltaE (c, xim ); Console. WriteLine ("DeltaE (" + i. ToString () + "):" + delta. ToString ()); yog (delta <matchDelta) {matchDelta = delta; bestMatch = kuv; }}
yog (matchDelta <5) {Console. WriteLine ("Pom! (posn:" + bestMatch + "Delta:" + matchDelta + ")"); xa rov qab bestMatch; }
yog (xim. Count <numColorSpots) {Console. WriteLine ("Xim tshiab!"); xim. Add (c); this. BeginInvoke (Action tshiab (setBackColor), yam khoom tshiab {colors. Count - 1}); writeOutColors (); rov qab (xim. Suav - 1); } lwm {Console. WriteLine ("Tsis paub xim!"); rov qab tsis paubColorIndex; }}
Txheeb cais Logic
Qhov kev faib ua haujlwm nqa ua ke txhua daim los ua cov hlaws dai. Txoj haujlwm no ua haujlwm tshwj xeeb; txav cov phaj saum toj kawg nkaus, kuaj pom cov hlaws xim, muab tso rau hauv lub thoob, ua kom ntseeg tau tias lub phaj saum toj nyob sib haum, suav cov hlaws, thiab lwm yam. Nws kuj tseem tsis tau khiav thaum lub catchall bin ua puv - Txwv tsis pub peb tsuas yog xaus nrog hlaws hlaws.
Xov colourTestThread; Boolean runtest = cuav; void colourTest () {
yog (! top. Engaged)
top. Engaged = tseeb;
yog (! hauv qab. Engaged)
hauv qab. Engaged = muaj tseeb;
thaum (runtest) {
nextMagnet (muaj tseeb);
Xov. Sleep (100); sim {yog (magSensor. SensorValue <(magSensorMax - 4)) alignMotor (); } ntes {alignMotor (); }
nextCamera (muaj tseeb);
ntes = tseeb;
thaum (detectCnt <5) Xov. Sleep (25); Console. WriteLine ("Txheeb Xyuas Suav:" + detectCnt); ntes = cuav;
Xim c = kuaj pom xim;
this. BeginInvoke (Action tshiab (setColorDet), yam khoom tshiab {c}); int kuv = findColorPosition (c);
SetBottomPosition (kuv, muaj tseeb);
nextHole (muaj tseeb); colorCnts [kuv] ++; this. BeginInvoke (Action tshiab (setColorTxt), yam khoom tshiab {i}); Xov. Sleep (250);
yog (colorCnts [unknownColorIndex]> 500) {
top. Engaged = tsis tseeb; hauv qab. Engaged = tsis tseeb; runtest = tsis tseeb; this. BeginInvoke (Action tshiab (setGoGreen), tsis muaj); rov qab; }}}
ntiag tug tsis muaj dab tsi colourTestBtn_Click (tus xa khoom, EventArgs e) {
yog (colourTestThread == null ||! colourTestThread. IsAlive) {colourTestThread = xov tshiab (ThreadStart tshiab (colourTest))); runtest = muaj tseeb; colourTestThread. Start (); colourTestBtn. Text = "Nres"; colourTestBtn. BackColor = Xim. Red; } lwm {runtest = tsis tseeb; colourTestBtn. Text = "Mus"; colourTestBtn. BackColor = Xim. Green; }}
Txij ntawm no, peb muaj txoj haujlwm ua haujlwm. Qee qhov ntawm cov cai tau tawm ntawm tsab xov xwm, yog li saib ntawm lub hauv paus kom ua tiav nws.
Qhov khoom plig thib ob hauv kev sib tw Optics
Pom zoo:
Recycle Sorting Robot: 15 Cov Kauj Ruam (nrog Duab)
Recycle Sorting Robot: Koj puas paub tias qhov nruab nrab kis kab mob hauv zej zog thiab kev lag luam muaj txog 25%? Qhov ntawd txhais tau tias yog ib ntawm plaub daim ntawm kev rov ua dua tshiab uas koj muab pov tseg tsis tau rov siv dua. Qhov no yog tshwm sim los ntawm tib neeg ua yuam kev hauv cov chaw rov ua dua tshiab. Traditi… nyeem ntxiv
Santa's Sorting Hat: 10 Kauj Ruam (nrog Duab)
Santa's Sorting Hat: Peb tau ua haujlwm ze nrog Santa's Rhiav kom coj koj qhov kev hloov pauv tshiab no hauv qhov tsis zoo lossis cov npe zoo sib txuas lus. Tam sim no, koj tuaj yeem tshawb xyuas lub sijhawm tiag tiag yog tias koj qhov kev ua zoo thiab phem tau cuam tshuam rau koj sawv ntawm Santa's Naughty lossis Nice list! Ib qhov kev lom zem
Cov Duab Duab Duab thiab Cov Duab 1: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Cubes thiab Cov Duab 1: Thaum sim nrog qee cov ntoo ntoo thiab cov duab los qhia, kuv pom ob peb txoj hauv kev los ua cov voos thiab lwm yam duab los ntawm cov khoom siv yooj yim. Los ntawm kev muab cov no los ua Cov Ntawv Qhia, Kuv vam tias yuav txhawb nqa kev ua si thiab kev kawm. Kev hloov pauv ntawm qhov kev qhia no
LittleBits Magical Marble Sorting Machine: 11 Kauj Ruam (nrog Duab)
LittleBits Magical Marble Sorting Machine: Koj puas tau xav txheeb cov pob zeb? Yog li koj tuaj yeem tsim lub tshuab no. Koj yuav tsis tas yuav hla lub pob zeb pob zeb ntxiv mus! Nws yog lub tshuab lim dej zoo nkauj lim dej, siv lub ntsuas xim fom Adafruit, ntaus TCS34725 thiab Leonardo Arduino los ntawm
Ntsia Hlau Sorting Tshuab: 7 Cov Kauj Ruam (nrog Duab)
Ntsia Hlau Sorting Tshuab: Muaj ib hnub hauv chav kuaj (FabLab Moscow), Kuv pom kuv cov npoj yaig tsis khoom los txheeb ib lub thawv ntawm cov ntsia hlau, txiv ntseej, nplhaib thiab lwm yam khoom siv. Nres ntawm nws ib sab, kuv tau saib ib pliag thiab hais tias: "Nws yuav yog txoj haujlwm zoo tshaj plaws rau tshuab." Tom qab saib sai