next up previous contents
Next: 2. Class Reference Up: cppclient Previous: Contents   Contents

1. Overview

The C++ client (client_libs/c++) is generally the most comprehensive library, since it is used to test new features as they are implemented in the server. It is also the most widely used client library and thus the best debugged. Having said that, this client is not perfect, but should be straightforward to use by anyone familiar with C++.

The C++ library is built on a "service proxy" model in which the client maintains local objects that are proxies for remote services. There are two kinds of proxies: the special server proxy PlayerClient and the various device-specific proxies. Each kind of proxy is implemented as a separate class. The user first creates a PlayerClient proxy and uses it to establish a connection to a Player server. Next, the proxies of the appropriate device-specific types are created and initialized using the existing PlayerClient proxy. To make this process concrete, consider the following simple example (for clarity, we omit some error-checking):

  int main(int argc, char **argv)
    /* Connect to Player server on "localhost" at default port */
    PlayerClient robot("localhost");
    /* Request access to the ptz camera */
    PtzProxy zp(&robot,0,'a');

    int dir = 1;
      // print out current camera state
      if(zp.pan > 80 || zp.pan < -80)
        dir = -dir;
      zp.SetCam(zp.pan + dir * 5,zp.tilt,zp.zoom);

    // won't actually get here, but...

This program will continuously pan the pan-tilt-zoom camera unit left and right1.1. First, a PlayerClient proxy is created, using the default constructor to connect to the server listening at localhost:6665. Next, a PtzProxy is created to control the camera. The constructor for this object uses the existing PlayerClient proxy to establish "all" ('a') access to the 0th pan-tilt-zoom camera. Finally, we enter a simple loop that reads the current camera state and writes back a new state with the pan angle changed slightly.

With that simple example in mind, we now describe the full functionality of the C++ client library.

next up previous contents
Next: 2. Class Reference Up: cppclient Previous: Contents   Contents