Revision: 6901
http://playerstage.svn.sourceforge.net/playerstage/?rev=6901&view=rev
Author: jeremy_asher
Date: 2008-07-22 17:01:34 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
libstageplugin: fixed remaining bug in p_laser, updated laser test
Modified Paths:
--------------
code/stage/trunk/libstageplugin/p_laser.cc
code/stage/trunk/libstageplugin/test/lsp_test_laser.cc
code/stage/trunk/libstageplugin/test/lsp_test_laser.hh
Modified: code/stage/trunk/libstageplugin/p_laser.cc
===================================================================
--- code/stage/trunk/libstageplugin/p_laser.cc 2008-07-22 16:14:59 UTC (rev
6900)
+++ code/stage/trunk/libstageplugin/p_laser.cc 2008-07-22 17:01:34 UTC (rev
6901)
@@ -115,9 +115,8 @@
stg_laser_cfg_t cfg = mod->GetConfig();
cfg.resolution = 1.0 / plc->resolution;
- cfg.range_bounds.max = plc->max_range;
cfg.fov = plc->max_angle - plc->min_angle;
- cfg.interval = 1E6 / plc->scanning_frequency;
+ cfg.interval = 1.0E6 / plc->scanning_frequency;
PRINT_DEBUG4( "setting laser config: fov %.2f max_range %.2f " /
"resolution %.2f interval %.2f",
@@ -160,7 +159,7 @@
plc.max_range = cfg.range_bounds.max;
plc.range_res = 1.0; // todo
plc.intensity = 1; // todo
- plc.scanning_frequency = 1E6 / cfg.interval;
+ plc.scanning_frequency = 1.0E6 / cfg.interval;
this->driver->Publish(this->addr, resp_queue,
PLAYER_MSGTYPE_RESP_ACK,
Modified: code/stage/trunk/libstageplugin/test/lsp_test_laser.cc
===================================================================
--- code/stage/trunk/libstageplugin/test/lsp_test_laser.cc 2008-07-22
16:14:59 UTC (rev 6900)
+++ code/stage/trunk/libstageplugin/test/lsp_test_laser.cc 2008-07-22
17:01:34 UTC (rev 6901)
@@ -3,6 +3,7 @@
using namespace lspTest;
const double Laser::Delta = 0.01;
+const int Laser::Samples = 361;
void Laser::setUp() {
connect();
@@ -20,10 +21,10 @@
void Laser::testConfig() {
double min = -M_PI/2;
double max = +M_PI/2;
- double res = M_PI/361; // sick laser default
- double range_res = 1; // not being used by stage
+ double res = M_PI/Samples; // sick laser default
+ double range_res = 1; // not being used by stage
unsigned char intensity = 1; // not being used by stage
- double freq = 1.0/1E4; // stage default
+ double freq = 10; // 10Hz / 100ms (stage default)
CPPUNIT_ASSERT( playerc_laser_set_config( laserProxy, min, max, res,
range_res, intensity, freq ) == 0 );
@@ -53,12 +54,20 @@
void Laser::testData() {
playerc_client_read( client );
- printf("\nlaser: [%14.3f ] [%d]\n ", laserProxy->info.datatime,
laserProxy->scan_count);
+ CPPUNIT_ASSERT( laserProxy->info.datatime > 0 );
+ CPPUNIT_ASSERT( laserProxy->scan_count == Samples );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "min scan angle", -M_PI/2,
laserProxy->scan[0][1], Delta );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "max scan angle", M_PI/2,
laserProxy->scan[Samples-1][1], Delta );
for ( int i = 0; i < laserProxy->scan_count; i++ ) {
- printf("[%6.3f, %6.3f ] \n", laserProxy->scan[i][0],
laserProxy->scan[i][1]);
+ double distance = laserProxy->scan[i][0];
+ CPPUNIT_ASSERT( distance <= laserProxy->max_range );
+ CPPUNIT_ASSERT( distance >= laserProxy->min_right );
+// printf("[%6.3f, %6.3f ] \n", laserProxy->scan[i][0],
laserProxy->scan[i][1]);
}
- // check first and last sample's angle
- // check number of samples
+ laserProxy->info.fresh = 0;
+ playerc_client_read( client );
+ CPPUNIT_ASSERT( laserProxy->info.fresh == 1 );
+
// check range of each is within max and min
}
\ No newline at end of file
Modified: code/stage/trunk/libstageplugin/test/lsp_test_laser.hh
===================================================================
--- code/stage/trunk/libstageplugin/test/lsp_test_laser.hh 2008-07-22
16:14:59 UTC (rev 6900)
+++ code/stage/trunk/libstageplugin/test/lsp_test_laser.hh 2008-07-22
17:01:34 UTC (rev 6901)
@@ -23,6 +23,7 @@
void testData();
static const double Delta;
+ static const int Samples;
public:
void setUp();
void tearDown();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit