introduction - badarabbas.files.wordpress.com€¦  · web viewactivex is a family of related...

92
RESTRICTED INTRODUCTION RESTRICTED 1

Upload: others

Post on 07-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

INTRODUCTION

RESTRICTED1

Page 2: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

1.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.2 GROUND STATION

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

RESTRICTED2

Figure 1.1

Page 3: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 Control2. Zooming Control 1.3 TILT AND PAN CONTROL

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

1. Zero position.2. Horizon3. Back to normal.4. Clockwise rotation.5. Positive tilt6. 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.

RESTRICTED3

Page 4: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.

1.4 ZOOMING CONTROL

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

1. Idle2. Zoom in3. Zoom out4. Stop zoom5. Full zoom in6. Full zoom out7. Zoom in speed8. Zoom out speed9. 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.

RESTRICTED4

Page 5: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.

1.5 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.

RESTRICTED5

Page 6: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

RESTRICTED6

Figure 1.2

Page 7: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

JOYSTICK AND KEYBOARD

RESTRICTED7

Page 8: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 DLLTo 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

RESTRICTED8

Page 9: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 SubIndicates 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. LibIndicates 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. typeData type of the value returned by the function procedure.

2.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

RESTRICTED9

Page 10: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

most PC's. Moreover if joystick is not available or not detected the application still be operated using the keyboard.

2.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.

RESTRICTED10

Page 11: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

CAMERA CONTROL

RESTRICTED11

Page 12: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

3.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().

3.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.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.

3.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.

RESTRICTED12

Page 13: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

3.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.

RESTRICTED13

Figure 3.1

Page 14: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

TRANSMISSION AND RECEPTION VIA LAN

RESTRICTED14

Page 15: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

4.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.

4.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.

RESTRICTED15

Page 16: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.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.

4.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.

RESTRICTED16

Page 17: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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:

RESTRICTED17

Figure 4.1

Page 18: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

TEST OF ZOOMING PROPERTIES OF

CAMERA

RESTRICTED18

Page 19: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

5.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.

5.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.

5.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.

RESTRICTED19

Page 20: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

5.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.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

RESTRICTED20

Figure 5.1

Page 21: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.

5.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:

RESTRICTED21

Page 22: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

TARGET COORDINATE CALCULATION

RESTRICTED22

Page 23: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

6.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 LongitudeThe 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.

RESTRICTED23

Figure 6.1

Page 24: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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) AzimuthAzimuth 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).

6.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.

RESTRICTED24

Figure 6.2

Page 25: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.

6.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

RESTRICTED25

Figure 6.3

Page 26: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 earth1500 15 12° 30' 6.51" N

34° 59' 48.46" W12° 30' 6.51" N34° 59' 48.46" W

1500 75 12° 31' 30.61" N34° 57' 19.2" W

12° 31' 30.76" N34° 57' 18.93" W

15000 15 12° 31' 5.06" N34° 58' 4.56" W

12° 31' 5.06" N34° 58' 4.55" W

15000 75 12° 45' 4.87" N34° 33' 9.15" W

12° 45' 20.2" N34° 32' 41.76" W

150000 75 14° 58' 39.5" N30° 26' 36.34" W

15° 37' 6.72" N29° 12' 23.39" W

Selection:

RESTRICTED26

Page 27: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 <= tan2-1 (Y,X) <= pi). This contrasts with the result of tan -1, which is limited to the interval -pi/2 to pi/2. The function angpi2pi wraps the input angle to lie on the range pi to -Pi. This will be used to make longitude in this range. Normal latitude always range between 180 to -180.

RESTRICTED27

Page 28: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

This will give longitude in radians which is converted into degree minute second format.

RESTRICTED28

Page 29: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

VIDEO

RESTRICTED29

Page 30: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

7.1 INTRODUCTION

In Visual Basic ezvidcap.ocx ActiveX control has been used to display the video on the display. This was downloaded from Internet and once added into the project just displays the video input at the video grabber card. It is freely downloadable from http://i.am/shrinkwrapvb.

7.2 ActiveX TERMENOLOGY

ActiveX is a Microsoft Windows protocol for component integration. Using ActiveX, developers and end users can select application-specific, ActiveX components produced by different vendors and seamlessly integrate them into a complete application solution. ActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model, or COM. Each object-oriented language or environment has an object model that defines certain characteristics of objects in that environment, such as how objects are located, instantiated, or identified. COM defines the object model for all ActiveX objects.Each ActiveX object supports one or more named interfaces. An interface is a logically related collection of methods, properties, and events. Methods are similar to function calls in that they are a request for the object to perform some action. Properties are state variables maintained by the object, such as the color of text, or the name of a file on which the control is acting. Events are notifications that the control forwards back to its client.

7.3 SETTING PROPERTIES

The autosize property of the ezvidcap.ocx control is set to false so that it can be resized to the requirement. If it is set to true it will resize itself to video format size.The StretchPreview property is set to true so that video is deformed to fit in the control’s dimensions. All the available properties, methods and events of this control are described in Appendix F.

RESTRICTED30

Page 31: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDICES

RESTRICTED31

Page 32: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDEX AUSER’S MANUAL

Step 1:The first step is to connect to the server. Fill in the IP address of the server and the port on which it will be listening. Then click the connect button. If the connection is unsuccessful the reason is displayed. The user can retry to connect.

A server must be present before connecting.

