برنامه نویسی

بازوی رباتیک موازی دلتا توسط سی شارپ | چگونه سینماتیک و دستی انجام دهیم؟

در اینجا، ما از ZMC406R-V2 EtherCAT Motion Controller برای ساختن سینماتیک رو به جلو یا معکوس برای دلتا از طریق C# استفاده می کنیم. علاوه بر این، نحوه کنترل دستی آن.

1. سی شارپ چگونه بازوی رباتیک موازی دلتا را توسعه می دهد؟

در اینجا، از VS2010 استفاده کنید.

مرحله 1: ساخت یک پروژه
– روی “فایل” – “جدید” – “پروژه”– کلیک کنید
– “Visual C#”، Net Framework 4 و Windows Program را انتخاب کنید–

مرحله 2: کتابخانه Zmotion را دریافت کنید
–روش 1: کتابخانه مربوطه را در وب سایت Zmotion “دانلود” پیدا کنید، سپس خودتان دانلود کنید–
–روش 2: با ما تماس بگیرید، کتابخانه مربوطه را برای شما ارسال کنید–

مرحله 3: فایل کتابخانه C# Zmotion را توسعه دهید
– فایل کتابخانه سی شارپ دانلود شده و فایل مربوطه را در پروژه جدید ساخته شده کپی کنید–
“zmcaux.cs” را در پروژه جدید کپی کنید
توضیحات تصویر
“zaux.dll” و “zmotion.dll” را در پوشه bin\debug کپی کنید
توضیحات تصویر

–باز کردن فایل ایجاد شده جدید–
*فایل را باز کنید و روی “show all files” در “solution resource manager” کلیک کنید و روی فایل “zmcaux.cs” راست کلیک کنید، سپس روی “include in project” کلیک کنید.

–ویرایش–
روی “فرم 1” از “فرم 1.cs” دوبار کلیک کنید
“استفاده از cszmcaux” را در ابتدا ویرایش کنید
*دسته کنترل کننده حالت “g_handle”.
توضیحات تصویر

2. دستورات کامپیوتر اصلی برای دلتا

در “راهنمای برنامه نویسی کتابخانه عملکرد کامپیوتر”، می توانید تمام دستورات کپسوله شده را بررسی کنید. می توانید آن را از اینجا دانلود کنید یا مستقیماً با ما تماس بگیرید.

در اینجا، دستورات مربوط به دلتا را نشان می دهد.
(1) فرمان اتصال — ZAux_OpenEth

توضیحات تصویر

(2) اتصال رو به جلو — ZAux_Direct_Connreframe

توضیحات تصویر

(3) اتصال معکوس — ZAux_Direct_Connframe

توضیحات تصویر

(4) سیستم مختصات بازوی رباتیک را بچرخانید تا سیستم مختصات کاربر را بدست آورید

توضیحات تصویر

3. یک روال: سی شارپ چگونه سینماتیک دلتا را ایجاد می کند؟

— نظریه —

(1) جهت محور را بررسی کنید
از مدل بازوی رباتیک موازی Zmotion Delta استفاده کنید، جهت 3 محور مفصلی هنگام چرخش به سمت پایین باید به سمت جلو باشد، و جهت محور چرخشی انتهایی نیز زمانی که در خلاف جهت عقربه‌های ساعت می‌چرخد (به سمت پایین) باید به سمت جلو باشد.

توضیحات تصویر

(2) پارامترهای ساختاری را ذخیره کنید

لطفاً پارامترهای ساختاری را از سازنده بدنه ربات خود دریافت کنید.

سپس پارامترهای مربوطه را در رجیستر TABLE کنترلر خود بنویسید، سپس می تواند رابط را برای ساخت سینماتیک رو به جلو یا معکوس فراخوانی کند.

توضیحات تصویر

توضیحات تصویر

(3) مبدا را تعریف کنید

