INTRODUCTION



INTRODUCTION

1 INTRODUCTION

The unmanned aerial vehicle system consists of two stations, the ground station and the airborne station. The airborne station is used for ground surveillance. It has a camera fixed on the fuselage, which captures the ground video, which is then displayed on the ground station. The radio controller (used in aero-modeling) controlled the previously developed UAV. Its disadvantage was that it could only be operated on some fixed band of frequency available for aero-modeling. So that system was prone to jamming and UAV was lost once communication from base station was disrupted. So in this project micro controller has been used in the UAV, which will allow to have an auto pilot system. Once communication from base station is disrupted then autopilot will direct the UAV to the base station. Secondly radio controller is not used. Transmitter and receiver can operate on any frequency. There will be very less chance of jamming.

1. GROUND STATION

The ground station will consist of two computers connected through LAN, these are the control station and camera station respectively.

Camera Station:

The camera station receives the information and sends the camera control signals to the control station via LAN. A joystick is connected to control the camera.

Control Station:

Signals to control the UAV are generated with the help of joystick and keyboard. From the information received the GPS and sensor information is passed to the Sky Tracker (Graphical user interface for the complete display of system parameters to the operator). Camera control signals and UAV control signals are sent to the transmitter for onward communication to the UAV.

This project has developed the camera station. The background of this project is as under:

• Earlier fixed camera was used to capture video that has been replaced by tilt pan system.

• As UAV will be used for reconnaissance and surveillance, the coordinates of the location on the ground the camera is aligned have been calculated. It uses GPS data and current camera position.

• Zooming was controlled mechanically by moving zooming button on the camera. It was unreliable, unsafe and insufficient. It demonstrates that it can be controlled digitally.

Either joystick or keyboard or both can control the camera. The camera control signals are sent according to agreed protocol to the control station. The camera control signals can be divided into following two parts.

1. Tilt and Pan Control

2. Zooming Control

2. TILT AND PAN CONTROL

Camera control signals for the tilt and pan movement of the camera are as under:

1. Zero position.

2. Horizon

3. Back to normal.

4. Clockwise rotation.

5. Positive tilt

6. Negative tilt.

7. Counter clockwise rotation.

8. Stay.

Zero Position: On this command the camera will look straight down. For this tilt-angle is at 0o (i.e. the center of two extremes, +90o and –90o) and pan is also at 0o (zero degree is in the direction of the nose of UAV). This command is for both tilt and pan movement of the camera.

Horizon: On this command the camera will be aligned in the direction of the nose of the UAV. This command is also for both tilt and pan movement of the camera.

Clockwise Rotation: On this command the camera will rotate in clockwise direction (0o 90o 180o 270o 0o) in azimuth plane. This command applies to pan movement only.

Counter Clockwise Rotation: This command is same as clockwise rotation except that the direction is counter clockwise (0o 270o 180o 90o 0o).

Positive Tilt: On this command the camera will move in positive direction i.e.(-90, 0, 90) in elevation plane. This applies only to the tilt movement.

Negative Tilt: On this command the camera will move in negative direction i.e.(90, 0, -90) in elevation plane. This applies only to the tilt movement.

Back to Normal: These commands will be given after the Horizon or Zero Position commands, to move the camera at the position at which it was before these commands were executed. This command is both for tilt and pan movement.

Stay: This command will be given to keep the camera at its current position. This command will be given separately for tilt and pan movement to keep camera at its current tilt or pan.

There are two digits in the protocol for the camera. They act independently of each other.

Details are given in Appendix.

3. ZOOMING CONTROL

Camera control signals for zooming property of the camera are as under:

1. Idle

2. Zoom in

3. Zoom out

4. Stop zoom

5. Full zoom in

6. Full zoom out

7. Zoom in speed

8. Zoom out speed

9. Digital zoom

Idle: On this command there will be will be no change in current camera zoom. It will stay at its current zoom level.

Zoom In: On this command camera will start zooming in till the time there is no stop zoom command or it has reached its maximum zoom in level. Zoom in makes the size of the objects in video bigger by using a zooming lens.

Zoom Out: On this command will start zooming out till the time there is no stop zoom command or it has reached it maximum zoom out level. Zoom out makes the size of the objects in video smaller.

Stop Zoom: This command will be given after zoom in or zoom out command to stop zooming.

Full Zoom in: This command will give camera the maximum zoom in that the camera can have.

Full Zoom Out: This command will give camera the maximum zoom out that the camera can have.

Zoom in Speed: This command will specify the speed for zooming in of the camera. This applies to zoom in command. It ranges from 0 to 7.

Zoom out Speed: This command will specify the speed for zooming out of the camera. This applies to zoom out command. It ranges from 0 to 7.

Digital Zoom: This command will turn the digital zoom on or off. Digital zoom increases the picture element size and reduces the resolution.

4. OVERALL BLOCK DIAGRAM

The overall block diagram of the camera station after establishing LAN connection with the control station is shown under. It gives the following parts of the camera control software

1. Joystick and keyboard programming.

2. Camera control.

3. Target coordinate calculation.

4. Transmission and reception via LAN.

5. Video display.

JOYSTICK AND KEYBOARD

2.1 PROGRAMMING THE JOYSTICK

The joystick object has been programmed in Visual Basic. A module has been used to get the different parameters of the joystick. This module uses winmm.dll (Windows Multimedia Dynamic Link Library) to get the parameters of the joystick. By calling procedures in DLLs, the thousands of procedures that form the backbone of the Microsoft Windows operating system, as well as routines written in other languages can be accessed.