Step 2:In case joystick is unplugged or not connected the user is given a choice to use only keyboard. Choose yes if you want to use keyboard only. Choosing no will terminate the application.

RESTRICTED32

Page 33: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Step 3:In “Set Local Height” frame enter the valid local height and select the unit. When finished click Done.Under File menu select the name of the file where target coordinates will be stored along with system time for later reference. If it is not assigned default location will be C:/target.txt.

Step 4:Under Mission menu click start to start the mission. The mission can be stopped at any time by clicking stop from Mission menu.The options in the menu are enabled or disabled to notify that which option is available at a particular time.

Important Consideration:The application is designed for 1024768 resolution or more. It will not run for less resolutions of the monitor.

The available controls during the running of the mission are as under:

RESTRICTED33

Page 34: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Joystick and keyboard controls

Control Joystick KeyboardClockwise Pan Moving Stick Right Right Arrow KeyCounter Clockwise Pan Moving Stick Left Left Arrow KeyStop Pan X-axis in center No Left or Right Arrow KeyPositive Tilt Moving Stick Up Up Arrow KeyNegative Tilt Moving Stick Down Down Arrow KeyStop Tilt Y-axis in center No Up or Down Arrow KeyZero Position Joystick Button 1 Z KeyBack to Normal Joystick Button 3 B KeyHorizon Position -------- H keyZoom In Joystick Button 2 I keyZoom Out Joystick Button 4 O keyFull Zoom In -------- End KeyFull Zoom Out -------- Home KeyStop Zoom Releasing Buttons 2 or 4 Releasing Keys I or OIdle (Zoom) No Zooming Command No Zooming Command

Note: select Zoom in speed and Zoom out speed using listbox in the application. Digital zoom can selected or deselected using the checkbox.

RESTRICTED34

Page 35: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDIX BCOMMUNICATION PROTOCOL

CSUAV CONTROL SIGNAL UAV 1 2 3 4 5 6 7 $CSUAV,X,X,X,X,X,X,X,Field Number1)AUTO PILOT(0=OFF,1=ON)2)ELEVATION(0=NORMAL,1=UP,2=DOWN,3=STAY)3)ROLL(0=NORMAL,1=LEFT,2=RIGHT,3=STAY)4)THROTTLE 1 (0=OFF,1=MIN,2=INCREASE,3=DECREASE,4=MAX)5)THROTTLE 2 (0=OFF,1=MIN,2=INCREASE,3=DECREASE,4=MAX)6)FLASHER(0=ON,1=OFF)7)WING LEVELLER(0=ON,1=OFF)CMUAV CAMERA MOVE UAV 1 2 3 4 5 6$CMUAV,X,X,X,X,X,X1)TILT(0=ZERO,1=HORIZON,2=UP,3=DOWN,4=STAY,5=BACK TO NORMAL)2)PAN(0=ZERO,1=HORIZON,2=LEFT,3=RIGHT,4=STAY,5=BACK TO NORMAL)3)ZOOM(0=IDLE,1=Z00M OUT,2=ZOOM IN, 3=STOP ZOOM, 4=FULL ZOOM IN, 5=FULL ZOOM OUT)4)ZOOM IN SPEED(0 TO 7)5)ZOOM OUT SPEED(0 TO 7)6)DIGITAL ZOOM(0=OFF, 1=ON)

CPUAV CAMERA POSITION UAV 1 2 $CPUAV,XXXX,YYYField Number1)TILT ANGLE2)PAN ANGLECSAUP CONTROL SIGNAL AUTOPILOT

1 2 3 4 5 6 7 8$ CSAUP,X,X,XXXX.XX,YYYY.YY,LLLL.LL,A,XXXX.XX,YYYY.YYField Number1) 0=CONTINUE,1=HOME2) 0=CONTINUE,1=CIRCLE3)LATITUDE4)LONGITUDE5)RADIUS6)0=CONTINUE7)LATITUDE8)LONGITUDE

RESTRICTED35

Page 36: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

SSUAV SENSOR SIGNAL UAV 1 2 3 4 5 6 7 8 9 10

$ SSUAV,XXXX,AAAA,YY.Y,XXXX.X,YY.Y,XX.X,BB.B,XXX.X,YYY.Y,AAA.AField Number1)RPM 12)RPM 23)FUEL4)LASER ALTITUDE5)TILT ANGLE6)BANK ANGLE7)BATTERY8)TEMP 19)TEMP 210)CLIMB RATE

GPRMC - Recommended Minimum Navigation Information 1 2 3 4 5 6 7 8 9 10 11 12$GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,xxxx,x.x,a*hh Field Number: 1) UTC Time 2) Status, V = Navigation receiver warning 3) Latitude 4) N or S 5) Longitude 6) E or W 7) Speed over ground, knots 8) Track made good, degrees true 9) Date, ddmmyy 10) Magnetic Variation, degrees 11) E or W 12) Checksum

GPGGA - GLOBAL POSITIONING SYSTEM FIX DATA Time, Position and fix related data for a GPS receiver.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $GPGGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh

Field Number: 1) Universal Time Coordinated (UTC) 2) Latitude 3) N or S (North or South) 4) Longitude 5) E or W (East or West)

RESTRICTED36

Page 37: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

