Thursday, September 25, 2008

Motor Tripod Part II

The last test was finally a successful one. I still will need to check the distance the wireless connection can work with and the test site I used is not wide enough, just 20m away causes the GPS errors to add up a lot. And the site does not have great visibility to the sky either with trees and hills around. So much about the excuses.

So what is working? Let me show you the video first. I place the GPS receiver next to the tripod and power up both. After a few seconds, the tripod electronic will show on the LCD that it found 6 or 7 satellites so you can be sure the position to be accurate. You press "5" on the keyboard and the tripod will store this position as its own.
Next I placed the GPS receiver 15m away so the controller can lock on the remote position. Back at the tripod I then use the keyboard to pan/tilt the video head until the camera looks straight at the position where the GPS receiver is lying on the ground. And that is where the video starts...

As said, I will post another video when I have the chance to test it on open ground.

The program consists basically of two phases. One is where all the setup takes place and the tripod position is locked in. And the second phase is the tracking mode with the option to manually control the head to maintain the offsets.

In the first phase the controller will carefully print its current state onto the LCD. Did it receive any serial data yet? Did it receive a valid GPS sentence? Does the GPS sentence tell that we have a satellite fix? And finally, if all is true it will tell you can press "5" at any time and start printing the number of satellites we have in view.
In order to get a serial connection via the XBee modules, they need to be programmed first. So I had to by a prototype board with which you can connect the XBee to the USB port of the computer and using a terminal emulation (Windows Hyperterminal) you can bring the module in the programming state by typing "+++" with two seconds lead and lag time where no data is sent. Then using some commands like "ATDL0202" you can tell it to which module it should send the data to - the one with the number 0x0202, what its own address is and save all of that into the XBee memory. To simplify that task for you, when no serial data is received you can press "1" or "2" to program either the local or the remote module. It does not matter which one is what, all I do is in "1" I set the XBee module address to one value and the the remote to another, when you press "2" I do the same but now the former remote address is the local. So all you have to do is insert the first XBee module, power up the controller, wait until it says "no data received, press 1 or 2" and then you press "1". Power down the controller, remove the XBee and place it into the socket of the GPS receiver. And the other XBee is now placed into the controller and programmed with "2". From now on you have a transparent serial connection between those two XBee's and when the GPS receiver is turned on, data should be received.

Once the local position is locked in, the controller goes into the second phase, the locking and aligning. To avoid erratic movement, the tracking is only done if the GPS module is more that 10m away. The first time the tracking starts, the current video head position is used as reference zero point. So at first, the head will not move at all and then start following you. If you walked away along where the camera looked to, the position would be correct already. But very likely it is off by a bid. So you place the GPS receiver somewhere remote and leave it there, then you walk back to the tripod and using the keys "4"-"6" and "2"-"8" you can move the zero-point until the camera looks directly at the GPS device. And from now on, the camera should keep the GPS always in the same position of the viewfinder - more or less.

Another option to provide a GPS position is to manually type it in. This is only useful if no GPS data is received at that time! For example, I might not trust the home position, I want the enter it by myself. So I power up the tripod but leave the GPS unit off. At any time you can press the "#" button and then using the keyboard enter the coordinates manually. At first, you type the digits for the latitude in the format 50° 20.2342N. So you just type the number sequence 5-0-2-0-2-3-4-2-2, the last "2" stands for north. Then the latitude 004° 43.2341E and finally the height in meter 000123. This manual entry is interpreted as a first valid GPS sentence, so you can press "5" to lock it in.
More important, instead of placing the GPS unit somewhere remote and then adjust the camera to it, you can switch it off then and manually enter the coords of any landmark in view. This will be used as the remote position and using the keyboard you then turn the head towards this location to zero it in. Turn on the GPS device again and as soon you are 10m away the head will look straight to you.
This feature was particularily cool during testing and calibrating the code. Sitting at the computer, entered the GPS position taken from google earth and the head started to move.

Another feature built in is to freeze the height. This is particularily useful if the camera and the object is on the same level the entire time anyway - Windsurfing, yes? - or like in my testing the GPS is close and does not have a good fix. In this case the height information keeps wandering by 10m within minutes.

Another change I made recently was to implement servo speed. Before, the GPS did send a new position every second. As a result, the head did jump to the new angle and then remained there for the reminder of the second to jump by another degree then. The result was no smooth movement, not at all. What I do now is calculating the degrees to be moved, divide that by one second and that is the rotation speed. So we are up to one second behind the actual position but that is good enough. Some fine tuning will be in order later.

The one step that is still missing is programming the GPS. By default it sends different GPS sentences, more than we are interested in. The XBee has a buffer of 100 characters which are sent at once and one GPS position sentence fits perfectly into that. So even without flowcontrol, we have a very reliable connection. Would we send more data every second, much more sentences would be lost. So I told the GPS I am interested in the GPGGA sentences only. The other thing, by default the SIRF chip is set to static movement and track smoothing, both good for higher speed movements but not for walking - so I disabled both. To do that you have to send a command to the GPS bringing it into binary mode where no ASCII data istransferred but binary data and then you can set those advanced options. Found that too dangerous to try via the XBee so I rather used a tool called SIRFdemo. But for this the GPS has to be connected to the computer directly or you have to make sure the binary mode is using 9600Baud as well. The first time I did that wrong and the result was the XBee couldn't talk to the GPS anymore due to different baud rates. So I had to program both XBees to 57kbit rate, then bring the GPS back into ASCII mode at 9600baud and reprogram the XBees again.
Post a Comment