什么叫机械程序

什么叫机械程序,第1张

认真说下来就是机械运行过程吧!这指的是智能型的机械,机械这是个复杂的概念,而且随着科学的发展,机械的复杂程度越来越高,举个简单的例子,过去种地用的锄头和犁也算是机械,但它的 *** 作程序简单,所以就基本不提什么程序,现代的机械 *** 作程序越来越复杂,所以就有程序啦,比如我们的汽车,开起来就有程序啊,先做什么后做什么,你能明白,还有智能型数控机床啊等,简单的说:其实就是 *** 作过程的先后顺序!

#include<stdio.h>

#include<graphics.h>

#include<math.h>

#include<dos.h>

#include<bios.h>

#include<ctype.h>

#include<process.h>

#include<conio.h>

#define COLOR WHITE

#define F1 59

#define F2 60

#define UP 72

#define DOWN 80

#define LEFT 75

#define RIGHT 77

#define HOME 71

#define END 79

#define PAGEUP 73

#define PAGEDOWN 81

int inc=1

typedef union/*返回键盘输入值*/

{char c[2]

int i

}KEY

KEY key

typedef struct /*定义点*/

{int x

int y

}DOT

DOT dis,firstdot,secdot,dot1

int point()

int do_that()

void mv_cp(int startx,int starty,int endx,int endy,int x,int y,int flag)/*移动函数*/

void fill(int startx,int starty,int endx,int endy)/*填充*/

void colour()/*颜色*/

void menu(void)/*主菜单*/

void save(void)/*保存*/

void load(void)/*打开文件*/

void xhairs(int a,int b)/*显示光标*/

void arr_key(char c)

/*--------------------------------主函数---------------------------------------*/

void main()

{

int k,j,m,r,x1,y1,xn,yn

int driver,mode

dis.x=200

dis.y=200

driver=DETECT

mode=VGAHI

registerbgidriver(EGAVGA_driver)

registerbgifont(TRIPLEX_FONT)

initgraph(&driver,&mode,"f:\\tc2.01\\BGI")

setbkcolor(BLUE)

cleardevice()

setcolor(YELLOW)

xhairs(dis.x,dis.y)

while(key.c[0]!='q')

{

menu()/*显示菜单*/

key.i=bioskey(0)

xhairs(dis.x,dis.y)

if(!key.c[0])

arr_key(key.c[1])

else

switch(tolower(key.c[0]))

{

case 'f':

xhairs(dis.x,dis.y)colour()break

case 'd':x1=y1=0xhairs(dis.x,dis.y)setcolor(LIGHTRED)

outtextxy(10,22+(13)*30,"b:begine point")

outtextxy(10,22+(14)*30,"g:give up")

x1=point()

fill(6,410,149,430)

xhairs(dis.x,dis.y)

outtextxy(10,22+(13)*30,"e:end point")

outtextxy(10,22+(14)*30,"g:give up")

y1=point()

fill(6,410,149,460)

setcolor(COLOR)

if(x1&&y1)

{outtextxy(10,22+(13)*30,"move the +")

outtextxy(10,22+(14)*30,"y:do n:no")

}

x1=0

xhairs(dis.x,dis.y)

x1=do_that()

if(x1)

{xn=dis.xyn=dis.y

mv_cp(firstdot.x,firstdot.y,secdot.x,secdot.y,xn,yn,0)

}

fill(6,410,149,460)break

case 'l':x1=y1=0/*画直线*/

xhairs(dis.x,dis.y)

setcolor(LIGHTRED)

outtextxy(10,22+(13)*30,"b:begin point")

outtextxy(10,22+(14)*30,"g:give up")

x1=point()

fill(6,410,149,430)

xhairs(dis.x,dis.y)

outtextxy(10,22+(13)*30,"e:end point")

outtextxy(10,22+(14)*30,"g:five up")

y1=point()

setcolor(COLOR)

if(x1&&y1)

line(firstdot.x,firstdot.y,secdot.x,secdot.y)

fill(6,410,155,460)

break

case 'o':/*画圆形*/

x1=y1=0

xhairs(dis.x,dis.y)

setcolor(LIGHTRED)

outtextxy(10,22+(13)*30,"b:radius")

outtextxy(10,22+(14)*30,"g:give up")

x1=point()

fill(6,410,149,430)

xhairs(dis.x,dis.y)

outtextxy(10,22+(13)*30,"e:radius")

outtextxy(10,22+(14)*30,"g:give up")

y1=point()

if(x1&&y1) setcolor(COLOR)

r=sqrt(fabs((secdot.x-firstdot.x)*(secdot.x-firstdot.x)+(secdot.y-firstdot.y)*(secdot.y-firstdot.y)))

if(x1&&y1) circle(firstdot.x,firstdot.y,r)

fill(6,410,149,460)break

case 'h':/*画矩形*/

x1=y1=0

xhairs(dis.x,dis.y)

setcolor(LIGHTRED)

outtextxy(10,22+(13)*30,"b:left top")

outtextxy(10,22+(14)*30,"g:give up")

x1=point()

fill(6,410,149,430)

xhairs(dis.x,dis.y)

outtextxy(10,22+(13)*30,"e:right bottom")

outtextxy(10,22+(14)*30,"g:give up")

y1=point()

if(x1&&y1)

{

setcolor(COLOR)

rectangle(firstdot.x,firstdot.y,secdot.x,secdot.y)

}

fill(6,410,155,460)break

case 's':cleardevice()break/*清屏*/

case 'w':save()break

case 'r':load()break

case 'm':x1=y1=0/*图形移动*/

xhairs(dis.x,dis.y)

setcolor(LIGHTRED)

outtextxy(10,22+(13)*30,"b:begin point")

outtextxy(10,22+(14)*30,"g:give up")

x1=point()

fill(6,410,149,430)

xhairs(dis.x,dis.y)

outtextxy(10,22+(13)*30,"e:end point")

outtextxy(10,22+(14)*30,"g:give up")

y1=point()

fill(6,410,149,460)

setcolor(COLOR)

if(x1&&y1)

{

outtextxy(10,22+(13)*30,"move the +")

outtextxy(10,22+(14)*30,"y:do n:no")

}

x1=0

xhairs(dis.x,dis.y)

x1=do_that()

if(x1)

{

xn=dis.xyn=dis.y

mv_cp(firstdot.x,firstdot.y,secdot.x,secdot.y,xn,yn,1)

}

fill(6,410,149,460)break

}

xhairs(dis.x,dis.y)

}

closegraph()

}

