lsp_test_laser.cc
Go to the documentation of this file.
1 #include "lsp_test_laser.hh"
2 
3 using namespace lspTest;
4 
5 const int Laser::Samples = 361;
6 
7 void Laser::setUp() {
8  connect();
9  laserProxy = playerc_laser_create( client, 0 );
10  CPPUNIT_ASSERT( playerc_laser_subscribe( laserProxy, PLAYER_OPEN_MODE ) == 0 );
11 }
12 
13 
15  CPPUNIT_ASSERT( playerc_laser_unsubscribe( laserProxy ) == 0 );
16  playerc_laser_destroy( laserProxy );
17  disconnect();
18 }
19 
21  double min = -M_PI/2;
22  double max = +M_PI/2;
23  double res = M_PI/Samples; // sick laser default
24  double range_res = 1; // not being used by stage
25  unsigned char intensity = 1; // not being used by stage
26  double freq = 10; // 10Hz / 100ms (stage default)
27 
28  CPPUNIT_ASSERT( playerc_laser_set_config( laserProxy, min, max, res, range_res, intensity, freq ) == 0 );
29 
30  double min2, max2, res2, range_res2, freq2;
31  unsigned char intensity2 = 1;
32  CPPUNIT_ASSERT( playerc_laser_get_config( laserProxy, &min2, &max2, &res2, &range_res2, &intensity2, &freq2 ) == 0 );
33 
34  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "min scan angle", min, min2, Delta );
35  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "max scan angle", max, max2, Delta );
36  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "angular resolution", res, res2, Delta );
37  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "range resolution", range_res, range_res2, Delta );
38  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "scan freq", freq, freq2, Delta );
39  CPPUNIT_ASSERT_EQUAL_MESSAGE( "intensity", intensity, intensity2 );
40 }
41 
43  CPPUNIT_ASSERT( playerc_laser_get_geom( laserProxy ) == 0 );
44 
45  // values from lsp_test.world and sick.inc
46  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (x)", 0.03, laserProxy->pose[0], Delta );
47  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (y)", 0, laserProxy->pose[1], Delta );
48  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "pose (angle)", 0, laserProxy->pose[2], Delta );
49  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "size (x)", 0.156, laserProxy->size[0], Delta );
50  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "size (y)", 0.155, laserProxy->size[1], Delta );
51 }
52 
54  playerc_client_read( client );
55 
56  // verify that we're getting new data
57  laserProxy->info.fresh = 0;
58  playerc_client_read( client );
59  CPPUNIT_ASSERT_MESSAGE( "laser updating", laserProxy->info.fresh == 1 );
60 
61  CPPUNIT_ASSERT( laserProxy->info.datatime > 0 );
62  CPPUNIT_ASSERT( laserProxy->scan_count == Samples );
63  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "min scan angle", -M_PI/2, laserProxy->scan[0][1], Delta );
64  CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "max scan angle", M_PI/2, laserProxy->scan[Samples-1][1], Delta );
65 
66  for ( int i = 0; i < laserProxy->scan_count; i++ ) {
67  double distance = laserProxy->scan[i][0];
68 
69  // check range of each sample is within max and min
70  CPPUNIT_ASSERT( distance <= laserProxy->max_range );
71  CPPUNIT_ASSERT( distance >= laserProxy->min_right );
72 
73  // printf("[%6.3f, %6.3f ] \n", laserProxy->scan[i][0], laserProxy->scan[i][1]);
74  }
75 }
float res
Definition: make_rsn.c:27
playerc_laser_t * laserProxy
static const int Samples
static const double Delta
playerc_client_t * client


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 Mon Jun 10 2019 15:06:09