الف. هنگامی که هر میله اتصال محور L1 در موقعیت افقی قرار می گیرد، به عنوان موقعیت مبدا اتصال در نظر گرفته می شود (به طور کلی، بدنه ربات پین موقعیت یابی را ارائه می دهد، اگر نه، می تواند از “gradienter” استفاده کند تا مطمئن شود L1 در افقی زمانی که در مبدا باشد.

ب. در این زمان جهت اتصال محور 0 و محور 1' جهت X سیستم مختصات دکارتی است و مبدا سیستم در مرکز صفحه افقی شاتون L1 قرار دارد.

توضیحات تصویر

(4) محور مشترک و محور مجازی را تنظیم کنید

محور مشترک یک محور موتور واقعی است. برای دلتا، دارای محور مشترک 0، محور مشترک 1، محور مشترک 2 و محور چرخش انتهایی است. و مقادیر پالس این محورهای مشترک باید به اندازه پالس های مورد نیاز در یک دایره تنظیم شود (واحد = پالس موتور در یک دایره * نسبت کاهش / 360).

محور مجازی یک محور مجازی برای سیستم مختصات دکارتی است، دارای محور مجازی سیستم X، محور Y، محور Z و یک محور چرخش RZ است. برای X,Y,Z واحدهای آنها (مقدار پالس) 1000 توصیه می شود. برای RZ واحدها باید به صورت پالس های مورد نیاز در یک دایره تنظیم شوند.

–مثال–

(1) به کنترلر متصل شوید

به کنترلر متصل شوید، دسته را دریافت کنید، سپس کامپیوتر از دسته بدست آمده برای کنترل کنترلر استفاده می کند.

//connect to controller, default IP is 192.168.0.11
ZauxErr = zmcaux.ZAux_OpenEth("192.168.0.11", out g_Handle);
if (0 != ZauxErr)
{
AlmInifFile.Write(DateTime.Now.ToString("F"), "ZAux_OpenEth Execute Error, Error Code:" + ZauxErr.ToString(), "Error Code Info");
}
وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

(2) پارامترهای بازوی رباتیک موازی دلتا را تنظیم کنید

توضیحات تصویر

توضیحات تصویر

توضیحات تصویر

(3) سینماتیک رو به جلو بسازید

/************************************************************************************
'Task No.: /
'Function of this function: build robotic arm forward or inverse connection 
'Input: Mode=0—disconnect, 1—inverse connection, 2—forward connection
'Output: /
'Returned Value: 0—success, 1--failure
'Notes: 
‘    *only controller with R is valid    
'    *when in forward, virtual axis MTYPE = 34
‘    *when in inverse, joint axis MTYPE = 34
‘    *when in inverse, keep enable.
**************************************************************************************/
public int ScaraEstab(int Mode)
{
    //update UI interface’s Delta parameters
    ScaraParaWindows.DeltaParaSave();
    //set robotic arm parameters
    SetControPara();
    //save Delta parameters into Ini file
    WriteIniFile();
    //clear controller alarms
    ZauxErr = zmcaux.ZAux_Direct_Single_Datum(g_Handle, 0, 0);
    //update axis list, the axis sequence is J1, J2, Ju, Jz(joint-axis), Vx, Vy, Vr, Vz (virtual-axis)
    int[] mJScaraAxisList = new int[4]; //joint-axis list
    int[] mVScaraAxisList = new int[4]; //virtual-axis list
    for (int i = 0; i < 4; i++)
    {
        mJScaraAxisList[i] = gDeltaAxisList[i];
        mVScaraAxisList[i] = gVAxisList[i];
    }
    //check whether robotic arm parameters are correct
    if ((DeltaR <= 0) || (Deltar <= 0) || (DeltaL1 <= 0) || (DeltaL2 <= 0))
    {
        MessageBox.Show("Delta Robot has Problem, Please Confirm! ");
        return -1;
    }
    //first to save robotic arm structural parameters into controller TABLE register, then it can build robotic arm connection
    //update robotic arm parameters into controller TABLE register
    float[] ScaraParaList = new float[11] { DeltaR, Deltar, DeltaL1, DeltaL2, gMotorPulNum[0] * gReducRatio[0], gMotorPulNum[1] * gReducRatio[1], gMotorPulNum[2] * gReducRatio[2], 0, 0, 0, gMotorPulNum[3] * gReducRatio[3] };
    ZauxErr = zmcaux.ZAux_Direct_SetTable(g_Handle, TableStaraId, 11, ScaraParaList);
    if (0 != ZauxErr)
    {
        return -1;
    }
    if ((1 == Mode) && (0 == ZauxErr)) //build inverse solution for the robot (when the robot parameters are updated successfully)
    {
        //build Scara inverse
        ZauxErr = zmcaux.ZAux_Direct_Connframe(g_Handle, 4, mJScaraAxisList, 14, TableStaraId, 4, mVScaraAxisList);
        if (0 != ZauxErr)
        {
            ProceWindows.WriteLog("Fail to Switch Inverse");
            return -1;
        }
        ProceWindows.WriteLog("Switch to Inverse");
    }
    else if ((2 == Mode) && (0 == ZauxErr)) //build forward solution for the robot (when the robot parameters are updated successfully)
    {
        //build Scara forward
        ZauxErr = zmcaux.ZAux_Direct_Connreframe(g_Handle, 4, mVScaraAxisList, 14, TableStaraId, 4, mJScaraAxisList);
        if (0 != ZauxErr)
        {
            ProceWindows.WriteLog("Fail to Switch Forward");
            return -1;
        }
        ProceWindows.WriteLog("Switch to Forward");
        }
    }
    return 0;
}
وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