DLLs (Dynamic Link Libraries) are an important aspect of Windows. A DLL contains functions that your executable program can call during execution. In other words, a DLL is a library of functions that your program can link with dynamically. Dynamic links are created as needed. When your program needs a function that is not in the executable file, Windows loads the dynamic link library (the DLL), making all of its functions available to the application.

2.2 USING DLL

To declare a DLL procedure, a Declare statement is used in Declarations section of the code window. If the procedure returns a value, the procedure should be declared as a Function otherwise a Sub. Visual Basic provides a broad set of predefined declares in the Win32api.txt file.

Two user-defined types are declared. First type is JOYINFOEX. Some of the useful information stored in a variable of this type is

1. dwXpos As Long

It gives the current x position (pan movement).

2. dwYpos As Long

It gives the current y position (tilt movement).

3. dwButtonNumber As Long

It tells about the current button number pressed.

The other user-defined type is JOYCAPS it contains the information about all the capabilities of the joystick. This is used to check the status of the joystick. It indicates whether joystick is connected or not, and if is not connected what is the reason.

The winmm.dll is called using these declarations:

Declare Function joyGetPosEx Lib "winmm.dll" (ByVal uJoyID As Long, pji As JOYINFOEX) As Long

Declare Function joyGetDevCaps Lib "winmm.dll" Alias "joyGetDevCapsA" (ByVal id As Long, lpCaps As JOYCAPS, ByVal uSize As Long) As Long

Declarations can be divided into following parts:

1. Function or Sub

Indicates that the procedure returns a value that can be used in an expression. If no value is returned use Sub.

2. Name

Required. Any valid procedure name. Note that DLL entry points are case sensitive.

3. Lib

Indicates that a DLL or code resource contains the procedure being declared. The lib clause is required for all declarations.

4. Libname

Name of the DLL or code resource that contains the declared procedure.

5. Alias

Indicates that the procedure being called has another name in the DLL. This is useful when the external procedure name is the same as a keyword. You can also use Alias when a DLL procedure has the same name as a public variable, constant. Alias is also useful if any characters in the DLL procedure name aren't allowed by the DLL naming convention.

6. aliasname