6) GPS Quality Indicator, 0 - fix not available, 1 - GPS fix, 2 - Differential GPS fix 7) Number of satellites in view, 00 - 12 8) Horizontal Dilution of precision 9) Antenna Altitude above/below mean-sea-level (geoid) 10) Units of antenna altitude, meters 11) Geoidal separation, the difference between the WGS-84 earth ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid 12) Units of geoidal separation, meters 13) Age of differential GPS data, time in seconds since last SC104 type 1 or 9 update, null field when DGPS is not used 14) Differential reference station ID, 0000-1023 15) Checksum

RESTRICTED37

Page 38: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDIX CCODE OF MAIN PROGRAM

Module joykey:

Option Explicit

‘ This declares function to get the Keyboard state using

‘ user32.dll

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

Public Const KEY_DOWN As Integer = &H1000

‘ This defines for joystick.Public Const MAXPNAMELEN = 32

' The JOYINFOEX user-defined type contains extended ‘information about the joystick position,point-of-view ‘position, and button state.Type JOYINFOEX dwSize As Long ' size of structure dwFlags As Long ' flags to indicate what to return dwXpos As Long ' x position dwYpos As Long ' y position dwZpos As Long ' z position dwRpos As Long ' rudder/4th axis position dwUpos As Long ' 5th axis position dwVpos As Long ' 6th axis position dwButtons As Long ' button states dwButtonNumber As Long ' current button number pressed dwPOV As Long ' point of view state dwReserved1 As Long ' reserved for communication ‘between winmm driver dwReserved2 As Long ' reserved for future expansionEnd Type

' The JOYCAPS user-defined type contains information about ‘the joystick capabilitiesType JOYCAPS wMid As Integer ' Manufacturer dentifier of the device ‘driver for the MIDI output device. wPid As Integer ' Product Identifier Product of the ‘ MIDI output device.

RESTRICTED38

Page 39: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

szPname As String * MAXPNAMELEN ' Null-terminated ‘string containing the

‘ joystick product name wXmin As Long ' Minimum X-coordinate. wXmax As Long ' Maximum X-coordinate. wYmin As Long ' Minimum Y-coordinate wYmax As Long ' Maximum Y-coordinate wZmin As Long ' Minimum Z-coordinate wZmax As Long ' Maximum Z-coordinate wNumButtons As Long ' Number of joystick buttons wPeriodMin As Long ' Smallest polling frequency ‘supported. wPeriodMax As Long ' Largest polling frequency ‘supported. wRmin As L ' Minimum rudder value. wRmax As Long ' Maximum rudder value. ‘The rudder is a fourth axis of movement. wUmin As Long ‘Minimum u-coordinate values. wUmax As Long ' Maximum u-coordinate values. wVmin As Long ' Minimum v-coordinate values. wVmax As Long ' Maximum v-coordinate values. wCaps As Long ' Joystick capabilities as defined‘ by the following flags JOYCAPS_HASZ- Joystick has z-‘ coordinate information.' JOYCAPS_HASR- Joystick has rudder (fourth axis) ‘information.JOYCAPS_HASU- Joystick has u-coordinate ‘(fifth axis) information.JOYCAPS_HASV- Joystick has v-‘coordinate (sixth axis) information.JOYCAPS_HASPOV- ‘Joystick has point-of-view information.JOYCAPS_POV4DIR- ‘Joystick point-of-view supports discrete values (centered, ‘forward, backward, left, and right). JOYCAPS_POVCTS ‘Joystick point-of-view supports continuous degree ‘bearings. wMaxAxes As Long ' Maximum number of axes supported ‘ by the joystick. wNumAxes As Long ' Number of axes currently in use by ‘ the joystick. wMaxButtons As Long ‘ Maximum number of buttons ‘ supported by the joystick. szRegKey As String * MAXPNAMELEN ' String containing ‘the registry key for the joystick.End Type

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

RESTRICTED39

Page 40: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

' This function queries a joystick for its position and ‘button status. The function requires the following ‘parameters;'uJoyID- integer identifying the joystick to be queried. ‘Use the constants JOYSTICKID1 or JOYSTICKID2 for this ‘value. pji- user-defined type variable that stores ‘extended position information and button status of the ‘joystick. The information returned from this function ,depends on the flags you specify in dwFlags member of ‘the user-defined type variable.

' The function returns the constant JOYERR_NOERROR if ‘successful or one of the following error values:'MMSYSERR_NODRIVER- The joystick driver is not ‘present. MMSYSERR_INVALPARAM- An invalid parameter was ‘passed. MMSYSERR_BADDEVICEID- The specified joystick ‘identifier is invalid. JOYERR_UNPLUGGED-The specified ‘joystick is not connected to the system.

Declare Function joyGetDevCaps Lib "winmm.dll" Alias "joyGetDevCapsA" (ByVal id As Long, lpCaps As JOYCAPS, ByVal uSize As Long) As Long' This function queries a joystick to determine its ,capabilities. The function requires the following ‘parameters:' uJoyID- integer identifying the joystick to be ‘queried. Use the contstants. JOYSTICKID1 or JOYSTICKID2 ‘for this value. pjc- user-defined type variable that ‘stores the capabilities of the joystick. cbjc- Size, in ‘bytes, of the pjc variable. Use the Len ‘function for this ‘value. The function returns the constant JOYERR_NOERROR if ‘a joystick is present or one of the following error ‘values:' MMSYSERR_NODRIVER- The joystick driver is not present.' MMSYSERR_INVALPARAM- An invalid parameter was passed.