توجه: برای جلو، MTYPE محور مجازی 34، برای معکوس، MTYPE محور مشترک 33 خواهد بود. برای اطلاعات بیشتر، لطفاً مقاله قبلی “کنترل کننده حرکت EtherCAT در بازوی رباتیک دلتا” را بررسی کنید.

(4) عملیات دستی حرکت

در زیر رابط حرکت دستی روتین را نشان می دهد.

دکمه “دستی” “کنترل دستی سیستم مختصات مشترک” را فشار دهید، به طور خودکار اتصال رو به جلو ایجاد می شود.

دکمه “دستی” “کنترل دستی سیستم مختصات دکارتی” را فشار دهید، به طور خودکار اتصال معکوس ایجاد می شود.

هنگامی که سرعت دستی به مقدار مشخصی کاهش می یابد، به طور خودکار به حالت اینچ تغییر می کند.

توضیحات تصویر

توضیحات تصویر

الف. حرکت دستی محور مشترک

/************************************************************************************
'Task No.: /
'Function of this “function”: joint-axis manual inverse motion, press “-“ to call
'Input: /
'Output: / 
'Returned Value: /
'Note: / 
**************************************************************************************/
private void JHandDirRev0_MouseDown(object sender, MouseEventArgs e)
{
    //whether locks it or not, after locked, then it can move
    int EnableState = 0;
    cszmcaux.zmcaux.ZAux_Direct_GetAxisEnable(MainWindows.g_Handle, MainWindows.gDeltaAxisList[0], ref EnableState);
    //if enabled
    if ((1 == EnableState) || (MainWindows.IsDebug)) 
    {
        int Vmtype = 0;//virtual axis MTYPE
        cszmcaux.zmcaux.ZAux_Direct_GetMtype(MainWindows.g_Handle, MainWindows.gVAxisList[0], ref Vmtype); 
        //if it is not forward state
        if (Vmtype != 34)
        {
            //build robotic arm forward connection
            if (0 != MainWindows.ScaraEstab(2))
            {
                //Fail to build the robot connection
                return;
            }
        }
        //which button to be pressed
        int Id = 0;
        for (int i = 0; i < 4; i++)
        {
            if (((Button)sender).Name == ("JHandDirRev" + i))
            {
                Id = i;
            }
        }
        int TempAxis = 0;
        TempAxis = MainWindows.gDeltaAxisList[Id];
        //if manual speed is less than 5, it is inching mode
        if (5 <= MainWindows.HnadSpeedPerc)
        {
            //set point motion speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.HnadSpeedPerc * MainWindows.gAxisHandSpeed[Id] / 100);
            //send “inverse” motion command
            cszmcaux.zmcaux.ZAux_Direct_Single_Vmove(MainWindows.g_Handle, TempAxis, -1);
        }
        else
        {
            //set inching speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.gAxisHandSpeed[Id] / 10);
            //send inching motion command
            cszmcaux.zmcaux.ZAux_Direct_Single_Move(MainWindows.g_Handle, TempAxis, -1 * MainWindows.HnadSpeedPerc);
        }
    }
}
/************************************************************************************
'Task No.: /
'Function of this “function”: joint-axis manual forward motion, press “+“ to call
'Input: /
'Output: / 
'Returned Value: /
'Note: /     
**************************************************************************************/
private void JHandDirFwd0_MouseDown(object sender, MouseEventArgs e)
{
    //whether locks it or not, after locked, then it can move
    int EnableState = 0;
    cszmcaux.zmcaux.ZAux_Direct_GetAxisEnable(MainWindows.g_Handle, MainWindows.gDeltaAxisList[0], ref EnableState);
    //if enabled
    if ((1 == EnableState) || (MainWindows.IsDebug)) 
    {
        int Vmtype = 0;//virtual axis MTYPE
        cszmcaux.zmcaux.ZAux_Direct_GetMtype(MainWindows.g_Handle, MainWindows.gVAxisList[0], ref Vmtype); 
        //if it is not forward state
        if (Vmtype != 34)
        {
            //build robotic arm forward kinematic
            if (0 != MainWindows.ScaraEstab(2))
            {
                //Fail to build the robot connection
                return;
            }
        }
        //which button to be pressed
        int Id = 0;
        for (int i = 0; i < 4; i++)
        {
            if (((Button)sender).Name == ("JHandDirFwd" + i))
            {
                Id = i;
            }
        }
        int TempAxis = 0;
        TempAxis = MainWindows.gDeltaAxisList[Id];
        //if manual speed is less than 5, it is inching mode
        if (5 <= MainWindows.HnadSpeedPerc)
        {
            //set point motion speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.HnadSpeedPerc * MainWindows.gAxisHandSpeed[Id] / 100);
            //send “forward” motion command
            cszmcaux.zmcaux.ZAux_Direct_Single_Vmove(MainWindows.g_Handle, TempAxis, 1);
        }
        else
        {
            //set inching speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.gAxisHandSpeed[Id] / 10);
            //send inching motion command
            cszmcaux.zmcaux.ZAux_Direct_Single_Move(MainWindows.g_Handle, TempAxis, 1 * MainWindows.HnadSpeedPerc);
        }
    }
}
/************************************************************************************
'Task No.: /
'Function of this “function”: joint-axis stop manual motion, call when point button is released
'Input: /
'Output: / 
'Returned Value: /
'Note: /      
**************************************************************************************/
private void JHandDirRev0_MouseUp(object sender, MouseEventArgs e)
{
    //which button to be pressed
    int Id = 0;
    for (int i = 0; i < 4; i++)
    {
        if (((Button)sender).Name == ("JHandDirRev" + i))
        {
            Id = i;
        }
    }
    int TempAxis = 0;
    TempAxis = MainWindows.gDeltaAxisList[Id];
    //if manual speed is less than 5, it is inching mode
    if (5 <= MainWindows.HnadSpeedPerc)
    {
        MainWindows.ZauxErr = cszmcaux.zmcaux.ZAux_Direct_Single_Cancel(MainWindows.g_Handle, TempAxis, 2);
    }
}
وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