Name of the procedure in the DLL or code resource. If the first character is not a number sign (#), aliasname is the name of the procedure's entry point in the DLL.

7. arglist

List of variables representing argument that are passed to the procedure when it is called.

8. type

Data type of the value returned by the function procedure.

3. KEYBOARD

The keyboard is the primary input device in most applications. The keyboard contains all the functions available on the joystick plus some additional functions. The reason for having keyboard is simple that there is always a keyboard of some type integrated on most PC's. Moreover if joystick is not available or not detected the application still be operated using the keyboard.

4. KEYBOARD PROGRAMMING

In the typical Visual Basic applications KeyPress, KeyDown and KeyUp events for registering user input via the keyboard can be used. This is a very easy approach and works well in most scenarios. But here it is required to have several keys pressed at the same time to perform a given action (such as moving the camera up and clockwise by pressing the up and right arrow keys). Moreover these events are for objects such as forms, textboxes and responds when they have focus. So here API function has been used. The best option is the GetKeyState() API function from user32.dll (Library for user interface routines). It is declared in same module as of joystick:

Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

The one parameter that the function expects is a virtual key-code that represents the key whose state must be checked. These keys are already declared constants in the Visual Basic environment, with the prefix of vbKey[Keyname). The return value from the function is an integer. If bit 1 in the return value is set, then the key checked has been toggled. This is only relevant for keys such as Caps Lock, Scroll Lock and Num Lock. If the fourth bit in the integer is set then the key we are checking has been pressed. Using this knowledge a constant is made to help with this function:

Public Const KEY_DOWN As Integer = &H1000

By using the Boolean AND operator with the return value from a function call and the KEY_DOWN constant it can be checked to see if a given key is pressed.

CAMERA CONTROL

1. CAMERA CONTROL

The camera control signals can be generated simultaneously from the joystick and keyboard. The control signals, to move the camera, are generated if either the status of keyboard or joystick is changed. The priority is given to the joystick input that means if the joystick is giving the signal to move clockwise in azimuth and keyboard to move counter clockwise then the command of the joystick will be executed. Moreover if there is no joystick, software should be able to run using keyboard only. So this have been achieved by defining the subroutines KeyJoyCode(), KeyWriteCode() and WriteCode().

2. EXPLAINING SUBROUTINES

The subroutine KeyJoyCode() generates alternate signals from the keyboard for the tilt and pan movement of the camera which corresponds to the movement of joystick in the x-axis and y-axis. Arrow keys generate all these signals. These signals are positive tilt, negative tilt, stop tilt, clockwise pan, counter clockwise pan and stop pan.

The subroutine KeyWriteCode() defines the signals from the keyboard for various joystick buttons and other signals which are available only on the keyboard. These are signals for zooming and signals that apply to both tilt and pan movement of the camera (horizon, back to normal and zero position).

3. GIVING PRIORITY TO THE JOYSTICK

If the joystick is detected the subroutine WriteCode() is called. This subroutine assures that the command of the joystick gets the priority. It begins by assigning signals for x-axis position and y-axis position of the camera. If the joystick is in the center then the subroutine KeyJoyCode() is called to check whether arrow keys are giving any signals. If the joystick is not in center then the subroutine KeyJoyCode() is not called and any signal from arrow keys is ignored.

Then the subroutine KeyWriteCode() is called to assign any signals from the keyboard. After that the subroutine WriteCode() continues which assigns signals from the joystick. If there is any conflict between the joystick signals and keyboard signals then the joystick gets priority as it is called later and overwrites any conflicting signal from the keyboard.

4. USING KEYBOARD ONLY

If joystick is detected then the subroutine WriteCode() is called which takes care of both joystick state and keyboard state. If joystick is not detected then the subroutines KeyJoyCode() and KeyWriteCode() are called which implements all the signals using only keyboard and assumes that there is no joystick available.

5. BLOCK DIAGRAM

The block diagram for generating the camera control signals is as under:

the availability of the joystick is checked in each cycle. This adds the following features in the application.

• During the running of the application if joystick becomes unavailable, the application continues.

• During the running of the application joystick can be plugged and used.

TRANSMISSION AND RECEPTION VIA LAN

1. NEED OF LAN

The LAN is used to connect the camera station and the control station. The camera station sends the camera control signals to the control station via LAN for transmission to UAV. While control station sends the camera station the GPS and present camera position signals received from the UAV to camera station. The control station acts as a server while the camera station client.

2. SOME TERMINOLOGY

server: Generally refers to a computer on a network that permits other nodes on the LAN to access its resources.

client: A computer ( printer etc.) or software program that requests services from a server.

TCP/IP: TCP/IP is a software-based communications protocol used in networking. It is not a single product. It is a family of protocols that use a similar behavior. Using the term TCP/IP usually refers to one or more protocols within the family, not just TCP and IP. It includes Transmission Control Protocol (TCP), User Datagram Protocol (UDP), Internet Protocol (IP), File Transfer Protocol (FTP), Telnet and many others.

TCP: Transmission Control Protocol (the TCP part of TCP/IP) is a communications protocol that provides reliable transfer of data. It is connection oriented and ensures that the data is transferred correctly.

UDP: User Datagram Protocol (UDP) is a connectionless-oriented protocol. UDP is not very reliable, but it does have specialized purposes.

port: The port is the electrical interface through which physical access is gained to the computer or device. It is the logical entrance and exit through which data traffic flows in to and out of a network (or a printer or other device).

IP address: TCP/IP uses a 32-bit address to identify a machine on a network and the network to which it is attached. The IP address is the set of numbers, such as 127.40.8.72, which uniquely identifies the device. A string name can also be assigned as IP address and is called “friendly name”.

4.3 USING WINSOCK CONTROL

WinSock control in Visual Basic allows to connect to a remote machine and exchange data using either the User Datagram Protocol (UDP) or the Transmission Control Protocol (TCP). Both protocols can be used to create client and server applications. Like the Timer control, the WinSock control doesn't have a visible interface at run time.

A client must know the server computer's name or IP address (RemoteHost property), as well as the port (RemotePort property) on which it will be "listening." Then the Connect method is invoked. While in a server application, a port (LocalPort property) is set on which to listen, and then Listen method invoked. When the client computer requests a connection, the ConnectionRequest event will occur. To complete the connection Accept method is invoked within the ConnectionRequest event.

Once a connection has been made, either computer can send and receive data. To send data, SendData method is invoked. Whenever data is received, the DataArrival event occurs. To transmit data, first the client computer's LocalPort property is set. The server computer then needs only to set the RemoteHost to the Internet address of the client computer, and the RemotePort property to the same port as the client computer's LocalPort property, and invoke the SendData method to begin sending messages. The client computer then uses the GetData method within the DataArrival event to retrieve the sent messages.

4. SELECTING A PROTOCOL

When using the WinSock control, the first consideration is whether to use the TCP or the UDP protocol. TCP was chosen because of its following advantages.

• The TCP protocol requires an explicit connection before sending or receiving data. While UDP is connectionless protocol and does not require acknowledgement from the server or client when data is sent or received.TCP is analogous to a telephone — the user must establish a connection before proceeding.

• The TCP protocol maintains the connection and ensures the integrity of the data. This connection, however, uses more computing resources.

UDP can be used in this application but has not been used due to the above reasons.

5. IMPLEMENTING THE LAN

In this application the camera station acts as a client. TCP protocol was selected at design time by using Properties window, clicking Protocol and selecting sckTCPProtocol.

Creating a Client:

Camera station acts as a client. There must be server i.e. control station present waiting for camera station to connect otherwise it will not connect. A form loads at the startup to fill the server computer's name or IP address (RemoteHost property), as well as the port (RemotePort property) on which it will be "listening." Then the Connect method is invoked.

Checking Connection:

If the connection is successful, the Connect event occurs. In this case MainProcedure is called to check the status of the joystick and act accordingly.

If the connection is not successful the Error event occurs. The following code in this event gives a message box indicating the reason. The user then can reenter the values and try to connect again.

Receiving Data:

When any new data arrives, the DataArrival event occurs. The GetData method is invoked to get this data in a string variable. Then this data is broken to assign various needed variables.

Transmitting Data:

To transmit the camera control signals to the control station via LAN the SendData is invoked.

4.6 BLOCK DIAGRAM

The block diagram for implementation of LAN is as under:

TEST OF ZOOMING PROPERTIES OF CAMERA

1. INTRODUCTION

The UAV uses a FCB-IX 47P camera for ground surveillance developed by Sony Corporation. Using the software developed by Sony, we can change the various properties of the camera. It uses RS-232 connection and follows VISCA protocol. The VISCA is a protocol that controls consumers camcorders developed by Sony. The command that can be used will differ for each product.

2. NEED FOR TEST

The need for test arises due to following reasons.

• The software supplied by the Sony needs a direct RS-232 link. Whereas in our case the camera will be in UAV and there will be no direct link.

• To demonstrate that camera can be controlled by any software that follows VISCA protocol.

• To develop a protocol based on these observations that requires a minimum transmission between ground station and airborne station and according to our needs.

• Finally applying the same logic, embed the software in the micro controller of the UAV to control zooming properties of the camera according to the received protocol.

3. OUTLINE OF VISCA

In the VISCA, the device generating commands such as computer is called the controller, while the receiver of the commands is called peripheral device. In this case the FCB IX 47P serves as peripheral device. In VISCA, up to 7 peripheral devices can be connected to one controller using communication conforming to RS-232C. The parameters of RS-232C are as follows:

• Communication speed : 9600 bps

• Data bits : 8

• Start bit : 1

• Stop bit : 1

• Non parity

• MSB first

The devices on the network are assigned addresses. The address of the controller is fixed at 0. The addresses of the peripheral devices are 1,2,3 in order from the one nearest to the controller. The address of the peripheral devices is set by sending address commands during the initialization of the network.

4. VISCA PACKET STRUCTURE

The basic unit of VISCA communication is called packet. The first byte of the packet is called header and comprises of the sender’s and receivers addresses. For example the, the header of the packet sent to the FCB camera of address 1 from the controller of address 0 is hexadecimal 81H. The packet sent to the FCB camera of address 2 is 82H. When the terminator is FFH, it signifies the end of the packet.

5. USING MSCOMM CONTROL

The MSComm control provides serial communications by allowing the transmission and reception of data through a serial port. Each MSComm control corresponds to one serial port. If it is needed to access more than one serial port in the application, then more than one MS Comm control have to be used. The port address and interrupt address can be changed from the Windows Control Panel.

The first step in using the Communications control is establishing the connection to the serial port. To open a serial port, use the CommPort, Settings, and PortOpen properties.

The first two properties are set at design time using properties window. The CommPort property sets which serial port to open. As the camera was connected to COM1, CommPort property value is set to 1 at design time. If, however, setting this value to a COM port that does not exist for the system on which application is run, an error will be generated.

The Settings property allows specifying the baud rate, parity, and the number of data bits and stopping bits. By default, the baud rate is set at 9600. The parity setting is for data validation. It is set to "N" as no parity is used inVISCA. The data bits setting specify the number of bits that represent a chunk of data. Its value is 8. The stop is set to 1.

Once it is specified which port to open and how data communication is to be handled, the PortOpen property is used to establish the connection. It is a Boolean value, True or False. It is set to true to start serial communication. Setting the value of the PortOpen property to False closes the port and stops communication.

6. TAKING CONTROL OF CAMERA

The form Load event initializes of the network. Output property of MSComm control transmits the command. This property writes a stream of data to the transmit buffer. The control of the camera is taken by sending these two commands.

Address Command:

Address command sets the address of the peripheral device. The address of the controller i.e. computer is fixed at 0. The first command packet sent is 88 30 01 FF. It sets the address of the camera to 1. It is third byte that assigns address of the camera to 1.

IF_CLEAR Command:

The second command packet sent is 88 01 01 FF. It is called IF_CLEAR command in VISCA protocol. It clears the command buffer in the FCB camera and cancels the command being executed. The code of the load event is as under:

TARGET COORDINATE CALCULATION

1. INTRODUCTION

The camera on the UAV is used for ground surveillance. The approximate target coordinates of the location at which camera is pointing is calculated using the GPS and tilt and pan angles of the camera. The basic terms are defined as under:

1) Latitude and Longitude