Public Const JOYSTICKID1 = 0Public Const JOYSTICKID2 = 1Public Const JOY_RETURNBUTTONS = &H80&Public Const JOY_RETURNCENTERED = &H400&Public Const JOY_RETURNPOV = &H40&Public Const JOY_RETURNR = &H8&Public Const JOY_RETURNU = &H10Public Const JOY_RETURNV = &H20Public Const JOY_RETURNX = &H1&Public Const JOY_RETURNY = &H2&

RESTRICTED40

Page 41: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Public Const JOY_RETURNZ = &H4&Public Const JOY_RETURNALL = (JOY_RETURNX Or JOY_RETURNY Or JOY_RETURNZ Or JOY_RETURNR Or JOY_RETURNU Or JOY_RETURNV Or JOY_RETURNPOV Or JOY_RETURNBUTTONS)Public Const JOYCAPS_HASZ = &H1&Public Const JOYCAPS_HASR = &H2&Public Const JOYCAPS_HASU = &H4&Public Const JOYCAPS_HASV = &H8&Public Const JOYCAPS_HASPOV = &H10&Public Const JOYCAPS_POV4DIR = &H20&Public Const JOYCAPS_POVCTS = &H40&Public Const JOYERR_BASE = 160Public Const JOYERR_UNPLUGGED = (JOYERR_BASE + 7)

Module targetfunct:

' This module defines all the function that will be needed' to calculate target coordinate.

Option ExplicitPublic Const Pi As Double = 3.14159265358979Public Const Radius_earth As Double = 6371000 'Radius of

'earth in meteres.

Function Radians(latg As String, direction As String) As Double' This function takes the GPS string of latitude or ‘ longitude and its direction and convert it into radians.

Dim deg As DoubleDim min As DoubleDim degrees As Double ' In case of latitude first 2 digits represents the ' degrees and for latitude 3 digits represent degrees. ' This block separates degrees and minutes from the ' string and convert it into radians. Select Case direction Case "N", "S" deg = Mid(latg, 1, 2) min = Mid(latg, 3) degrees = deg + min / 60 Radians = degrees * Pi / 180 Case "E", "W" deg = Mid(latg, 1, 3) min = Mid(latg, 4)

RESTRICTED41

Page 42: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

degrees = deg + min / 60 Radians = degrees * Pi / 180 End Select ' In case of South latitude or West longitude the ' angle is assumed to be negative. Select Case direction Case "S", "W" Radians = -Radians End Select End Function

Function Angpi2pi(angle As Double) As Double' This function wraps the input angle to lie on the range' pi to -Pi. This will be used to make longitude in this' range. Normal latitude always range between 180 to -180.

Dim temp1 As DoubleDim temp2 As Doubletemp1 = Abs(angle) / Pitemp2 = 2 * Int((temp1 + 1) / 2)Angpi2pi = Pi * (temp1 - temp2) * Sgn(angle)End Function

Function Asin(R As Double) As Double' This function calculates the arc sin of the input angle.If R = 1 Then Asin = Pi / 2ElseIf R = -1 Then Asin = -Pi / 2Else Asin = Atn(R / Sqr(-R * R + 1))End If End FunctionFunction Atan2(y As Double, x As Double) As Double' This function returns the four quadrant arctangent of the' elements X and Y(-pi <= ATAN2(Y,X) <= pi). This contrasts' with the result of ATn which is limited to the interval' -pi/2 to pi/2. This will be used in longitude calculation

Dim i As IntegerDim j As IntegerDim temp As Double

i = Sgn(x)

RESTRICTED42

Page 43: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

j = Sgn(y)

' if point is on y-axis.If i = 0 Then If j = 1 Then Atan2 = Pi / 2 Exit Function ElseIf j = -1 Then Atan2 = -Pi / 2 Exit Function ElseIf j = 0 Then Atan2 = 0 Exit Function End IfEnd If

' If point is on x-axis.If j = 0 Then If i = 1 Then Atan2 = 0 Exit Function ElseIf i = -1 Then Atan2 = Pi Exit Function End IfEnd If

temp = Atn(Abs(y) / Abs(x))

If i = 1 Then If j = 1 Then ' First Quadrant. Atan2 = temp ElseIf j = -1 Then Atan2 = -temp ' Fourth Quadrant. End IfEnd If

If i = -1 Then If j = 1 Then ' Second Quadrant. Atan2 = Pi - temp ElseIf j = -1 Then ' Third Quadrant Atan2 = -Pi + temp End IfEnd If

End Function

RESTRICTED43

Page 44: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Function LatLong(angle As Double, description As String) As String' This function returns the string representation given the' input angle in radians, for display purposes. Second ' argument is description which should be "lat" or "long" ' to indicate whether we want to display latitude or ‘ longitude.

Dim deg As IntegerDim min As IntegerDim sec As SingleDim i As IntegerDim degrees As DoubleDim temp1 As DoubleDim temp2 As DoubleDim direction As String

degrees = angle * 180 / Pitemp1 = Abs(degrees)deg = Int(temp1)temp2 = 60 * (temp1 - deg)min = Int(temp2)sec = Format(60 * (temp2 - min), "0.00")

i = Sgn(angle)

' In case of latitude N or S is appended in display.Select Case descriptionCase "lat" If i = 1 Then direction = "N" ElseIf i = -1 Then direction = "S" Else LatLong = 0 Exit Function End If

' In case of longitude E or W is appended in display.Case "long" If i = 1 Then direction = "E" ElseIf i = -1 Then direction = "W" Else LatLong = 0

RESTRICTED44

Page 45: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Exit Function End IfEnd Select