ب. حرکت دستی محور مجازی

/************************************************************************************
'Task No.: /
'Function of this “function”: virtual manual inverse motion, press “-“ to call
'Input: /
'Output: / 
'Returned Value: /
'Note: /     
**************************************************************************************/
private void VHandDirRev0_MouseDown(object sender, MouseEventArgs e)
{
    //whether locks it or not, after locked, then it can move
    int EnableState = 0;
    cszmcaux.zmcaux.ZAux_Direct_GetAxisEnable(MainWindows.g_Handle, MainWindows.gDeltaAxisList[0], ref EnableState);
    //if enabled
    if ((1 == EnableState) || (MainWindows.IsDebug)) 
    {
        int Jmtype = 0;//joint-axis Mtype
        cszmcaux.zmcaux.ZAux_Direct_GetMtype(MainWindows.g_Handle, gDeltaAxisList[0], ref Jmtype);
        //if it is not inverse state
        if (Jmtype != 33)
        {
            //build robotic arm inverse kinematic
            if (0 != MainWindows.ScaraEstab(1))
            {
                //Fail to build the robot connection
                return;
            }
        }
        //which button to be pressed
        int Id = 0;
        for (int i = 0; i < 5; i++)
        {
            if (((Button)sender).Name == ("VHandDirRev" + i))
            {
                Id = i;
            }
        }
        int TempAxis = 0;
        //update current robotic arm state
        TempAxis = MainWindows.gVAxisList[Id];
        //if manual speed is less than 5, it is inching mode
        if (5 <= MainWindows.HnadSpeedPerc)
        {
            //set point motion speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.HnadSpeedPerc * MainWindows.gAxisHandSpeed[Id] / 100);
            //send “inverse” motion command
           cszmcaux.zmcaux.ZAux_Direct_Single_Vmove(MainWindows.g_Handle, TempAxis, -1); 
        }
        else
        {
            //set inching speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.gAxisHandSpeed[Id] / 10);
            //send inching motion command
           cszmcaux.zmcaux.ZAux_Direct_Single_Move(MainWindows.g_Handle, TempAxis, -1 * MainWindows.HnadSpeedPerc);
        }
    }
}
/************************************************************************************
'Task No.: /
'Function of this “function”: joint-axis manual forward motion, press “+“ to call
'Input: /
'Output: / 
'Returned Value: /
'Note: /    
**************************************************************************************/
private void VHandDirFwd0_MouseDown(object sender, MouseEventArgs e)
{
    //whether locks it or not, after locked, then it can move
    int EnableState = 0;
    cszmcaux.zmcaux.ZAux_Direct_GetAxisEnable(MainWindows.g_Handle, MainWindows.gDeltaAxisList[0], ref EnableState);
    //if enabled
    if ((1 == EnableState) || (MainWindows.IsDebug)) 
    {
        int Jmtype = 0;//joint-axis Mtype
        cszmcaux.zmcaux.ZAux_Direct_GetMtype(MainWindows.g_Handle, gDeltaAxisList[0], ref Jmtype);
        //if it is not forward kinematic
        if (Jmtype != 33)
        {
            //build robotic arm forward connection
            if (0 != MainWindows.ScaraEstab(1))
            {
                //Fail to build the robot connection
                return;
            }
        }
        //which button to be pressed
        int Id = 0;
        for (int i = 0; i < 5; i++)
        {
            if (((Button)sender).Name == ("VHandDirFwd" + i))
            {
                Id = i;
            }
        }
        int TempAxis = 0;
        //update current robotic arm state
        TempAxis = MainWindows.gVAxisList[Id];
        //if manual speed is less than 5, it is inching mode
        if (5 <= MainWindows.HnadSpeedPerc)
        {
           //set point motion speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.HnadSpeedPerc * MainWindows.gAxisHandSpeed[Id] / 100);
           //send “forward” motion command
           cszmcaux.zmcaux.ZAux_Direct_Single_Vmove(MainWindows.g_Handle, TempAxis, 1); 
        }
        else
        {
            //set inching speed
            cszmcaux.zmcaux.ZAux_Direct_SetSpeed(MainWindows.g_Handle, TempAxis, MainWindows.gAxisHandSpeed[Id] / 10);
            //send inching motion command
           cszmcaux.zmcaux.ZAux_Direct_Single_Move(MainWindows.g_Handle, TempAxis, 1 * MainWindows.HnadSpeedPerc);
        }
    }
}
/************************************************************************************
'Task No.: /
'Function of this “function”: virtual-axis stop motion, call when the point motion button is released
'Input: /
'Output: / 
'Returned Value: /
'Note: /     
**************************************************************************************/
//stop the motion
private void VHandDirRev0_MouseUp(object sender, MouseEventArgs e)
{
    //which button to be pressed
    int Id = 0;
    for (int i = 0; i < 5; i++)
    {
        if (((Button)sender).Name == ("VHandDirRev" + i))
        {
            Id = i;
        }
    }
    int TempAxis = 0;
    TempAxis = MainWindows.gVAxisList[Id];
    //if manual speed is less than 5, it is inching mode
    if (5 <= MainWindows.HnadSpeedPerc)
    {
        cszmcaux.zmcaux.ZAux_Direct_Single_Cancel(MainWindows.g_Handle, TempAxis, 2);
    }
}
وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

(5) از ابزار شبیه ساز بازوی رباتیک استفاده کنید

نرم افزار “ZRobotView” را باز کنید، IP کنترلر را وارد کنید (IP پیش فرض: 192.168.0.11)، سپس روی “connect” کلیک کنید. پس از اتصال، روی “سوئیچ” کلیک کنید، می تواند عملیات بازوی رباتیک را به صورت سه بعدی شبیه سازی کند.

توضیحات تصویر

توضیحات تصویر

این همه است، از خواندن شما متشکرم – بازوی رباتیک موازی دلتا توسط سی شارپ | نحوه انجام سینماتیک و دستی.

این مقاله توسط ZMOTION ویرایش شده است، در اینجا، با شما به اشتراک بگذارید، بیایید با هم یاد بگیریم.

توجه: کپی رایت متعلق به Zmotion Technology است، در صورت تکرار، لطفا منبع مقاله را ذکر کنید. متشکرم.

نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا