球面距离
球面上两点之间的最短连线的长度,就是经过这两点的大圆在这两点间的一段劣弧的长度(大圆就是经过球心的平面截球面所得的圆)。这个弧长叫做两点的球面距离。
求法如下:
设若角AOB(球心角)为θ,大球的半径为R,A点维度、经度为(x1,y1),B点维度、经度为(x2,y2),则球面距离为Rθ。球面距离计算公式:d(x1,y1,x2,y2)=r*arccos(sin(x1)*sin(x2)+cos(x1)*cos(x2)*cos(y1-y2)) * Pi/180 // x,y是纬度\经度的角度单位,若x,y用弧度表示,比如sin(x1)需要修正为sin(x1*Pi/180),r 为地球半径。
这里忽略地球表面地形对计算带来的误差,仅仅是理论上的估算值。按照0度经线的基准,东经取经度的正值(Longitude),西经取经度负值(-Longitude),北纬取90-维度值(90-Latitude),南纬取90+维度值(90+Latitude);假设都是北半球(南半球只有澳洲具有应用意义),可以仅对经度作正负处理,而不对维度作 90-Latitude。
地球的相关知识:
(1)形状和大小:
地球形状是一个两极部位略扁的不规则的球体。地球的平均半径为6371千米,赤道半径6378千米,极半径6357千米。赤道周长约为4万千米。
(2)纬线和纬度、经线和经度
① 纬线:纬线都是圆,也称为纬线圈,长度不等。赤道最长,由赤道向两极逐渐缩短,最后成一点。纬线指向东西方向。
② 纬度:赤道是零度纬线。赤道以北的纬度,叫北纬,用“N”作代号;赤道以南的纬度叫南纬,用“S”作代号。北纬、南纬各有90°。
③ 经线:也叫子午线。经线是半圆,所有经线长相等。经线指向南北方向。
④ 经度:零度经线叫做本初子午线。从本初子午线向东、向西各分作180度,以东的180°属于东经,用“E”作代号;以西的180°属于西经,用“W”作代号。(因为经线圈都过极点,所以就把经线圈,拆分成半圆,这样就有了东经、西经的区分了;而维线圈相互之间没有相交,所以即使是圆圈,同样可以区分南纬、北纬)。
全球定位系统组成部分
GPS系统包括三大部分: 空间部分—GPS星座(GPS星座是由24颗卫星组成的星座,其中21颗是工作卫星,3颗是备份卫星);地面控制部分—地面监控系统;用户设备部分—GPS 信号接收机。
空间部分
GPS的空间部分是由24 颗工作卫星组成,它位于距地表2_0200km的上空,均匀分布在6 个轨道面上(每个轨道面4 颗) ,轨道倾角为55°。此外,还有4 颗有源备份卫星在轨运行。卫星的分布使得在全球任何地方、任何时间都可观测到4 颗以上的卫星,并能保持良好定位解算精度的几何图象。这就提供了在时间上连续的全球导航能力。GPS 卫星产生两组电码, 一组称为C/A 码( Coarse/ Acquisition Code1.023MHz) ;一组称为P 码(Procise Code 10.23MHz) ,P 码因频率较高,不易受干扰,定位精度高,因此受美国军方管制,并设有密码,一般民间无法解读,主要为美国军方服务。C/A 码人为采取措施而刻意降低精度后,主要开放给民间使用。
定位原理
GPS的基本定位原理是卫星不间断地发送自身的星历参数和时间信息,用户接收到这些信息后,经过计算求出接收机的三维位置,三维方向以及运动速度和时间信息。
当苏联发射了第一颗人造卫星后,美国约翰·霍布金斯大学应用物理实验室的研究人员提出既然可以已知观测站的位置知道卫星位置,那么如果已知卫星位置,应该也能测量出接收者的所在位置。这是导航卫星的基本设想。GPS导航系统的基本原理是测量出已知位置的卫星到用户接收机之间的距离,然后综合多颗卫星的数据就可知道接收机的具体位置。要达到这一目的,卫星的位置可以根据星载时钟所记录的时间在卫星星历中 查出。而用户到卫星的距离则通过纪录卫星信号传播到用户所经历的时间,再将其乘以光速得到(由于大气层电离层的干扰,这一距离并不是用户与卫星之间的真实距离,而是伪距(PR):当GPS卫星正常工作时,会不断地用1和0二进制码元组成的伪随机码(简称伪码)发射导航电文。GPS系统使用的伪码一共有两种,分别是民用的C/A码和军用的P(Y)码。C/A码频率1.023MHz,重复周期一毫秒,码间距1微秒,相当于300m;P码频率 10.23MHz,重复周期266.4天,码间距0.1微秒,相当于30m。而Y码是在P码的基础上形成的,保密性能更佳。导航电文包括卫星星历、工作状况、时钟改正、电离层时延修正、大气折射修正等信息。
差分技术
为了使民用的精确度提升,科学界发展另一种技术,称为差分全球定位系统(Differential GPS), 简称DGPS。亦即利用附近的已知参考坐标点(由其它测量方法所得), 来修正 GPS 的误差。再把这个即时(real time)误差值加入本身坐标运算的考虑, 便可获得更精确的值。
GPS有2D导航和3D导航分,在卫星信号不够时无法提供3D导航服务,而且海拔高度精度明显不够,有时达到10倍误差。但是在经纬度方面经改进误差很小。卫星定位仪在高楼林立的地区扑捉卫星信号要花较长时间。
基本定位知识
收到兩顆衛星以下無法定位
收到三顆衛星只能做平面基本定位
收到四顆衛星可作立體(含高度)基本定位
收到五顆衛星以上可作立體(含高度)精準定位
GPS接收器拿來完成標準的3D定位是需要4顆沒錯
最簡單的解釋是以解這個方程式來說明 (dx^2+dy^2+dz^2)^(1/2)=Pseudorange
這個方程式有三個未知數 同時也是一個二階的方程式
理論上必須要有四顆衛星才能解 可是因為我們接收器都假設使用者在地球上
所以把外太空的那個解去掉就可以只需三顆衛星來解這個方程式
但是我們知道GPS的工作原理包括了解出使用者的時鐘誤差
所以必須多一顆衛星來解這個未知數 這就是為何需要四顆的原因
时钟相位偏差
相位偏差测量不是用本地时钟跟收到的卫星时钟做比较得出的.而是多颗卫星的数据列方程组求解得到的.
一点的坐标有三个未知量,这样本来只需要三个卫星的相位偏差信号就可以唯一的确定三维坐标了,可事实上不行,因为本地没有绝对准确的时钟,所以就需要第四颗卫星,把接收机和卫星同步时钟的相对钟差做为一个未知量列入方程组,4个方程,4个未知量,就可以精确求解xyzt了。事实上,接收机也可以根据上述计算得到的钟差将本地时钟校准.实际使用中,这个本地时钟准确与否对坐标测量是没有什么影响的.
距离测量:
卫星坐标(x1,y1,z1)...(x4,y4,z4)到接收机坐标x,y,z.;接收机有时钟,尽管不同步,设收到信号时侯按照接收机的时钟跟卫星信号中的时钟数据相减的传输时间是t1,t2,t3,t4.
事实上接收机的时钟可能是跟卫星同步时钟有偏差的.设这个偏差是dt。那么实际的信号传输时间应该是,t1-dt....t4-dt. 方程组如下式:
√[(x1-x)^2+(y1-y)^2+(z1-z)^2]=c*(t1-dt) (球体半径)★★★★★
...4个这样的方程
未知数是4个x,y,z,t,可以求解.就是说接收机时钟尽管不同步,我们解完方程也就知道这个钟差t到底多大了,xyz也同时得到了.距离是不用关心的中间数据,若需要的话也可以求.我们只需要xyz坐标数据.伪距就是上面解得的t乘以光速.
接收机的时钟数据是否需要校准呢?(出厂注入时间后需要更改吗?) 如果需要,是根据上次得出的 dT 进行校准,还是通过其他的人工方式 ?
理论上讲是无须校准的,这与接收机的设计思路有关的,他们在软件处理上可以定期用算出来的dt校准,也可以根据dt的大小校准,比如dt超出某范围就校准一次,尽管接收机的时钟精度不够,但是短时间积累的钟差不会很大,使接收机与卫星保持一种准同步状态,使每次计算出来的dt都不会很大,这样就可以在环境不好不能接收4颗卫星信号的时候可以用dt=0,简单求解坐标值.总之这些要看接收机设计人员的思路了.不同的人会有不同的习惯,只要最终得出的数据是满足精度要求的就可以了.
最少几颗卫星即可确定地面准确位置?
首先,我们忽略地球的高度,把它假想成一个纯平面,也就是一个纯的球面。也就是说我们只关心物体的位置,不关心他的高度、速度等等其他信息 。这时候其实三颗(甚至两颗)就可以定出平面上的位置,如果卫星的数据十分精确的话。
因为每颗卫星可以精确定出距离,忽略地面位置的高度,那么一颗卫星就可以在地球上画出一个圆,圆弧上每点到卫星的距离一样。如果有两颗卫星,就可以画出两个圈,那么这两个圈的两个交点(如图,A和B点)就是这个物体可能所处的位置。我们可以根据一定的条件排除另外一个交点,那么我们就可以得到所关心物体的位置了。但如果A、B两点相距太近,这时候就需要三颗卫星,三颗卫星定出的圆弧交于一点,这个时候就可以准确知道物体的位置(所以三星定位时,与海平面高度差越大,位置误差就越大)。
但如果要考虑物体的高度的话,也就是考虑实际的三维情况 (也就是真实的GPS的情形),2-3颗卫星就不够了。而这个时候,如(三维立体)图所示:
两颗卫星定出来的会是一个圆弧,也就是只能确定位置处于圆弧上某一点(右上图):三颗卫星可以定出来两个点(左下图):而如果你需要精确得到一个点的空间位置,你至少需要四颗卫星(右下图)。
You need four satellites because each data from one satellite put you in a sphere around the satellite. By computing the intersections you can narrow the possibilities to a single point.
Two satellites intersection places you on a circle. (all points possible)(两个球面的交点组成一个圆弧)
Three satellites intersection places you on two possible points.
The last satellite give you the exact location.
You can avoid using four satellite if you already know the altitude, for example when you drive, you can use the ground level as the last intersection. But you can't possibly do this in a plane, since you are not bound to the ground.
relates to the geometry of being able to pin point a uav position. example: if all the sats were in the same location you might not get a fix at all.
if there is not a good spread of sat positions in relation to the earths globe then the accuracy of the uav position or "fix" is reduced. 3D is the best and you should be able to get 3D outside. Is the gps view of the sky obstucted by wires or copter frame etc?
2-D vs. 3-D Fixes
Most receivers calculate a horizontal(水平面,水平线;水平的) position after they acquire three satellites. To do this they must make presumptions(假定,推定) on their altitude. Usually the last calculated altitude is used. If the altitude assumed by the receiver is in error, the accuracy of the horizontal position is impacted. For example, if the receiver assumed mean sea level and it was at 10,000 feet, a horizontal error of more than a mile could result. On the other hand, if the assumed value is very accurate the horizontal error may be less than if four satellites are tracked.
I’m going to try to present a simplified description of the GPS position calculation procedure to help the reader understand why the above is true. If a receiver is tracking four satellites, it is able to make simultaneous(同步的) pseudo('sjuːdəʊ;冒充的,假的;伪君子)-range measurements from each. Each pseudo-range can be thought of as being equal to the range to the satellite plus the offset in the receiver’s clock, scaled to distance units. Since the receiver can calculate the satellite’s position from the Navigation Message, there are four unknowns in the pseudo-range equations: the three components of the receiver’s position, and the offset in the receiver’s clock. To determine its location it then must solve the four equations for the four unknowns. The receiver uses suitable algorithms to perform this arithmetic [Note for the more mathematically inclined. You’ve noticed that the equations are non-linear which makes the task non-trivial. If a rough estimate of position is available a Taylor series expansion about the estimated position is generally used. The partial derivatives of the pseudo-range wrt to receiver position are equal to the satellite-to-receiver unit line of sight vector.]
If the receiver “knows” one of the three position components, then measurements from only three satellites are required to solve for the other two components and the receiver clock offset (3 equations and 3 unknowns). If, for example, the altitude is known perfectly, this is equivalent to tracking a satellite directly above (or below) the user, and having a perfect pseudo-range measurement to it. Since a real fourth satellite will never provide a perfect pseudo-range, the three-satellite solution will be better than the four-satellite solution (assuming similar geometry quality, i.e., PDOP). If on the other hand the assumed altitude is in error, then the two sides of the equations will be equal only if a compensating error is added to the horizontal position components and clock offset.
How does a receiver calculate its position if more than four satellites are tracked? Well, without getting into the mathematics it will be a little difficult to explain, but I’ll try. This description will be conceptual, that is should not be taken literally. As was described above, with four satellites (and good geometry) the position (and necessarily the clock offset) can be calculated. If a measurement from a fifth satellite is available, the receiver can calculate what the measurement should be (expected pseudo-range is range plus clock offset, based on the four satellite solution). The difference between the actual pseudo-range and the expected pseudo-range indicates whether the fifth satellite “agrees” with the four-satellite position solution. That is, if the difference is zero the five-satellite solution is the same as the four-satellite solution. If it is non-zero, then the value is used to adjust the four satellite position (and clock offset) to produce the five satellite position. How is the adjustment done? Well mathematically, linear algebra techniques are used to produce a least square solution. Conceptually think about it like this. You guess a position (and clock) solution, then use it to calculate the five expected pseudo-range values as described above. You then square each of the pseudo-range differences (expected minus actual pseudo-range) and sum them up. This is a measure of the quality of the five-satellite solution. You try many different position solutions, calculating the quality measure for each. The one with the smallest quality measure is your least squares five satellite position. A similar technique is used to calculate a least squares solution for more than five satellites.
How GPS Works
The Global Positioning System, also called NavStar, that we use was built by the US military and has been fully operational since 1995. Many modern GPS receivers use a combination of both GPS and the Russian GLONASS satellites for improved coverage and accuracy.
The GPS system currently has 31 active satellites in orbits inclined 55 degrees to the equator(赤道). The satellites orbit about 20,000km from the earth's surface and make two orbits per day. The orbits are designed so that there are always 6 satellites in view, from most places on the earth.
GPS uses a lot of complex technology, but the concept is simple.
The GPS receiver gets a signal from each GPS satellite. The satellites transmit the exact time the signals are sent. By subtracting the time the signal was transmitted from the time it was received, the GPS can tell how far it is from each satellite. The GPS receiver also knows the exact position in the sky of the satellites, at the moment they sent their signals. So given the travel time of the GPS signals from three satellites and their exact position in the sky, the GPS receiver can determine your position in three dimensions - east, north and altitude.(longitude latitude)
There is a complication. To calculate the time the GPS signals took to arrive, the GPS receiver needs to know the time very accurately. The GPS satellites have atomic clocks that keep very precise time, but it's not feasible to equip a GPS receiver with an atomic clock. However, if the GPS receiver uses the signal from a fourth satellite it can solve an equation that lets it determine the exact time, without needing an atomic clock.
If the GPS receiver is only able to get signals from 3 satellites, you can still get your position, but it will be less accurate. As we noted above, the GPS receiver needs 4 satellites to work out your position in 3-dimensions. If only 3 satellites are available, the GPS receiver can get an approximate position by making the assumption that you are at mean sea level. If you really are at mean sea level, the position will be reasonably accurate. However if you are in the mountains, the 2-D fix could be hundreds of metres off.(GPS卫星的坐标是世界大地坐标系(world geodetic system s4,WGSs4),坐标系,转换算法 2D-fix 无法获得高度)
A modern GPS receiver will typically track all of the available satellites simultaneously, but only a selection of them will be used to calculate your position.
Almanac and Ephemeris
To determine the location of the GPS satellites two types of data are required by the GPS receiver: the almanac('ɔːlmənæk;年历) and the ephemeris(ɪ'fem(ə)rɪs;星历表). This data is continuously transmitted by the GPS satellites and your GPS receiver collects and stores this data.
The almanac contains information about the status of the satellites and approximate orbital information. The GPS receiver uses the almanac to calculate which satellites are currently visible. The almanac is not accurate enough to let the GPS receiver get a fix. If the GPS receiver is new, or has not been used for some time, it may need 15 minutes or so to receive a current almanac. In older GPS receivers, an almanac is required to acquire the satellites, but many newer models are able to acquire the satellites without waiting for the almanac.
To get a fix, your GPS receiver requires additional data for each satellite, called the ephemeris. This data gives very precise information about the orbit of each satellite. Your GPS receiver can use the ephemeris data to calculate the location of a satellite to with a metre or two. The ephemeris is updated every 2 hours and is usually valid for 4 hours. If your GPS receiver has been off for a while, it may take up to several minutes to receive the ephemeris data from each satellite, before it can get a fix.
Your GPS will have a screen, like the one on the right, which shows which satellites are in use. The bar graphs show the strength of the satellites that the GPS has acquired. If the bar is hollow, the GPS is still downloading the ephemeris. The circular plot shows the location of the satellites in the sky - the centre of the circle is overhead.
Startup
When you switch the GPS on, the time-to-first-fix varies depending on how long it is since you last used the GPS. To get a fix, the GPS receiver needs a valid almanac, initial location, time, and ephemeris data.
The terms "cold/warm/hot start" indicate how many of these pieces of data the GPS receiver already has. The terms mean different things to different GPS manufacturers.
Cold start - if the GPS not been used for a long time and/or has moved several hundred kilometres it will take some time to get the first fix. In this state, the GPS receiver does not have a current almanac, ephemeris, initial position or time. Older GPS units may take up to an hour to search for satellites, download the almanac and ephemeris data and obtain an initial position, though newer GPS units may require much less than this.
If the GPS receiver has moved several hundred kilometres, its assumptions about which satellites to use will be incorrect and it will have to search for them. Most units will let you enter an approximate location to speed the process.
Warm start - current almanac, initial position, and time are all valid. Ephemeris data is either invalid or only partially valid. Time-to-first-fix is likely to be 30 seconds to 2 minutes depending on satellite availability and the type of GPS receiver.
Hot start - if the receiver has been off for, say, less than an hour time-to-first-fix will likely be 5-20 seconds.
What does this all mean in practice?
If the GPS has been recently used you should get a fix almost immediately. If it hasn't, put the GPS outside with a clear view of the sky and have a cup of tea.
If you have a GPS in a vehicle, it's better to wait for the unit to get a fix before driving off. Receiving ephemeris data for a satellite takes 30 seconds. If you momentarily interrupt the signal during that time the GPS it could take up to a minute more to get the ephemeris for that satellite as it has to start over. If you drive in an area with tall buildings or other obstructions it may take a long time to get the ephemeris data, for four satellites, that is needed for the first fix.
Accuracy
The accuracy of the position your GPS reports is influenced by a number of factors, such as the positions of the satellites in the sky, atmospheric effects, satellite clock errors and ephemeris errors etc.
GPS units often show on the screen an accuracy figure, e.g. EPE on Garmin units. Under ideal conditions, this may be 5, or even 3 metres. Manufacturers are vague on exactly how this figure is determined and it would be unwise to take this figure literally.
You'll get a more realistic figure by looking in the specification section of your GPS receiver's user-manual. Typically, with a handheld GPS, 95% of horizontal GPS positions will be within 10 metres of their true location. The error in altitude will probably be at least twice the horizontal error.
The accuracy of a GPS can be improved by using secondary data from external reference stations. (数据补偿)
Many consumer GPS units have a WAAS option. WAAS uses a network of ground-based reference stations. Readings from the reference stations are used to correct for some of the sources of error mentioned above. The correction data is sent to geostationary WAAS satellites which transmit them back to WAAS-enabled GPS receivers to improve position accuracy. WAAS is not available in New Zealand.
Differential Global Positioning System (DGPS) is a similar system. The data from ground reference stations is transmitted to the GPS using longwave radio, FM radio, or even cellphones.
How many satellites are needed for a fix?
You need 3 GPS satellites for a 2D fix (i.e. no height) or 4 satellites for a 3D fix. Typically a GPS will track many more satellites than
A-GPS
Have you noticed how cellphone GPS units get a fix almost immediately. They use Assisted(辅助的) GPS (A-GPS) as a way of improving the time to first fix, or even allowing a fix in conditions where the GPS might not otherwise be able to function.
The A-GPS device will use a data connection (e.g. 3G on a cellphone) to contact an assistance server. The server can supply almanac and ephemeris data so the GPS doesn't have to wait to receive them from the satellites. The server can also send an approximate location derived from cellphone towers(由信号塔的GPS位置推断出手机的大致相对位置), allowing an immediate fix. In some cases the A-GPS device may send incomplete(不完备的) GPS data to the server for processing into a fix.
Once you are out cellphone and WiFi coverage, a cellphone GPS unit has to rely on the satellites to provide the ephemeris & almanac date so, like a standard recreational GPS, it takes 1-2mins to get a fix from a cold start.