LatLong = deg & Chr(176) & " " & min & "' " & sec & """ " & direction

End Function

Function Gps2string(LatLong As String, direction As String) As String' This function displays the string representation of the' received GPS data.

Dim degs As Integer Dim mins As Integer Dim secs As Double Select Case direction Case "N", "S" degs = Mid(LatLong, 1, 2) mins = Mid(LatLong, 3, 2) secs = Format(Mid(LatLong, 5) * 60, "0.00") Case "E", "W" degs = Mid(LatLong, 1, 3) mins = Mid(LatLong, 4, 2) secs = Format(Mid(LatLong, 6) * 60, "0.00") End Select Gps2string = degs & Chr(176) & " " & mins & "' " & secs & """ " & direction End Function

Function CurveDisAngle(tilt As Double, height As Double)' This function calculates the distance angle taking' curvature of earth into account.Dim temp1 As DoubleDim temp2 As Double

temp1 = Abs(tilt / 180 * Pi) temp2 = (Radius_earth + height) / Radius_earth * Sin(temp1) CurveDisAngle = Asin(temp2) - temp1 End Function

RESTRICTED45

Page 46: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Function CalcLat(lat As Double, dist As Double, azmth As Double) As String' This function calculate the latitude of the target' location.Dim temp1 As DoubleDim temp2 As DoubleDim newlat As Double

temp1 = Sin(lat) * Cos(dist) temp2 = Cos(lat) * Sin(dist) * Cos(azmth) newlat = Asin(temp1 + temp2) CalcLat = LatLong(newlat, "lat") End FunctionFunction CalcLong(lat As Double, lng As Double, dist As Double, azmth As Double) As String' This function calculate the longitude of the target' location.Dim temp1 As DoubleDim temp2 As DoubleDim temp3 As DoubleDim temp4 As DoubleDim newlong As Double

temp1 = Sin(dist) * Sin(azmth) temp2 = Cos(lat) * Cos(dist) temp3 = Sin(lat) * Sin(dist) * Cos(dist) temp4 = lng + Atan2(temp1, temp2 - temp3) newlong = Angpi2pi(temp4) CalcLong = LatLong(newlong, "long") End Function

Module receive:‘ This module declares the global variables which will be ‘ use in various calculation and be accessed from various‘ forms. Option ExplicitGlobal present_lat As StringGlobal present_long As StringGlobal present_azimuth As DoubleGlobal lat_dir As StringGlobal long_dir As StringGlobal present_asml As DoubleGlobal tilt_angle As DoubleGlobal pan_angle As Double

RESTRICTED46

Page 47: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Function GetToken(ByVal strVal As String, intIndex As Integer, strDelimiter As String) As String'---------------------------------------------------------- ' ' Returns : [string] "Token" (section of data) from a ‘list of delimited string data ' Requires : [string] delimited data, '[integer] index of desired section, '[string] delimiter (1 or more chars) ' ' Examples : GetToken("[email protected]", 2, "@") ‘ returns "hotmail 'GetToken("123-45-6789", 2, "-") returns "45" 'GetToken("first,middle,last", 3, ",") returns "last" ''---------------------------------------------------------

Dim strSubString() As String Dim intIndex2 As Integer Dim i As Integer Dim intDelimitLen As Integer intIndex2 = 1 i = 0 intDelimitLen = Len(strDelimiter) Do While intIndex2 > 0 ReDim Preserve strSubString(i + 1) intIndex2 = InStr(1, strVal, strDelimiter) If intIndex2 > 0 Then strSubString(i) = Mid(strVal, 1, (intIndex2 - 1)) strVal = Mid(strVal, (intIndex2 + intDelimitLen), Len(strVal)) Else strSubString(i) = strVal End If i = i + 1 Loop If intIndex > (i + 1) Or intIndex < 1 Then GetToken = "" Else GetToken = strSubString(intIndex - 1) End IfEnd Function

RESTRICTED47

Page 48: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Module Procedure:

‘ This module checks the status of joystick and loads an‘ appropriate form.

Option Explicit

Dim ji As JOYINFOEX ' joystick state bufferDim caps As JOYCAPS ' joystick capabilitiesDim rc As Long ' return code

Public Sub MainProcedure() ' Get capabilities of joystick1 rc = joyGetDevCaps(JOYSTICKID1, caps, Len(caps)) If (rc <> 0) Then frmStatus.lblStatus.Caption = "Couldn't detect the joystick." frmStatus.Show End If ' Initialize struct ji.dwSize = Len(ji) ji.dwFlags = JOY_RETURNALL ' Get the current joystick data rc = joyGetPosEx(JOYSTICKID1, ji) ' Display the status If (rc = 0) Then frmCamera.Timer1 = True frmCamera.Show ElseIf (rc = JOYERR_UNPLUGGED) Then frmStatus.lblStatus.Caption = "Joystick is unplugged." frmStatus.Show Else frmStatus.lblStatus.Caption = "Unable to find or connect joystick." frmStatus.Show End IfEnd Sub

Form frmConnect:

Option ExplicitDim strdata As String

RESTRICTED48

Page 49: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Dim id As StringDim status As String

Private Sub Form_Load()cmbOption.ListIndex = 0 ' Display meter as unit for ‘ height.End Sub

Private Sub cmdConnect_Click()

' The name of the Winsock control is tcpClient.' Note: to specify a remote host, you can use' either the IP address (ex: "121.111.1.1") or' the computer's "friendly" name.

