如何使用C#编写获取机器人坐标的winform程序

如何使用C#编写获取机器人坐标的winform程序,第1张

private void Form1_Move(object sender, EventArgs e)

{

thislabel1Text = thisLocationXToString() + "," + thisLocationYToString();

}

注意:Form1是窗体类名,label1是Form1窗体里面的一个Label控件,注意这个事件是Move事件,也就是窗口移动事件

你需要的东西有点类似搜索,或者像素搜索。有点像按键精灵里的功能,只不过vb中需要自己写这个函数。

这里只说下原理。

首先,需要红点和蓝点的像素信息集合,可以自己抓各个像素点的颜色值,并排列成矩阵,也可以截取红点和蓝点的,用程序读取这个像素信息矩阵。

然后,将这个矩阵在你的这张中比对,找到后,取左上角顶点坐标偏移红点或蓝点矩阵长宽的一半即可得出结果,如果在你自己的程序里,后台抓取也是可以得。

不过说了这么多也不知道你自己能否实现= =。。。

如果你找得到别人写的搜索的函数也可以直接借用。或者可以搜下“大漠插件”,记得里面有现成的搜索函数。

从Mapinfo读取节点或数据坐标信息。可采用3种办法:

mif/mid文件中读取。在mapinfo中选export file,把地图中的数据信息输出到mif/mid文件中。在程序中打开mif文件读取。可以得到如线段起始和终点坐标等等

主要是C语言对文件 *** 作。

从地图table表直接读取,读取表中的数据一般用FetcH。具体 *** 作如下:

1 Use a Fetch statement to specify which row in the table you want to query

This action sets which row is current

2 Use a table-reference expression (eg tablenamecolumnname) to access a

specific column in the current row

For example, the following program reads the contents of the Country column from

the first row of the World table:

Dim s_name As String

Open Table ”world” Interactive

Fetch First From world

s_name = worldCountry

MapBasic例子程序:读表中FROMLEFT一项的数据

Include "MAPBASICDEF"

Dim s_name As Integer

Open Table "D:\aa\street\onhalts1"

Map From onhalts1

Dim i,counter As Integer

Fetch First From onhalts1

Do While Not EOT(onhalts1)

s_name = onhalts1FROMLEFT

Print "The name: "+ s_name

i = i + 1

Fetch Next From onhalts1

Loop

Print "Number of undeleted records: " + i

读Object信息。

MapBasic程序:读出Object的节点坐标,长度,segment数。

Include "MAPBASICDEF"

Dim table_OBJ As String

table_OBJ = "JPN1RAILobj"

Dim geogr_length As Float,

x1,y1,x2,y2 As Float

Open Table "D:\aa\japan\JPN1RAIL"

Map From JPN1RAIL

Dim i,counter As Integer

i = 0

Fetch First From JPN1RAIL

Do While Not EOT(JPN1RAIL)

'counter = ObjectInfo(JPN1RAILobj, OBJ_INFO_NPNTS)

counter = ObjectInfo(JPN1RAILobj, OBJ_INFO_NPOLYGONS)

x1 = ObjectNodeX(JPN1RAILobj, 1, 1) ' read longitude

x2 = ObjectNodeX(JPN1RAILobj, 1, ObjectInfo(JPN1RAILobj, 20)) ' read longitude

y1 = ObjectNodeY(JPN1RAILobj, 1, 1) ' read latitude

y2 = ObjectNodeY(JPN1RAILobj, 1, ObjectInfo(JPN1RAILobj, 20)) ' read latitude

geogr_length = ObjectLen(JPN1RAILobj, "km")

Print "The length: "+ geogr_length+"x1:"+ x1+"y1:"+y1

'Print "The length: "+ geogr_length+"Counter:"+ counter

i = i + 1

Fetch Next From JPN1RAIL

Loop

Print "Number of undeleted records: " + i

============================================================================================

float geogr_length;

int nPolygons,Segment,node_Num;

CString strCommand;

mapinfoDo("Dim i As Integer");

sprintf(str,"Fetch First From %s",Table_name);

mapinfoDo(str);

num=493;

for(int i=0;i<num;i++)

{

sprintf(str,"ObjectInfo(%s,20)",Table_obj);

node_Num = atoi (mapinfoEval(str));//OBJ_INFO_NPNTS

sprintf(str,"ObjectInfo(%s,21)",Table_obj);

Segment = atoi (mapinfoEval(str));//OBJ_INFO_NPOLYGONS

sprintf(str,"ObjectNodeX(%s,1,1)",Table_obj);

x1[i] = (float)atof(mapinfoEval(str));

sprintf(str,"ObjectNodeY(%s,1,1)",Table_obj);

y1[i] = (float)atof(mapinfoEval(str));

sprintf(str,"ObjectNodeX(%s,1,ObjectInfo(%s, 20))",Table_obj,Table_obj);

x2[i] = (float)atof(mapinfoEval(str));

sprintf(str,"ObjectNodeY(%s,1,ObjectInfo(%s, 20))",Table_obj,Table_obj);

y2[i] = (float)atof(mapinfoEval(str));

geogr_length = atof( mapinfoEval("ObjectLen(JPN1RAILobj, \"km\") "));

sprintf(str,"Fetch Next From %s",Table_name);

mapinfoDo(str);

}

mapinfoDo("Print \"Number of undeleted records: \" + i ");

Fetch First From world

Note worldobj

counter = ObjectInfo(CHINAHWYobj, OBJ_INFO_NPNTS)表示一个多边形有多少个点(segment+section)。

ObjectNodeX(xxxobj, 1, counter)

一个polyline Object有line segments 和line sections组成。属性有节点数,长度,节点坐标,segment数和section数。

用函数counter = ObjectInfo(JPN1RAILobj, OBJ_INFO_NPOLYGONS)

ObjectNodeX(JPN1RAILobj, 1, 1) ' read x

ObjectNodeY(JPN1RAILobj, 1, 1) ' read y

ObjectLen(JPN1RAILobj, "km")

等求出。

dxf中你看entity字段

关于arc的描述

ARC

以下组码适用于圆弧图元。除此处所述的组码以外,另请参见常用图元组码。关于此表中使用的缩写和格式方面的信息,请参见本参考的格式惯例。

圆弧组码

组码说明

100

子类标记

(AcDbCircle)

39

厚度(可选;默认值

=

0)

10

中心点(在

OCS

中)DXF:X

值;APP:三维点

20,

30

DXF:中心点的

Y

值和

Z

值(在

OCS

中)

40

半径

100

子类标记

(AcDbArc)

50

起点角度

51

端点角度

210

拉伸方向(可选;默认值

=

0,

0,

1)DXF:X

值;APP:三维矢量

220,

230

DXF:拉伸方向的

Y

值和

Z

值(可选)

以上就是关于如何使用C#编写获取机器人坐标的winform程序全部的内容,包括:如何使用C#编写获取机器人坐标的winform程序、VB获取坐标、mapinfo怎么读取地图节点的坐标等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

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

原文地址:https://54852.com/zz/9656601.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存