lsp_test_blobfinder.cc
Go to the documentation of this file.
00001 #include "lsp_test_blobfinder.hh"
00002 
00003 using namespace lspTest;
00004 
00005 void Blobfinder::setUp() {
00006         connect();
00007         blobProxy = playerc_blobfinder_create( client, 0 );
00008         CPPUNIT_ASSERT( playerc_blobfinder_subscribe( blobProxy, PLAYER_OPEN_MODE ) == 0 );
00009 }
00010 
00011 
00012 void Blobfinder::tearDown() {
00013         CPPUNIT_ASSERT( playerc_blobfinder_unsubscribe( blobProxy ) == 0 );
00014         playerc_blobfinder_destroy( blobProxy );
00015         disconnect();
00016 }
00017 
00018 void Blobfinder::testData() {
00019         playerc_client_read( client );
00020         
00021         // verify that we're getting new data
00022         blobProxy->info.fresh = 0;
00023         playerc_client_read( client );
00024         CPPUNIT_ASSERT_MESSAGE( "blobfinder updating", blobProxy->info.fresh == 1 );
00025         
00026         CPPUNIT_ASSERT( blobProxy->info.datatime > 0 );
00027 
00028         //printf("\ncolor0: 0x%X, color1: 0x%X\n", blobProxy->blobs[0].color, blobProxy->blobs[1].color);
00029         
00030         // check stage defaults
00031         CPPUNIT_ASSERT( blobProxy->width == 80 );
00032         CPPUNIT_ASSERT( blobProxy->height == 60 );
00033         
00034         // Make sure we see three blobs: wall, robot, wall
00035         CPPUNIT_ASSERT_EQUAL_MESSAGE( "blobs_count", (unsigned int)3, blobProxy->blobs_count ); // lsp_test.world
00036         // sanity checks
00037         CPPUNIT_ASSERT( blobProxy->blobs[1].range > 0 );
00038         CPPUNIT_ASSERT( blobProxy->blobs[1].area > 0 );
00039         CPPUNIT_ASSERT( blobProxy->blobs[1].y > 0 );
00040         CPPUNIT_ASSERT( blobProxy->blobs[1].left < blobProxy->blobs[1].right );
00041         CPPUNIT_ASSERT( blobProxy->blobs[1].top < blobProxy->blobs[1].bottom );
00042         
00043         // robot should be red
00044         CPPUNIT_ASSERT( blobProxy->blobs[1].color == 0xFFFF0000 );
00045         
00046         // robot should be closer
00047         CPPUNIT_ASSERT( blobProxy->blobs[0].range > blobProxy->blobs[1].range );
00048         
00049         // robot should be towards the right
00050         uint32_t robotCenter = blobProxy->blobs[1].x;
00051         uint32_t imageCenter = blobProxy->width / 2;
00052         //printf(" robotCenter: %d, imageCenter: %d\n", robotCenter, imageCenter);
00053         CPPUNIT_ASSERT( robotCenter > imageCenter );
00054         
00055         
00056         
00057 //      CPPUNIT_ASSERT_EQUAL_MESSAGE( "id", (unsigned int)2, blobProxy->blobs[0].id );
00058 
00059 }


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Thu Aug 27 2015 15:20:57