The position of a point on the surface of the Earth, or any other planet, for that matter, can be specified with two angles, latitude and longitude. These angles can be specified in degrees or radians; however, degrees are far more common in geographic usage.

Latitude is the angle at the center of the planet between the plane of the Equator and a line through the center passing through the surface at the point in question. Latitude is positive in the Northern Hemisphere, reaching a limit of +90° at the North Pole, and negative in the Southern Hemisphere, reaching a limit of -90° at the South Pole. Lines of constant latitude are called parallels.

Longitude is the angle at the center of the planet between two planes passing through the center and perpendicular to the plane of the Equator. The first plane also includes the surface point in question; the second plane contains the Prime Meridian, which currently means it includes the point defined by the Royal Observatory in Greenwich, England. Lines of constant longitude are called meridians. Longitude ranges from 0 at the Prime Meridian passing through Greenwich, England, to +180 toward the east and 0 to -180 toward the west.

2) Azimuth

Azimuth is the angle a line makes with a meridian, taken clockwise from north. Usually azimuth is measured clockwise from north (0 = North, 90 = East, 180 = South 270= West, 360=0=North).

2. RECKONING

The problem is simplified to determine the destination given a starting point, an initial azimuth, and a distance. In the Mapping Toolbox, in MATLAB this process is called reckoning. This Toolbox has a function available reckon for the calculation of latitude and longitude of the destination. This function was converted in Visual Basic for target coordinate calculation. The result was checked in MATLAB also to verify that it has been successfully implemented.

In this figure A is starting point and angle azm is net azimuth. The angle dis is the angle made by the distance at the center of the earth.