/*--------------------------------显示光标函数--------------------------------*/

void xhairs(int a,int b)

{

int i

for(i=a-3i<=a+3i++)

putpixel(i,b,15^getpixel(i,b))

for(i=b-3i<=b+3i++)

putpixel(a,i,15^getpixel(a,i))

}

/*------------------------------菜单函数------------------------------*/

void menu(void)

{

#define STARTX 10

#define STARTY 22

#define DISTANCE 30

int i

char *menu_name[]={"F1:setp=1",

"F2:step=5",

"l:draw line",

"o:draw cirle",

"h:graw box",

"s:clear screen",

"m:move",

"d:copy",

"f:fill color",

"w:save",

"r:load",

"q:quit"}

setcolor(WHITE)

rectangle(5,5,150,470)

rectangle(5,403,150,470)

rectangle(155,5,635,470)

setcolor(LIGHTBLUE)

settextstyle(TRIPLEX_FONT,HORIZ_DIR,2)

outtextxy(36,STARTY,"menu")

settextstyle(DEFAULT_FONT,HORIZ_DIR,1)

for(i=0i<12i++)

outtextxy(STARTX,STARTY+(i+1)*DISTANCE,menu_name[i])

}

/*---------------------------------保存函数---------------------------------*/

void save(void)

{int i,j

FILE *fp

if((fp=fopen("graph.dat","w+"))==NULL)

{printf("cannot open this file!")

exit(0)

}

fill(260,473,400,480)

for(i=5i<470i++)

for(j=155j<=635j++)

fputc(getpixel(j,i),fp)

fclose(fp)

outtextxy(260,471,"save over!")

}

/*-----------------------------------------打开函数------------------------*/

void load(void)

{

int i,j

FILE *fp

if((fp=fopen("graph.dat","r+"))==NULL)

{

outtextxy(260,471,"cannot open this file!")

getch()

exit(0)

}

fill(260,471,400,480)

outtextxy(280,471,"loading......")

for(i=5i<=470i++)

for(j=155j<=635j++)

putpixel(j,i,fgetc(fp))

fill(260,471,400,480)

fclose(fp)

outtextxy(280,471,"loading over")

}

/*-----------------------------------------移动复制函数---------------------------*/

void mv_cp(int startx,int starty,int endx,int endy,int x,int y,int flag)

{

int i,j

unsigned char c

if(startx>endx)

if(starty>endy)

{i=starty

starty=endyendy=i}

for(startx<=endxstartx++,x++)

for(i=starty,j=yi<=endyi++,j++)

{c=getpixel(startx,i)

if(flag) putpixel(startx,i,BLUE)

putpixel(x,j,c)

}

}

/*----------------------------返回点坐标函数----------------------------------*/

int point()

