Skip to content
This repository
Browse code

stage: added player plugin test, added CMake options to toggle buildi…

…ng plugin and plugin tests
  • Loading branch information...
commit 0922512ab60cf21d9f25b217562e2d726d7b0bc7 1 parent ffebe7c
jeremy_asher authored
7 CMakeLists.txt
@@ -10,6 +10,8 @@ SET( APIVERSION ${V_MAJOR}.${V_MINOR} )
10 10 # minimum version of Player to build the plugin
11 11 SET( MIN_PLAYER 2.1.0 )
12 12
  13 +OPTION (BUILD_PLAYER_PLUGIN "Build Player plugin" ON)
  14 +OPTION (BUILD_LSPTEST "Build Player plugin tests" OFF)
13 15
14 16 cmake_minimum_required( VERSION 2.4 FATAL_ERROR )
15 17
@@ -59,7 +61,6 @@ ELSE (PKGCONFIG)
59 61 MESSAGE (STATUS "pkg-config not found, skipping Player plugin")
60 62 ENDIF (PKGCONFIG)
61 63
62   -
63 64 # find FLTK and set flags
64 65 FIND_PROGRAM (FLTKCONFIG NAMES fltk-config)
65 66 IF (FLTKCONFIG)
@@ -107,9 +108,9 @@ ADD_SUBDIRECTORY(examples)
107 108 ADD_SUBDIRECTORY(assets)
108 109 ADD_SUBDIRECTORY(worlds)
109 110
110   -IF ( PLAYER_FOUND )
  111 +IF ( BUILD_PLAYER_PLUGIN AND PLAYER_FOUND )
111 112 ADD_SUBDIRECTORY(libstageplugin)
112   -ENDIF ( PLAYER_FOUND )
  113 +ENDIF ( BUILD_PLAYER_PLUGIN AND PLAYER_FOUND )
113 114
114 115
115 116 # generate a cpack config file used to create packaged tarballs
5 libstageplugin/CMakeLists.txt
... ... @@ -1,3 +1,4 @@
  1 +MESSAGE( STATUS "Building Player plugin" )
1 2
2 3 link_directories( ${PLAYER_LIBDIR} )
3 4 include_directories( ${PLAYER_INCLUDE_DIRS})
@@ -26,6 +27,10 @@ target_link_libraries( stageplugin
26 27
27 28 )
28 29
  30 +IF (BUILD_LSPTEST)
  31 + ADD_SUBDIRECTORY(test)
  32 +ENDIF (BUILD_LSPTEST)
  33 +
29 34 INSTALL(TARGETS stageplugin
30 35 LIBRARY DESTINATION lib
31 36 )
1  libstageplugin/p_driver.cc
@@ -568,6 +568,7 @@ void StgDriver::Update(void)
568 568 for( int i=0; i<(int)this->devices->len; i++ )
569 569 {
570 570 Interface* interface = (Interface*)g_ptr_array_index( this->devices, i );
  571 +
571 572 assert( interface );
572 573
573 574 switch( interface->addr.interf )
6 libstageplugin/p_fiducial.cc
@@ -68,11 +68,7 @@ void InterfaceFiducial::Publish( void )
68 68 assert( fids );
69 69
70 70 pdata.fiducials_count = fidmod->fiducial_count;
71   -
72   - //printf( "reporting %d fiducials\n",
73   - // fcount );
74   -
75   - pdata.fiducials = new player_fiducial_item_t[pdata.fiducials_count];
  71 + pdata.fiducials = new player_fiducial_item_t[pdata.fiducials_count];
76 72
77 73 for( int i=0; i<(int)pdata.fiducials_count; i++ )
78 74 {
3  libstageplugin/p_speech.cc
@@ -81,9 +81,6 @@ int InterfaceSpeech::ProcessMessage( QueuePointer & resp_queue,
81 81
82 82 mod->Say( pcmd->string );
83 83
84   - this->driver->Publish(this->addr, resp_queue,
85   - PLAYER_MSGTYPE_RESP_ACK,
86   - PLAYER_SPEECH_CMD_SAY);
87 84 return( 0 );
88 85 }
89 86 else
10 libstageplugin/test/CMakeLists.txt
... ... @@ -0,0 +1,10 @@
  1 +MESSAGE( STATUS "Building Player plugin tests" )
  2 +
  3 +pkg_search_module( PLAYERC REQUIRED playerc )
  4 +
  5 +SET( lspTestSrcs
  6 + lsp_test.cc
  7 +)
  8 +
  9 +add_executable( lsp_test ${lspTestSrcs} )
  10 +target_link_libraries( lsp_test PLAYERC )
42 libstageplugin/test/lsp_test.cc
... ... @@ -0,0 +1,42 @@
  1 +#include <stdio.h>
  2 +
  3 +#include <libplayerc/playerc.h>
  4 +
  5 +int main(int argc, const char **argv)
  6 +{
  7 + int i;
  8 + playerc_client_t *client;
  9 + playerc_position2d_t *position2d;
  10 +
  11 + // Create a client and connect it to the server.
  12 + client = playerc_client_create(NULL, "localhost", 6665);
  13 + if (0 != playerc_client_connect(client))
  14 + return -1;
  15 +
  16 + // Create and subscribe to a position2d device.
  17 + position2d = playerc_position2d_create(client, 0);
  18 + if (playerc_position2d_subscribe(position2d, PLAYER_OPEN_MODE))
  19 + return -1;
  20 +
  21 + // Make the robot spin!
  22 + if (0 != playerc_position2d_set_cmd_vel(position2d, 0, 0, DTOR(40.0), 1))
  23 + return -1;
  24 +
  25 + for (i = 0; i < 200; i++)
  26 + {
  27 + // Wait for new data from server
  28 + playerc_client_read(client);
  29 +
  30 + // Print current robot pose
  31 + printf("position2d : %f %f %f\n",
  32 + position2d->px, position2d->py, position2d->pa);
  33 + }
  34 +
  35 + // Shutdown
  36 + playerc_position2d_unsubscribe(position2d);
  37 + playerc_position2d_destroy(position2d);
  38 + playerc_client_disconnect(client);
  39 + playerc_client_destroy(client);
  40 +
  41 + return 0;
  42 +}
2  worlds/simple.cfg
@@ -18,7 +18,7 @@ driver
18 18 )
19 19
20 20 # Create a Stage driver and attach position2d and laser interfaces
21   -# to the model "robot1"
  21 +# to the model "r0"
22 22 driver
23 23 (
24 24 name "stage"

0 comments on commit 0922512

Please sign in to comment.
Something went wrong with that request. Please try again.