If Not (IsNumeric(txtLocal.Text)) Then GoTo errheighttcpClient.RemoteHost = txtIP.TextIf Not (IsNumeric(txtPort.Text)) Then GoTo err

' Invoke the Connect method to initiate a connection. tcpClient.RemotePort = txtPort.Text tcpClient.Connect Exit Suberr: MsgBox "Port should be a number", vbOKOnly, "ERROR" Exit Suberrheight: MsgBox "Enter a valid height", vbOKOnly, "ERROR"End Sub

Private Sub tcpClient_Connect()‘ If connection is successful Main procedure is calledCall MainProcedureMe.HideEnd Sub

Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)‘ If any data arrives it writes the values in global‘ variables.

On Error Resume NexttcpClient.GetData strdata, vbString If InStr(strdata, "$") Then id = Mid(strdata, 2, 5) Select Case id Case "GPRMC"

RESTRICTED49

Page 50: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

status = GetToken(strdata, 3, ",") If status = "A" Then present_lat = GetToken(strdata, 4, ",") lat_dir = GetToken(strdata, 5, ",") present_long = GetToken(strdata, 6, ",") long_dir = GetToken(strdata, 7, ",") present_azimuth = CDbl(GetToken(strdata, 9, ",")) End If Case "GPGGA" present_lat = GetToken(strdata, 3, ",") lat_dir = GetToken(strdata, 4, ",") present_long = GetToken(strdata, 5, ",") long_dir = GetToken(strdata, 6, ",") present_asml = CDbl(GetToken(strdata, 10, ",")) Case "CPUAV" pan_angle = CDbl(GetToken(strdata, 3, ",")) tilt_angle = CDbl(GetToken(strdata, 2, ",")) pan_angle = CDbl(GetToken(strdata, 3, ",")) Case Else Exit Sub End Select Else Exit Sub End IfEnd Sub

Private Sub tcpClient_Error(ByVal Number As Integer, description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)‘ If conection is naot succesful it displays the reason in‘ a message box. MsgBox description, vbOKOnly, "ERROR" tcpClient.CloseEnd Sub

Private Sub cmdExit_Click()‘ If exit buuton is clicked it ends the application. tcpClient.Close Unload Me EndEnd Sub

Form frmStatus:

RESTRICTED50

Page 51: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Option Explicit’ This form is displayed if the joystick is not detected.Private Sub cmdNo_Click()‘ If user don’t want to use only keyboard the application‘ ends. frmConnect.tcpClient.Close End ' end the applicationEnd Sub

Private Sub cmdYes_Click()‘ If user wants to use only keyboard the application ‘ continues. Me.Hide frmCamera.Show frmCamera.Timer1 = TrueEnd Sub

Private Sub Form_Unload(Cancel As Integer) frmConnect.tcpClient.CloseEnd Sub

Form frmCamera:

Option ExplicitDim ji As JOYINFOEX ' joystick state bufferDim caps As JOYCAPS ' joystick capabilitiesDim rc As Long ' return codeDim local_height As DoubleDim present_agl As DoubleDim temp As DoubleDim dis As DoubleDim azm As DoubleDim plat As DoubleDim plong As DoubleDim code As StringDim zoom As StringDim panc As StringDim tiltc As StringDim zoom_in_speed As StringDim zoom_out_speed As StringDim text_file As StringDim file_write As String

Private Sub Form_Load()

' Sets default zoom speeds to 4.

RESTRICTED51

Page 52: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

cmbZoomIn.ListIndex = 4 cmbZoomOut.ListIndex = 4 ' sets the default unit of heights to meter. cmbUnit.ListIndex = 0 cmbASML.ListIndex = 0 cmbAGL.ListIndex = 0 ' sets the default file for storing target coordinates. text_file = "C:/target.txt" End Sub

Private Sub mnuExit_Click() EndEnd Sub

Private Sub mnuStart_Click()' This starts the mission by enabling the timer and' opens the text file for storing the coordinates.

Timer1.Enabled = True mnuStart.Enabled = False mnuStop.Enabled = True mnuText.Enabled = False mnuExit.Enabled = False Open text_file For Append As #1End Sub

Private Sub mnuStop_Click()' This stops the mission by disabling the timer and' closes the text file.

Timer1.Enabled = False mnuStop.Enabled = False mnuStart.Enabled = True mnuText.Enabled = True mnuExit.Enabled = True Close #1 End Sub

Private Sub cmdDone_Click()' If local height is changed it recalculate in meters.

If Not (IsNumeric(txtLocalHeight.Text)) Then GoTo errheight Call AssignHeight If Not mnuStop.Enabled Then

RESTRICTED52

Page 53: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

mnuStart.Enabled = True End If Exit Suberrheight: txtLocalHeight.Text = "INVALID"End Sub

Private Sub mnuText_Click()' This opens the dialog box for saving the text file.

With cmnDialog .DefaultExt = ".txt" .DialogTitle = "Save Text File As" .Filter = "Text (*.txt)|*.txt" .ShowSave End With ' This assigns the name of text file. text_file = cmnDialog.FileName End Sub

Private Sub txtLocalHeight_KeyPress(KeyAscii As Integer)' On pressing ENTER after entering height, the units combo box' get focus.

If KeyAscii = 13 Then cmbUnit.SetFocus End IfEnd Sub

Private Sub Form_Unload(Cancel As Integer) frmConnect.tcpClient.CloseEnd Sub