{int valid_p=0,g=1

key.c[0]=''

while(key.c[0]!='p')

{key.i=bioskey(0)

xhairs(dis.x,dis.y)

if(!key.c[0])

arr_key(key.c[1])

else

switch(tolower(key.c[0]))

{case 'b':putpixel(dis.x,dis.y,COLOR)

firstdot.x=dis.x

firstdot.y=dis.y

key.c[0]='p'

valid_p=1

break

case 'e':

putpixel(dis.x,dis.y,COLOR)

secdot.x=dis.x

secdot.y=dis.y

key.c[0]='p'

valid_p=2break

case 'g':

firstdot.x=secdot.x

firstdot.y=secdot.y

key.c[0]='p'

g=0break

}

xhairs(dis.x,dis.y)

if(valid_p==1||valid_p==2||g==0)

break

}

xhairs(dis.x,dis.y)

return valid_p

}

/*------------------------------确认 *** 作------------------------*/

int do_that()

{

int valid_p=0,g=1

key.c[0]=''

while(key.c[0]!='p')

{key.i=bioskey(0)

xhairs(dis.x,dis.y)

if(!key.c[0])

arr_key(key.c[1])

else

switch(tolower(key.c[0]))

{case 'y':

key.c[0]='p'

putpixel(dis.x,dis.y,COLOR)

valid_p=1break

case 'n':

key.c[0]='p'

firstdot.x=secdot.x

firstdot.y=secdot.y

g=0break}

xhairs(dis.x,dis.y)

if(valid_p==1||g==0)

break

}

xhairs(dis.x,dis.y)

return valid_p

}

/*-----------------------------填充-------------------------------*/

void fill(int startx,int starty,int endx,int endy)

{int i,j

for(i=startxi<=endxi++)

for(j=startyj<=endyj++)

{putpixel(i,j,BLUE)

}

}

/*-----------------------------------颜色定义--------------------------------*/

void colour()

{

key.c[0]=''

setcolor(RED)

outtextxy(10,412,"R")

setcolor(GREEN)

outtextxy(40,412,"G")

setcolor(CYAN)

outtextxy(70,412,"C")

setcolor(LIGHTBLUE)

outtextxy(10,432,"L")

setcolor(MAGENTA)

outtextxy(40,432,"M")

setcolor(YELLOW)

outtextxy(70,432,"Y")

setcolor(WHITE)

outtextxy(10,452,"W")

setcolor(BROWN)

outtextxy(40,452,"N")

setcolor(LIGHTRED)

outtextxy(70,452,"D")

while(key.c[0]!='p')

{

key.i=bioskey(0)

xhairs(dis.x,dis.y)

if(!key.c[0])

arr_key(key.c[0])

else

{switch(tolower(key.c[0]))

{case 'y' : setfillstyle(SOLID_FILL,YELLOW) break

case 'r' : setfillstyle(SOLID_FILL,RED)break

case 'g' : setfillstyle(SOLID_FILL,GREEN)break

case 'c' : setfillstyle(SOLID_FILL,CYAN)break

case 'l' : setfillstyle(SOLID_FILL,LIGHTBLUE)break

case 'm' : setfillstyle(SOLID_FILL,MAGENTA)break

case 'w' : setfillstyle(SOLID_FILL,WHITE)break

case 'n' : setfillstyle(SOLID_FILL,BROWN)break

case 'd' : setfillstyle(SOLID_FILL,LIGHTRED)break

}

key.c[0]='p'}

*-------------------------光标---------------------*/

xhairs(dis.x,dis.y)

}

xhairs(dis.x,dis.y)

floodfill(dis.x,dis.y,WHITE)

fill(6,410,149,460)

}

/*-----------------------------光标控制----------------------------*/

void arr_key(char c)

{switch(c)

{case LEFT : dis.x-=incbreak

case RIGHT : dis.x+=incbreak

case UP : dis.y-=incbreak

case DOWN : dis.y+=incbreak

case F1 : inc=1break

case F2 : inc=5break

}

}

机械程序编程能复制

同型号的机械,机械程序编程能复制。机械编程为使机器人完成某种任务而设置的动作顺序描述。

机械编程需要学习的内容

1.工业机器人应用编程,就学对应厂家的,如ABB的RAPID,PLC,这个要平台动手 *** 作

2.机器人算法开发,就得学习C/C++,或者matlab

3.机器人控制器开发,C/C++,RTX等,也有在linuxROS下开发的,界面MFC.QT.C#

4.机器视觉opencv等,再带点机器学习,可能用到Python。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/10955806.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-12
下一篇 2023-05-12

发表评论

登录后才能评论

评论列表(0条)

保存