DAVID4 SDK
1.8.7
|
The DAVID4 SDK allows you to write own software programs that use the DAVID functionality, e.g. for batch scanning, bin picking, quality inspection, etc.
There are two modes how to use the SDK: DLL Mode and Client/Server Mode. Both use the same interface, so it's easy for you to switch.
A DLL is a usual way to include software libraries into your own software: We supply header files and a DLL, and you include/link them into your project. The DLL has a low-level C API, but we recommend to use our C++ wrapper classes, which are included in our SDK package.
Your client program remotely controls one or several DAVID4 servers. This concept is illustrated in this figure:
Each DAVID server is a DAVID4 Enterprise Edition software instance, running on a Windows PC and started in server mode. It is usually invisible, but can be made visible via its Systray icon or by a command from the client.
The user application (client) is connected to the DAVID servers via TCP/IP connections. But don't worry, connection handling is mostly hidden within the DAVID SDK. This way, you can remote control several DAVID servers from one client at once. The DAVID servers can be located on the same machine as the client (local host) or on different machines that are connected over network. The client can run on any operating system with TCP support. There is a low-level JsonRpc interface you can access, but the easiest way is to use our C++ wrapper which is included in our SDK package.
Before we go into details within the next sections, let's have a look at a simple example.
This is a completely working example including simple error handling. It makes several scans from different views, fuses them, and exports the fusion result as 'FusionResult.stl'. The single include
at the beginning is the only include you need. It will give you access to all important DAVID SDK functions and classes. The most important class is david::Client. It stores all information about the connection between exactly one client and one server. In
a client instance is generated and a connection between our application client and a running DAVID server is established using 'localhost' at a DAVID standard port. You always need a reference to this client instance in order to get access to the module interfaces. See david.h to switch to DLL Mode.
By
an interface to the david::StructuredLightScanner module is requested so you can e.g. make a new scan:
This new scan is then copied to the david::ShapeFusion module via the function call
It returns a mesh ID so you can do some operations on this mesh. In this case, we want to rotate our new scan so that all scans are correctly aligned within the same coordinate systems:
The function call
tells the turntable to rotate by 'angle' degrees.
After finishing all scans, we fuse all scans with resolution "1000" by
Here again, we get a mesh ID. In this case, we use it to export the fusion result as a STL file:
A client connects to a running server. This server is an instance of the DAVID4 Enterprise software started with the parameter "server":
On 32-bit systems, use:
Example:
DAVID will now use the ports 10600 and 10601. Do not forget to use this port in your client code, too.
You can also start a server on your local machine with the API function david::Client::StartServer:
Alternatively, you can run the included Start_DAVID_SDK_Server_xxx.bat, which starts DAVID in Server Mode with the default port.
david::Client: Handles connection between client and server, initializes library, and gives you access to all module interfaces.
david::IStructuredLightScanner: Interface to the 'Structured Light Scanning' module.
david::IShapeFusion: Interface to the 'Shape Fusion' module.
david::ITurntable: Interface to the 'Turntable' module.
david::IMeasure: Interface to the 'Measurement' module.
david::IMainWindow: Interface to the 'Main Window' module.
david: The standard namespace for most users.
examples: Here you can find source code examples separated from the normal code.
david::jsonrpc: The low level network code and TCP/IP communication protocol is located within this namespace. Only look here, if you want to implement remote functions on a specific platform that is not directly supported by our standard C++ API.
The high level error handling in DAVID SDK is via C++ exceptions. This allows the user to separate normal control flow from error control flow, thus making the programs much more readable. The basic concept is that at low level DAVID generates old school error codes (david::ErrorCode) that are packed into different categories of exceptions:
All DAVID exceptions are inherited from david::Exception. Therefore, you can simply catch all DAVID exceptions by
In many cases you expect the connection between client and server to work correctly. And you might be only interested in the error codes provided by function itself, ignoring all connection stuff like david::Error_ConnectionLost. Therefore, all error codes are grouped into two categories:
Assuming a bug free implementation of DAVID SDK and DAVID4 server software, the exception david::ProtocolException should never occur. This exception indicates a mismatch of what the client transmits to server and what the server expects from the client.
Here is an example for one of the possible error handling patterns that distinguishes between connection and function exceptions: XXX
The DAVID SDK is developed and tested using Microsoft Visual Studio 2012. But it should compile under other modern C++ compilers as well.
Minimum requirements:
Recommended:
Best way to learn more about the DAVID SDK is to study some examples. Within this documentation you find a list of all examples here and some more information in the namespace examples. We also provide a sample project for Visual Studio that includes all examples. You can find it in your DAVID SDK directory under
If you want to integrate remote functions on a specific platform that is not directly supported by our standard C++ API, have a look at our Low Level Interface.