Private Sub Timer1_Timer() ' Initialize struct ji.dwSize = Len(ji) ji.dwFlags = JOY_RETURNALL 'Get the current joystick data rc = joyGetPosEx(JOYSTICKID1, ji) If rc = 0 Then Call WriteCode Else

RESTRICTED53

Page 54: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Call KeyJoyCode Call KeyWriteCode End If ' Display time. txtTime.Text = Time ' Display UAV's coordinate txtPreLat.Text = Gps2string(present_lat, lat_dir) txtPreLong.Text = Gps2string(present_long, long_dir) 'Displays tilt and pan angle. lblAngTilt.Caption = tilt_angle lblAngPan.Caption = pan_angle On Error Resume Next ' Calculates present altitude above ground level. present_agl = present_asml - local_height ' Displays the heights according to the selected unit. Select Case cmbASML.List(cmbASML.ListIndex) Case "m" txtASML.Text = Format(present_asml, "0.00") Case "ft" txtASML.Text = Format(present_asml * 3.281, "0.00") End Select Select Case cmbAGL.List(cmbAGL.ListIndex) Case "m" txtAGL.Text = Format(present_agl, "0.00") Case "ft" txtAGL.Text = Format(present_agl * 3.281, "0.00") End Select 'Compute distance and azimuth into radians. dis = CurveDisAngle(tilt_angle, present_agl) temp2 = pan_angle + present_azimuth azm = temp2 * Pi / 180

' Compute present lat and long in radians. plat = Radians(present_lat, lat_dir) plong = Radians(present_long, long_dir) ' Display target coordinates as a string in degrees ' minute second format. lblTgtLat.Caption = CalcLat(plat, dis, azm) lblTgtLong.Caption = CalcLong(plat, plong, dis, azm) ' Assign code for zoom in speed and zoom out speed.

RESTRICTED54

Page 55: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

zoom_in_speed = cmbZoomIn.ListIndex & "," zoom_out_speed = cmbZoomOut.ListIndex & "," ' Write the target coordinates in the file. file_write = txtTime.Text & "," & lblTgtLat.Caption & "," & lblTgtLong.Caption Print #1, file_write ' Code is assigned, displayed in text box. Then it is sent ' via LAN. code = "$CMUAV," & tiltc & panc & zoom & zoom_in_speed & zoom_out_speed & chkDigitalZoom.Value txtCode.Text = code frmConnect.tcpClient.SendData codeEnd Sub

Private Sub WriteCode()

If ji.dwXpos > 36000 Then ' Clockwise pan. imgCCW.Visible = False imgCW.Visible = True imgStopPan.Visible = False lblTltPan.Visible = False panc = "3,"

ElseIf ji.dwXpos < 28000 Then ' Counter clockwise pan. imgCCW.Visible = True imgCW.Visible = False imgStopPan.Visible = False lblTltPan.Visible = False panc = "2,"

Else imgCCW.Visible = False ' Stop pan. imgCW.Visible = False imgStopPan.Visible = True lblTltPan.Visible = False panc = "4," End If

If ji.dwYpos > 36000 Then ' Negative tilt. imgDown.Visible = True imgStopTilt.Visible = False imgUp.Visible = False lblTltPan.Visible = False

RESTRICTED55

Page 56: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 <= 36000 And ji.dwXpos >= 28000) And _ (ji.dwYpos <= 36000 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

RESTRICTED56

Page 57: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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,"

RESTRICTED57

Page 58: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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

RESTRICTED58

Page 59: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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.281End Select

End Sub

RESTRICTED59

Page 60: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

RESTRICTED60

Page 61: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDIX DCODE OF CAMERA TEST PROGRAM

Option ExplicitDim 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) / 2cmbZoomIn.ListIndex = 4cmbZoomOut.ListIndex = 4

' This asigns the address of the camera to 1.ReDim buffer(3)buffer(0) = &H88buffer(1) = &H30buffer(2) = &H1buffer(3) = &HFFMSComm1.Output = buffertxtCode.Text = "88 30 01 FF" & vbCrLf

' This cancels any command being executed and takes control' of the camera.ReDim buffer(4)buffer(0) = &H88buffer(1) = &H1buffer(2) = &H0buffer(3) = &H1buffer(4) = &HFFMSComm1.Output = buffertxtCode.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) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H6buffer(5) = &HFFIf chkZoom.Value = 1 Thenbuffer(4) = &H2

RESTRICTED61

Page 62: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

txtCode.Text = txtCode.Text & "81 01 04 02 FF" & vbCrLfElsebuffer(4) = &H3txtCode.Text = txtCode.Text & "81 01 04 03 FF" & vbCrLfEnd IfMSComm1.Output = buffer

End Sub

Private Sub cmdTeleFull_Click()' This sends the full zoom in command.ReDim buffer(8)buffer(0) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H47buffer(4) = &H7buffer(5) = &H0buffer(6) = &H0buffer(7) = &H0buffer(8) = &HFFMSComm1.Output = buffertxtCode.Text = txtCode.Text & "81 01 04 47 07 00 00 00 FF" & vbCrLfsldZoom.Value = sldZoom.MaxEnd Sub

Private Sub cmdWideFull_Click()' This sends the full zoom out command.ReDim buffer(8)buffer(0) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H47buffer(4) = &H0buffer(5) = &H0buffer(6) = &H0buffer(7) = &H0buffer(8) = &HFFMSComm1.Output = buffertxtCode.Text = txtCode.Text & "81 01 04 47 00 00 00 00 FF" & vbCrLfsldZoom.Value = sldZoom.MinEnd Sub