Generally all the calculation formulae involving the astronomical coordinates is done in the natural angular units that is radians. First of all the latitude and longitude which is received by GPS is converted into radians. Then net azimuth is calculated by summing the pan angle and azimuth of the UAV.

3. FINDING DISTANCE ANGLE

Altitude above the ground level is calculated by subtracting local height from the altitude above mean sea level (AMSL) that is received from the GPS. It is denoted by h in the figure. Then the angle made by this distance from the earth center is calculated. The angle ( is the tilt angle of the camera. Point O is the center of the earth. Arc AD is on the earth’s surface. R is the radius of the earth. There are two approaches for this.

Plane Earth:

In this case triangle BAC forms a right-angled triangle. The distance AC is calculated by using simple trigonometry. It height h is very less as compared to the radius of the earth then it is same as the distance on earth. The angle ( is calculated by dividing this distance by radius of the earth. The formulae are as under:

Curve Earth:

If curvature of earth is taken into account then the triangle OBD is solved. In this triangle length of OB is R+h and length of OD is R. The angle OBD is (. This situation may give two solutions. The solution which give angle BDO is greater than 90 otherwise it will not touch earth’s surface. The formulae are as under:

Comparison:

In the following table starting point has latitude of 12° 30' N and longitude of 32° 50' E. The net azimuth is 60 degrees. The coordinates of the target location for various heights and tilt angles have been calculated.

|Height (m) |Tilt angle (degrees) |Target Coordinates |

| | |plane earth |Curve earth |

|1500 |15 |12° 30' 6.51" N |12° 30' 6.51" N |

| | |34° 59' 48.46" W |34° 59' 48.46" W |

|1500 |75 |12° 31' 30.61" N |12° 31' 30.76" N |

| | |34° 57' 19.2" W |34° 57' 18.93" W |

|15000 |15 |12° 31' 5.06" N |12° 31' 5.06" N |

| | |34° 58' 4.56" W |34° 58' 4.55" W |

|15000 |75 |12° 45' 4.87" N |12° 45' 20.2" N |

| | |34° 33' 9.15" W |34° 32' 41.76" W |

|150000 |75 |14° 58' 39.5" N |15° 37' 6.72" N |

| | |30° 26' 36.34" W |29° 12' 23.39" W |

Selection:

Although there is not so much difference for small heights, the curvature of the earth is taken into account due to these reasons.

• It gives the accurate results for all values of heights and tilt angles.

• The formulae are not so much complicated as compared to the planer earth approach.

6.4 ALGORITHM

The algorithm is taken from reckon function in Mapping Toolbox, in MATLAB. Its derivation involves spherical trigonometry. In the following formulae lat is latitude of starting location and long is longitude of starting location. The latitude and longitude of target location are newlat and newlong respectively. The angles azm and dis are as shown in Figure 6.2.

Latitude calculation:

Latitude is calculated as under.

This gives latitude in radians, which is converted into degree, minute and second notation.

Longitude calculation:

For longitude calculation these arguments are calculated first.

In the following formulae the function tan2-1 calculates the four quadrant arctangent of the elements X and Y (-pi 36000 Then ' Negative tilt.

imgDown.Visible = True

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = False

tiltc = "3,"

ElseIf ji.dwYpos < 28000 Then ' Positive tilt.

imgDown.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = True

lblTltPan.Visible = False

tiltc = "2,"

Else

imgDown.Visible = False ' Stop tilt.

imgStopTilt.Visible = True

imgUp.Visible = False

lblTltPan.Visible = False

tiltc = "4,"

End If

If (ji.dwXpos = 28000) And _

(ji.dwYpos = 28000) Then

Call KeyJoyCode

End If

Call KeyWriteCode

If ji.dwButtonNumber = 4 Then

lblZoom.Caption = "ZOOM OUT"

zoom = "1,"

ElseIf ji.dwButtonNumber = 2 Then

lblZoom.Caption = "ZOOM IN"

zoom = "2,"

End If

If ji.dwButtonNumber = 1 Then

imgCCW.Visible = False

imgCW.Visible = False

imgDown.Visible = False

imgStopPan.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = True

lblTltPan.Caption = "Zero Position"

tiltc = "0,"

panc = "0,"

ElseIf ji.dwButtonNumber = 3 Then

imgCCW.Visible = False

imgCW.Visible = False

imgDown.Visible = False

imgStopPan.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = True

lblTltPan.Caption = "Back to Normal"

tiltc = "5,"

panc = "5,"

End If

End Sub

Private Sub KeyJoyCode()

' This subroutine defines the signals from the keyboard for ' the tilt and pan movement of the camera which corresponds

' to the movement of joystick in the x-axis and y-axis.

' Arrow keys generate all these signals.

If (GetKeyState(vbKeyRight) And KEY_DOWN) Then

imgCCW.Visible = False

imgCW.Visible = True

imgStopPan.Visible = False

lblTltPan.Visible = False

panc = "3,"

ElseIf (GetKeyState(vbKeyLeft) And KEY_DOWN) Then

imgCCW.Visible = True

imgCW.Visible = False

imgStopPan.Visible = False

lblTltPan.Visible = False

panc = "2,"

Else

imgCCW.Visible = False

imgCW.Visible = False

imgStopPan.Visible = True

lblTltPan.Visible = False

panc = "4,"

End If

If (GetKeyState(vbKeyDown) And KEY_DOWN) Then

imgDown.Visible = True

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = False

tiltc = "3,"

ElseIf (GetKeyState(vbKeyUp) And KEY_DOWN) Then

imgDown.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = True

lblTltPan.Visible = False

tiltc = "2,"

Else

imgDown.Visible = False

imgStopTilt.Visible = True

imgUp.Visible = False

lblTltPan.Visible = False

tiltc = "4,"

End If

End Sub

Private Sub KeyWriteCode()

' This subroutine defines the alternate signals from the

' keyboard for various joystick buttons and other signals

' which are available only on the keyboard.

If (GetKeyState(vbKeyO) And KEY_DOWN) Then

lblZoom.Caption = "ZOOM OUT"

zoom = "1,"

ElseIf (GetKeyState(vbKeyI) And KEY_DOWN) Then

lblZoom.Caption = "ZOOM IN"

zoom = "2,"

ElseIf (GetKeyState(vbKeyEnd) And KEY_DOWN) Then

lblZoom.Caption = "FULL ZOOM IN"

zoom = "4,"

ElseIf (GetKeyState(vbKeyHome) And KEY_DOWN) Then

lblZoom.Caption = "FULL ZOOM OUT"

zoom = "5,"

Else

If (zoom = "1,") Or (zoom = "2,") Then

lblZoom.Caption = "STOP ZOOM"

zoom = "3,"

Else

lblZoom.Caption = "IDLE"

zoom = "0,"

End If

End If

If (GetKeyState(vbKeyH) And KEY_DOWN) Then

imgCCW.Visible = False

imgCW.Visible = False

imgDown.Visible = False

imgStopPan.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = True

lblTltPan.Caption = "Horizon"

tiltc = "1,"

panc = "1,"

ElseIf (GetKeyState(vbKeyZ) And KEY_DOWN) Then

imgCCW.Visible = False

imgCW.Visible = False

imgDown.Visible = False

imgStopPan.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = True

lblTltPan.Caption = "Zero Position"

tiltc = "0,"

panc = "0,"

ElseIf (GetKeyState(vbKeyB) And KEY_DOWN) Then

imgCCW.Visible = False

imgCW.Visible = False

imgDown.Visible = False

imgStopPan.Visible = False

imgStopTilt.Visible = False

imgUp.Visible = False

lblTltPan.Visible = True

lblTltPan.Caption = "Back to Normal"

tiltc = "5,"

panc = "5,"

End If

End Sub

Private Sub AssignHeight()

' This calculates the local height in meter.

Select Case cmbUnit.List(cmbUnit.ListIndex)

Case "m"

local_height = CDbl(txtLocalHeight.Text)

Case "ft"

local_height = CDbl(txtLocalHeight.Text) / 3.281

End Select

End Sub

APPENDIX D

CODE OF CAMERA TEST PROGRAM

Option Explicit

Dim buffer() As Byte

Private Sub Form_Load()

MSComm1.PortOpen = True ' Open the port.

' Sets the slider in center and default zoom speeds to 4.

sldZoom.Value = (sldZoom.Min + sldZoom.Max) / 2

cmbZoomIn.ListIndex = 4

cmbZoomOut.ListIndex = 4

' This asigns the address of the camera to 1.

ReDim buffer(3)

buffer(0) = &H88

buffer(1) = &H30

buffer(2) = &H1

buffer(3) = &HFF

MSComm1.Output = buffer

txtCode.Text = "88 30 01 FF" & vbCrLf

' This cancels any command being executed and takes control

' of the camera.

ReDim buffer(4)

buffer(0) = &H88

buffer(1) = &H1

buffer(2) = &H0

buffer(3) = &H1

buffer(4) = &HFF

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "88 01 01 FF" & vbCrLf

End Sub

Private Sub chkZoom_Click()

' This turns digital zoom on or off.

ReDim buffer(5)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H6

buffer(5) = &HFF

If chkZoom.Value = 1 Then

buffer(4) = &H2

txtCode.Text = txtCode.Text & "81 01 04 02 FF" & vbCrLf

Else

buffer(4) = &H3

txtCode.Text = txtCode.Text & "81 01 04 03 FF" & vbCrLf

End If

MSComm1.Output = buffer

End Sub

Private Sub cmdTeleFull_Click()

' This sends the full zoom in command.

ReDim buffer(8)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H47

buffer(4) = &H7

buffer(5) = &H0

buffer(6) = &H0

buffer(7) = &H0

buffer(8) = &HFF

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 47 07 00 00 00 FF" & vbCrLf

sldZoom.Value = sldZoom.Max

End Sub

Private Sub cmdWideFull_Click()

' This sends the full zoom out command.

ReDim buffer(8)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H47

buffer(4) = &H0

buffer(5) = &H0

buffer(6) = &H0

buffer(7) = &H0

buffer(8) = &HFF

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 47 00 00 00 00 FF" & vbCrLf

sldZoom.Value = sldZoom.Min

End Sub

Private Sub cmdTele_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

' This gives the zoom in command according to the selected

' zoom in speed.

ReDim buffer(5)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H7

buffer(5) = &HFF

Select Case cmbZoomIn.ListIndex

Case 0

buffer(4) = &H20

Case 1

buffer(4) = &H21

Case 2

buffer(4) = &H22

Case 3

buffer(4) = &H23

Case 4

buffer(4) = &H24

Case 5

buffer(4) = &H25

Case 6

buffer(4) = &H26

Case 7

buffer(4) = &H27

End Select

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 07 2" & cmbZoomIn.ListIndex & " FF" & vbCrLf

sldZoom.Value = sldZoom.Value + cmbZoomIn.ListIndex + 1

End Sub

Private Sub cmdTele_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

' This stops the zooming in.

ReDim buffer(5)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H7

buffer(4) = &H0

buffer(5) = &HFF

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 07 00 FF" & vbCrLf

End Sub

Private Sub cmdWide_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

' This gives the zoom out command according to the selected

' zoom out speed.

ReDim buffer(5)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H7

buffer(5) = &HFF

Select Case cmbZoomOut.ListIndex

Case 0

buffer(4) = &H30

Case 1

buffer(4) = &H31

Case 2

buffer(4) = &H32

Case 3

buffer(4) = &H33

Case 4

buffer(4) = &H34

Case 5

buffer(4) = &H35

Case 6

buffer(4) = &H36

Case 7

buffer(4) = &H37

End Select

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 07 3" & cmbZoomOut.ListIndex & " FF" & vbCrLf

sldZoom.Value = sldZoom.Value - (cmbZoomOut.ListIndex + 1)

End Sub

Private Sub cmdWide_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

' This stops the zooming in.

ReDim buffer(5)

buffer(0) = &H81

buffer(1) = &H1

buffer(2) = &H4

buffer(3) = &H7

buffer(4) = &H0

buffer(5) = &HFF

MSComm1.Output = buffer

txtCode.Text = txtCode.Text & "81 01 04 07 00 FF" & vbCrLf

End Sub

APPENDIX E

MATLAB FUNCTION FOR TARGET CALCULATION

function[newlat,newlong] = calculate (lat,long,azimuth, ...

height,tilt,pan)

% This function has the following inputs.

% lat = current latitude in degree, minute second format.

% long = current longitude in degree, minute second format.

% azimuth = current azimuth of the UAV (in degrees).

% height = height above ground level (in meters).

% tilt = tilt angle of the camera (in degrees).

% pan = pan angle of the camera (in degrees).

% It gives the target coordinates in degree, minute and

% second format.

temp1=abs(deg2rad(tilt));

temp2=height*tan(temp1);

rng=distdim(temp2,'meters','radians');

azm=deg2rad(azimuth+pan);

lat1=dms2rad(lat);

long1=dms2rad(long);

[lat2,long2]=reckon(lat1,long1,rng,azm,'radians');

newlat=rad2dms(lat2);

newlong= rad2dms(long2);

APPENDIX F

EZIVIDCAP.OCX INTERFACES

PROPERTIES

AbortLeftMouse Boolean

Set to True to allow left mouse button to cancel video capture session

Default value: True

AutoSize Boolean

Set to True to force control to size itself to the video format size

Default value: True

BackColor OLE_COLOR

Sets the backcolor of the control

Default value: &H80000005 (Windows default)

BorderStyle VBCAPBORDERSTYLES

Sets the border style of the control

Default value: SingleLine (1)

CancelKey CANCEL_KEY

Sets a keyboard hotkey which will allow user to cancel a capture session from the keyboard

Default value: KEY_NONE (0)

CaptureFile String

Allows you to set the location and name of the video capture cache file.

Note* setting this property does not create a file or allocate space. The capture file can be pre-allocated for better performance using the AllocCapFile method. Otherwise this file is created, if necessary, when the capture session begins.

Default value: “C:\Capture.avi”

CaptureRate Long

Set this property to a value between 1 and 100 to request a video capture frame rate from the capture device.

Default value: 15

Capturing Boolean (Read only)

This property indicates whether a capture session is in progress (True)

Default value (when not capturing video): False

CenterVideo Boolean

Set to True to center the video preview window in the control. This property is useful when AutoSize is set to False. Otherwise, it has no effect.

Default value: True

DriverIndex DRIVERINDEXES

Set this to the VFW driver index of the capture device you want to connect to. The NumCapDevs method should be used to determine the number of installed devices on a system. The GetDriverName and GetDriverVersion methods should be used to return info about devices at each index before connecting.

Note* the control will automatically attempt to connect to the VFW default index (0) even if this property is not set.

Default value: VFW_DEFAULT (0)

HasDlgDisplay Boolean (Read Only)

A value of True indicates that the currently connected VFW capture device will display a standard Display Dialog Box to the user when you call the ShowDlgVideoDisplay method. The user can then access and change device specific parameters for this capture device.

Default value:

HasDlgFormat Boolean (Read Only)

A value of True indicates that the currently connected VFW capture device will display a standard Format Dialog Box to the user when you call the ShowDlgVideoFormat method. The user can then access and change device specific parameters for this capture device.

Default value:

HasDlgSource Boolean (Read Only)

A value of True indicates that the currently connected VFW capture device will display a standard Source Dialog Box to the user when you call the ShowDlgVideoSource method. The user can then access and change device specific parameters for this capture device.

Default value:

Height Single

Returns or sets the height of the control

Note* this property cannot be changed when AutoSize is set to True.

Default value:

MakeUserConfirmCapture Boolean

If this member is True, VFW displays a dialog box prompting the user to initiate capture.

Default value: True

PercentDropForError Long

Maximum allowable percentage of dropped frames during capture. Values range from 0 to 100. If the percentage of dropped frames exceeds this value the Error event will be raised.

PreviewRate Long

Sets/Returns the frame display rate in preview mode using fps. Valid rates are 1 - 100

Note* The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another application has the focus. During streaming video capture, the previewing task is lower priority than writing frames to disk, and preview frames are displayed only if no other buffers are available for writing.

Default value: 15

TimeLimit Long

Time limit for capture, in seconds. This parameter is ignored if TimeLimitEnabled is False.

Default value: 30

TimeLimitEnabled Boolean

If this member is True, streaming capture stops after the number of seconds in the TimeLimit property has elapsed

Default value: False

UsePreciseCaptureControls Boolean

Setting this property to True gives the user precise control over the capture start and stop times. After setting this property, when the user calls the CaptureStart method the control will do all necessary preparations before capture, such as allocating memory buffers. After doing this the control will raise the PreRollComplete event and wait for the user to call either the PreciseCaptureStart method , to start capturing, or the PreciseCaptureCancel method. to cancel the capture session. This method is more complicated than simply calling CaptureStart, but it gives the user precise control over the instant that the capture session starts, an it also makes it possible to show a custom user dialog rather than the VFW defined one if desired (see sample application).Note*

Default value: False

VideoBorder VBCAPBORDERSTYLES

Sets the border around the video window to NONE or SINGLE_LINE.

Note* This border is separate from the control border

Default value: SINGLE_LINE

Width Single

Returns or sets the width of the control

Note* this property cannot be changed when AutoSize is set to True.

Default value:

METHODS

About returns:

Displays an about box with ezVidCap version and copyright information. Takes no parameters.

AllocCapFile returns: Boolean

Creates (preallocates) a capture file of a specified size

CaptureAbort returns: Boolean

Abandons the current capture operation. The capture operation must yield to use this method (set CaptureViaBackgroundThread to True ).

CaptureEnd returns: Boolean

Stops the current capture operation. The capture operation must yield to use this method (set CaptureViaBackgroundThread to True ).

CaptureVideo returns: Boolean

Initiates streaming video and audio capture to a file.

By default, the capture control does not allow other applications to continue running during capture. To override this, either set the Yield property to True, or add code to the Yield Event in the client application.

During streaming capture, the capture window will issue notifications to your application of specific types of conditions. The CaptureYield event will be raised at least once per frame captured if the YieldEventEnabled property is set to True. The following events may also be raised during capture if the control is either yielding CPU time or running in a background thread:

ErrorMessage

StatusMessage

DiskSpace returns: Long

Returns free space on drive which contains capture file in bytes.

Allocated capture file size is not counted as used diskspace since it will be overwritten by the control during capture. (for example if there is 10000 bytes free and the capture file size is 5000 bytes, this function will return 15000 bytes).

GetDriverName returns: String

Returns the driver description string for the currently selected VFW driver. Or if optional Index parameter is passed returns information for device located at the VFW index specified.

GetDriverVersion returns: String

Returns version string for the currently selected VFW driver. Or if optional Index parameter is passed returns version string for device located at the VFW index specified.

NumDevCaps returns: Long

Returns the number of installed VFW capture devices in the system (VFW spec allows for up to 9 devices).

PreciseCaptureStart returns:

Capture session will start at the precise moment this method is called when UsePreciseCaptureControls property is set to True. Note* This method will have no effect until the PreRollComplete event is raised.

ShowDlgCompressionOptions returns: Boolean

Displays a dialog box in which the user can select a compressor to use during the capture process. The list of available compressors can vary with the video format selected in the capture driver's Video Format dialog box.

Software compression is only used with capture drivers that provide frames in the BI_RGB format. This message is most useful in the step capture operation to combine capture and compression in a single operation. Compressing frames with a software compressor as part of a real-time capture operation is most likely too time-consuming to perform.

Compression does not affect the frames copied to the clipboard.

ShowDlgVideoDisplay returns: Boolean

Displays a dialog box in which the user can set or adjust the video output. This dialog box might contain controls that affect the hue, contrast, and brightness of the displayed image, as well as key color alignment.

The controls in this dialog box do not affect digitized video data; they affect only the output or redisplay of the video signal.

The Video Display dialog box is unique for each capture driver. Some capture drivers might not support a Video Display dialog box. Applications can determine if the capture driver supports this method by checking the HasDlgDisplay property.

ShowDlgVideoFormat returns: Boolean

Displays a dialog box in which the user can select the video format. The Video Format dialog box might be used to select image dimensions, bit depth, and hardware compression options.

The Video Format dialog box is unique for each capture driver. Some capture drivers might not support a Video Format dialog box. Applications can determine if the capture driver supports this method by checking the HasDlgFormat property.

ShowDlgVideoFormat returns: Boolean

Displays a dialog box in which the user can control the video source. The Video Source dialog box might contain controls that select input sources; alter the hue, contrast, brightness of the image; and modify the video quality before digitizing the images into the frame buffer.

The Video Source dialog box is unique for each capture driver. Some capture drivers might not support a Video Source dialog box. Applications can determine if the capture driver supports this method by checking the HasDlgSource property.

EVENTS

ErrorMessage

This event is raised when the capture window yields during streaming capture.

StatusMessage

This event is raised when VFW sends a status message to the control. Some status messages include both a numeric code and a native VB string, others do not return a description string.

-----------------------

[pic]

[pic]

[pic]

[pic]

Figure 6.1

Figure 6.2

Figure 6.3

Figure 1.1

Figure 1.2

Figure 3.1

Figure 4.1

Figure 5.1

[pic]

[pic]

[pic]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download