RESTRICTED62

Page 63: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H7buffer(5) = &HFF

Select Case cmbZoomIn.ListIndex Case 0buffer(4) = &H20 Case 1buffer(4) = &H21 Case 2buffer(4) = &H22 Case 3buffer(4) = &H23 Case 4buffer(4) = &H24 Case 5buffer(4) = &H25 Case 6buffer(4) = &H26 Case 7buffer(4) = &H27End SelectMSComm1.Output = buffertxtCode.Text = txtCode.Text & "81 01 04 07 2" & cmbZoomIn.ListIndex & " FF" & vbCrLfsldZoom.Value = sldZoom.Value + cmbZoomIn.ListIndex + 1End SubPrivate 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) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H7buffer(4) = &H0buffer(5) = &HFFMSComm1.Output = buffer

RESTRICTED63

Page 64: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

txtCode.Text = txtCode.Text & "81 01 04 07 00 FF" & vbCrLfEnd 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) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H7buffer(5) = &HFF

Select Case cmbZoomOut.ListIndex Case 0buffer(4) = &H30 Case 1buffer(4) = &H31 Case 2buffer(4) = &H32 Case 3buffer(4) = &H33 Case 4buffer(4) = &H34 Case 5buffer(4) = &H35 Case 6buffer(4) = &H36 Case 7buffer(4) = &H37End SelectMSComm1.Output = buffertxtCode.Text = txtCode.Text & "81 01 04 07 3" & cmbZoomOut.ListIndex & " FF" & vbCrLfsldZoom.Value = sldZoom.Value - (cmbZoomOut.ListIndex + 1)End SubPrivate 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) = &H81buffer(1) = &H1buffer(2) = &H4buffer(3) = &H7

RESTRICTED64

Page 65: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

buffer(4) = &H0buffer(5) = &HFFMSComm1.Output = buffertxtCode.Text = txtCode.Text & "81 01 04 07 00 FF" & vbCrLfEnd Sub

RESTRICTED65

Page 66: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDIX EMATLAB 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);

RESTRICTED66

Page 67: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

APPENDIX FEZIVIDCAP.OCX INTERFACES

PROPERTIESAbortLeftMouse BooleanSet to True to allow left mouse button to cancel video capture sessionDefault value: True

AutoSize BooleanSet to True to force control to size itself to the video format sizeDefault value: True

BackColor OLE_COLORSets the backcolor of the controlDefault value: &H80000005 (Windows default)

BorderStyle VBCAPBORDERSTYLESSets the border style of the controlDefault value: SingleLine (1)

CancelKey CANCEL_KEYSets a keyboard hotkey which will allow user to cancel a capture session from the keyboardDefault value: KEY_NONE (0)

CaptureFile StringAllows 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 LongSet 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 BooleanSet 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.

RESTRICTED67

Page 68: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Default value: True

DriverIndex DRIVERINDEXESSet 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: <depends on installed hardware>

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: <depends on installed hardware>

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: <depends on installed hardware>

Height SingleReturns or sets the height of the controlNote* this property cannot be changed when AutoSize is set to True.Default value: <depends on video format size>

MakeUserConfirmCapture BooleanIf this member is True, VFW displays a dialog box prompting the user to initiate capture.Default value: True

PercentDropForError LongMaximum 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 LongSets/Returns the frame display rate in preview mode using fps. Valid rates are 1 - 100

RESTRICTED68

Page 69: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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 LongTime limit for capture, in seconds. This parameter is ignored if TimeLimitEnabled is False.Default value: 30

TimeLimitEnabled BooleanIf this member is True, streaming capture stops after the number of seconds in the TimeLimit property has elapsedDefault value: False

UsePreciseCaptureControls BooleanSetting 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 VBCAPBORDERSTYLESSets the border around the video window to NONE or SINGLE_LINE.Note* This border is separate from the control borderDefault value: SINGLE_LINE

Width SingleReturns or sets the width of the controlNote* this property cannot be changed when AutoSize is set to True.Default value: <depends on video format size>

METHODS

About returns:<none>Displays an about box with ezVidCap version and copyright information. Takes no parameters.

AllocCapFile returns: Boolean

RESTRICTED69

Page 70: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

Creates (preallocates) a capture file of a specified size

CaptureAbort returns: Boolean<takes no parameters>Abandons the current capture operation. The capture operation must yield to use this method (set CaptureViaBackgroundThread to True ).

CaptureEnd returns: Boolean<takes no parameters>Stops the current capture operation. The capture operation must yield to use this method (set CaptureViaBackgroundThread to True ).

CaptureVideo returns: Boolean<takes no parameters>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:ErrorMessageStatusMessage

DiskSpace returns: Long<takes no parameters>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: StringReturns 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: StringReturns 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<takes no parameters>Returns the number of installed VFW capture devices in the system (VFW spec allows for up to 9 devices).

RESTRICTED70

Page 71: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

PreciseCaptureStart returns: <none><takes no parameters>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<takes no parameters>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<takes no parameters>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<takes no parameters>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<takes no parameters>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.

RESTRICTED71

Page 72: INTRODUCTION - badarabbas.files.wordpress.com€¦  · Web viewActiveX is a family of related object-oriented technologies that have a common root, called the Component Object Model,

RESTRICTED

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

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

StatusMessageThis 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.

RESTRICTED72